28d8538347b84541311b50db4946e99c85a7a419
[barrelfish] / hake / K1om.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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8 --
9 -- Architectural definitions for Barrelfish on x86_mic.
10 --
11 -- This architecture is used to build for the Intel Xeon Phi architecture.
12 -- 
13 --------------------------------------------------------------------------
14
15 module K1om where
16
17 import HakeTypes
18 import Path
19 import qualified Config
20 import qualified ArchDefaults
21
22 -------------------------------------------------------------------------
23 --
24 -- Architecture specific definitions for X86_64-k1om
25 --
26 -------------------------------------------------------------------------
27
28 arch = "k1om"
29 archFamily = "k1om"
30
31 --compiler = "x86_64-k1om-barrelfish-gcc"
32 --objcopy  = "x86_64-k1om-barrelfish-objcopy"
33 --objdump  = "x86_64-k1om-barrelfish-objdump"
34 --ar       = "x86_64-k1om-barrelfish-ar"
35 --ranlib   = "x86_64-k1om-barrelfish-ranlib"
36 --cxxcompiler = "x86_64-k1om-barrelfish-g++"
37
38
39 compiler = "gcc"
40 objcopy  = "objcopy"
41 objdump  = "objdump"
42 ar       = "ar"
43 ranlib   = "ranlib"
44 cxxcompiler = "g++"
45
46
47 ourCommonFlags = [ --Str "-m64",
48                    Str "-mno-red-zone",
49                    Str "-fPIE",
50                    Str "-fno-stack-protector", 
51                    Str "-Wno-unused-but-set-variable",
52                    Str "-Wno-packed-bitfield-compat",
53 -- the intel mic architecture has no "normal" SIMD extensions
54 --                   Str "-mno-mmx",
55 --                   Str "-mno-sse",
56                    Str "-mno-sse2",
57                    Str "-mno-sse3",
58                    Str "-mno-sse4.1",
59                    Str "-mno-sse4.2",
60                    Str "-mno-sse4",
61                    Str "-mno-sse4a",
62                    Str "-mno-3dnow", 
63 -- specific Xeon Phi architecture
64 --                   Str "-Wa,-march=k1om",
65 --                   Str "-Wa,-mtune=k1om",
66                    Str "-D__x86__" ]
67
68 cFlags = ArchDefaults.commonCFlags
69                ++ ArchDefaults.commonFlags
70                ++ ourCommonFlags
71
72 cxxFlags = ArchDefaults.commonCxxFlags
73                  ++ ArchDefaults.commonFlags
74                  ++ ourCommonFlags
75
76 cDefines = ArchDefaults.cDefines options
77
78 -- TODO> -m elf_i386
79 ourLdFlags = [ Str "-Wl,-z,max-page-size=0x1000",
80 --               Str "-Wl,-b,elf64-k1om",
81 --               Str "-Wl,--oformat,elf64-k1om",
82                Str "-Wl,--build-id=none"]
83                --Str "-m64" 
84
85
86 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
87 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
88
89 options = (ArchDefaults.options arch archFamily) { 
90             optFlags = cFlags,
91             optCxxFlags = cxxFlags,
92             optDefines = cDefines,
93             optLdFlags = ldFlags,
94             optLdCxxFlags = ldCxxFlags,
95             optInterconnectDrivers = ["lmp", "ump", "multihop"],
96             optFlounderBackends = ["lmp", "ump", "multihop"]
97           }
98
99 --
100 -- The kernel is "different"
101 --
102
103 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
104                                 "-nostdinc",
105                                 "-std=c99",
106                                 "-mno-red-zone",
107                                 "-fPIE",
108                                 "-fno-stack-protector",
109                                 "-U__linux__",
110                                 "-Wall",
111                                 "-Wshadow",
112                                 "-Wstrict-prototypes",
113                                 "-Wold-style-definition",
114                                 "-Wmissing-prototypes",
115                                 "-Wmissing-declarations",
116                                 "-Wmissing-field-initializers",
117                                 "-Wredundant-decls",
118                                 "-Wno-packed-bitfield-compat",
119                                 "-Wno-unused-but-set-variable",
120                                 "-Werror",
121                                 "-imacros deputy/nodeputy.h",
122                                 "-mno-mmx",
123                                 "-mno-sse",
124                                 "-mno-sse2",
125                                 "-mno-sse3",
126                                 "-mno-sse4.1",
127                                 "-mno-sse4.2",
128 --              "-Wno-unused-but-set-variable",
129                                 "-mno-sse4",
130                                 "-mno-sse4a",
131                                 "-mno-3dnow" ] ]
132         
133
134 kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
135 --                                 "-Wl,-b,elf64-k1om",
136                                 -- "-Wl,-A,k1om",
137 --                                 "-Wl,--oformat,elf64-k1om",
138                                  "-pie",
139                                  "-fno-builtin",
140                                  "-nostdlib",
141                                  "-Wl,--fatal-warnings"] ]
142 --                                "-m64" 
143
144
145 ------------------------------------------------------------------------
146 --
147 -- Now, commands to actually do something
148 --
149 ------------------------------------------------------------------------
150
151 --
152 -- Compilers
153 --
154 cCompiler = ArchDefaults.cCompiler arch compiler
155 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
156 makeDepend = ArchDefaults.makeDepend arch compiler
157 makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
158 cToAssembler = ArchDefaults.cToAssembler arch compiler
159 assembler = ArchDefaults.assembler arch compiler
160 archive = ArchDefaults.archive arch
161 linker = ArchDefaults.linker arch compiler
162 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
163
164 --
165 -- Link the kernel (CPU Driver)
166 -- 
167 linkKernel :: Options -> [String] -> [String] -> String -> HRule
168 linkKernel opts objs libs kbin = 
169     let linkscript = "/kernel/linker.lds"
170     in
171       Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
172                       NStr "-T", In BuildTree arch "/kernel/linker.lds",
173                       Str "-o", Out arch kbin 
174                     ]
175                     ++ (optLdFlags opts)
176                     ++
177                     [ In BuildTree arch o | o <- objs ]
178                     ++
179                     [ In BuildTree arch l | l <- libs ]
180                     ++ 
181                     [ NL, NStr "/bin/echo -e '\\0002' | dd of=",
182                       Out arch kbin, 
183                       Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer"
184                     ]
185                    ),
186               Rule [ Str "cpp", 
187                      NStr "-I", NoDep SrcTree "src" "/kernel/include/",
188                      Str "-D__ASSEMBLER__", 
189                      Str "-P", In SrcTree "src" "/kernel/arch/k1om/linker.lds.in",
190                      Out arch linkscript 
191                    ]
192             ]