hake: removing an unknown warning option from the x86_64 target
[barrelfish] / hake / X86_64.hs
1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-2010, ETH Zurich.
3 -- All rights reserved.
4 --
5 -- This file is distributed under the terms in the attached LICENSE file.
6 -- If you do not find this file, copies can be found by writing to:
7 -- ETH Zurich D-INFK, Universitaetstasse 6, CH-8092 Zurich. Attn: Systems Group.
8 --
9 -- Architectural definitions for Barrelfish on x86_64.
10 --
11 --------------------------------------------------------------------------
12
13 module X86_64 where
14
15 import HakeTypes
16 import qualified Config
17 import qualified ArchDefaults
18
19 -------------------------------------------------------------------------
20 --
21 -- Architecture specific definitions for x86_64
22 --
23 -------------------------------------------------------------------------
24
25 arch = "x86_64"
26 archFamily = "x86_64"
27
28 compiler    = Config.x86_cc
29 cxxcompiler = Config.x86_cxx
30 objcopy     = Config.x86_objcopy
31
32 ourCommonFlags = [ Str "-m64",
33                    Str "-mno-red-zone",
34                    Str "-fPIE",
35                    Str "-fno-stack-protector",
36                    Str "-Wno-unused-but-set-variable",
37                    Str "-Wno-packed-bitfield-compat",
38                    Str "-D__x86__" ]
39
40 cFlags = ArchDefaults.commonCFlags
41                ++ ArchDefaults.commonFlags
42                ++ ourCommonFlags
43
44 cxxFlags = ArchDefaults.commonCxxFlags
45                  ++ ArchDefaults.commonFlags
46                  ++ ourCommonFlags
47          ++ [Str "-std=gnu++11"]
48
49 cDefines = ArchDefaults.cDefines options
50
51 ourLdFlags = [ Str "-Wl,-z,max-page-size=0x1000",
52                Str "-Wl,--build-id=none",
53                Str "-Wl,--verbose",
54                Str "-static",
55                Str "-m64" ]
56
57 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
58 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
59
60 options = (ArchDefaults.options arch archFamily) {
61             optFlags = cFlags,
62             optCxxFlags = cxxFlags,
63             optDefines = cDefines,
64             optLdFlags = ldFlags,
65             optLdCxxFlags = ldCxxFlags,
66             optInterconnectDrivers = ["lmp", "ump", "multihop", "local"],
67             optFlounderBackends = ["lmp", "ump", "multihop", "local"]
68           }
69
70 --
71 -- The kernel is "different"
72 --
73
74 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
75                                 "-nostdinc",
76                                 "-std=c99",
77                                 "-m64",
78                                 "-mno-red-zone",
79                                 "-fPIE",
80                                 "-fno-stack-protector",
81                                 "-U__linux__",
82                                 "-Wall",
83                                 "-Wshadow",
84                                 "-Wstrict-prototypes",
85                                 "-Wold-style-definition",
86                                 "-Wmissing-prototypes",
87                                 "-Wmissing-declarations",
88                                 "-Wmissing-field-initializers",
89                                 "-Wredundant-decls",
90                                 "-Wno-packed-bitfield-compat",
91                                 "-Wno-unused-but-set-variable",
92                                 "-Werror",
93                                 "-imacros deputy/nodeputy.h",
94                                 "-mno-mmx",
95                                 "-mno-sse",
96                                 "-mno-sse2",
97                                 "-mno-sse3",
98                                 "-mno-sse4.1",
99                                 "-mno-sse4.2",
100                                 "-mno-sse4",
101                                 "-mno-sse4a",
102                                 "-mno-3dnow" ]]
103
104 kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
105                                 "-pie",
106                                  "-fno-builtin",
107                                 "-nostdlib",
108                                 "-Wl,--fatal-warnings",
109                                 "-m64" ] ]
110
111
112 ------------------------------------------------------------------------
113 --
114 -- Now, commands to actually do something
115 --
116 ------------------------------------------------------------------------
117
118 --
119 -- Compilers
120 --
121 cCompiler = ArchDefaults.cCompiler arch compiler Config.cOptFlags
122 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler Config.cOptFlags
123 makeDepend = ArchDefaults.makeDepend arch compiler
124 makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
125 cToAssembler = ArchDefaults.cToAssembler arch compiler Config.cOptFlags
126 assembler = ArchDefaults.assembler arch compiler Config.cOptFlags
127 archive = ArchDefaults.archive arch
128 linker = ArchDefaults.linker arch compiler
129 strip = ArchDefaults.strip arch objcopy
130 debug = ArchDefaults.debug arch objcopy
131 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
132
133 --
134 -- Link the kernel (CPU Driver)
135 --
136 linkKernel :: Options -> [String] -> [String] -> String -> HRule
137 linkKernel opts objs libs kbin =
138     let linkscript = "/kernel/linker.lds"
139     in
140       Rules [ Rule ([ Str compiler ] ++
141                     map Str Config.cOptFlags ++
142                     [ NStr "-T", In BuildTree arch "/kernel/linker.lds",
143                       Str "-o", Out arch kbin
144                     ]
145                     ++ (optLdFlags opts)
146                     ++
147                     [ In BuildTree arch o | o <- objs ]
148                     ++
149                     [ In BuildTree arch l | l <- libs ]
150                     ++
151                     (ArchDefaults.kernelLibs arch)
152                     ++
153                     [ NL, NStr "bash -c \"echo -e '\\0002'\" | dd of=",
154                       Out arch kbin,
155                       Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer"
156                     ]
157                    ),
158               Rule [ Str "cpp",
159                      NStr "-I", NoDep SrcTree "src" "/kernel/include/",
160                      Str "-D__ASSEMBLER__",
161                      Str "-P", In SrcTree "src" "/kernel/arch/x86_64/linker.lds.in",
162                      Out arch linkscript
163                    ],
164               -- Produce a stripped binary
165               Rule [ Str objcopy,
166                      Str "-g",
167                      In BuildTree arch kbin,
168                      Out arch (kbin++ ".stripped")
169                    ]
170             ]