Added: New architecture to targets / arch folders and hake files
[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 ourCommonFlags = [ Str "-m64",
40                    Str "-mno-red-zone",
41                    Str "-fPIE",
42                    Str "-fno-stack-protector", 
43                    Str "-Wno-unused-but-set-variable",
44                    Str "-Wno-packed-bitfield-compat",
45 -- the intel mic architecture has no "normal" SIMD extensions
46                    Str "-mno-mmx",
47                    Str "-mno-sse",
48                    Str "-mno-sse2",
49                    Str "-mno-sse3",
50                    Str "-mno-sse4.1",
51                    Str "-mno-sse4.2",
52                    Str "-mno-sse4",
53                    Str "-mno-sse4a",
54                    Str "-mno-3dnow", 
55 -- specific Xeon Phi architecture
56                    Str "-Wa,-march=k1om",
57                    Str "-Wa,-mtune=k1om",
58                    Str "-D__x86__" ]
59
60 cFlags = ArchDefaults.commonCFlags
61                ++ ArchDefaults.commonFlags
62                ++ ourCommonFlags
63
64 cxxFlags = ArchDefaults.commonCxxFlags
65                  ++ ArchDefaults.commonFlags
66                  ++ ourCommonFlags
67
68 cDefines = ArchDefaults.cDefines options
69
70 ourLdFlags = [ Str "-Wl,-z,max-page-size=0x1000",
71                Str "-Wl,--build-id=none",
72                Str "-m64" ]
73
74 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
75 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
76
77 options = (ArchDefaults.options arch archFamily) { 
78             optFlags = cFlags,
79             optCxxFlags = cxxFlags,
80             optDefines = cDefines,
81             optLdFlags = ldFlags,
82             optLdCxxFlags = ldCxxFlags,
83             optInterconnectDrivers = ["lmp", "ump", "multihop"],
84             optFlounderBackends = ["lmp", "ump", "multihop"]
85           }
86
87 --
88 -- The kernel is "different"
89 --
90
91 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
92                                 "-nostdinc",
93                                 "-std=c99",
94                                 "-m64",
95                                 "-mno-red-zone",
96                                 "-fPIE",
97                                 "-fno-stack-protector",
98                                 "-U__linux__",
99                                 "-Wall",
100                                 "-Wshadow",
101                                 "-Wstrict-prototypes",
102                                 "-Wold-style-definition",
103                                 "-Wmissing-prototypes",
104                                 "-Wmissing-declarations",
105                                 "-Wmissing-field-initializers",
106                                 "-Wredundant-decls",
107                                 "-Wno-packed-bitfield-compat",
108                                 "-Wno-unused-but-set-variable",
109                                 "-Werror",
110                                 "-imacros deputy/nodeputy.h" ] ]
111 --                                "-mno-mmx",
112 --                                "-mno-sse",
113 --                                "-mno-sse2",
114 --                                "-mno-sse3",
115 --                                "-mno-sse4.1",
116 --                                "-mno-sse4.2",
117 --              "-Wno-unused-but-set-variable",
118 --                                "-mno-sse4",
119 --                                "-mno-sse4a",
120 --                                "-mno-3dnow" 
121
122
123 kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
124                                 "-pie",
125                                  "-fno-builtin",
126                                 "-nostdlib",
127                                 "-Wl,--fatal-warnings",
128                                 "-m64" ] ]
129
130
131 ------------------------------------------------------------------------
132 --
133 -- Now, commands to actually do something
134 --
135 ------------------------------------------------------------------------
136
137 --
138 -- Compilers
139 --
140 cCompiler = ArchDefaults.cCompiler arch compiler
141 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
142 makeDepend = ArchDefaults.makeDepend arch compiler
143 makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
144 cToAssembler = ArchDefaults.cToAssembler arch compiler
145 assembler = ArchDefaults.assembler arch compiler
146 archive = ArchDefaults.archive arch
147 linker = ArchDefaults.linker arch compiler
148 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
149
150 --
151 -- Link the kernel (CPU Driver)
152 -- 
153 linkKernel :: Options -> [String] -> [String] -> String -> HRule
154 linkKernel opts objs libs kbin = 
155     let linkscript = "/kernel/linker.lds"
156     in
157       Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
158                       NStr "-T", In BuildTree arch "/kernel/linker.lds",
159                       Str "-o", Out arch kbin 
160                     ]
161                     ++ (optLdFlags opts)
162                     ++
163                     [ In BuildTree arch o | o <- objs ]
164                     ++
165                     [ In BuildTree arch l | l <- libs ]
166                     ++ 
167                     [ NL, NStr "/bin/echo -e '\\0002' | dd of=",
168                       Out arch kbin, 
169                       Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer"
170                     ]
171                    ),
172               Rule [ Str "cpp", 
173                      NStr "-I", NoDep SrcTree "src" "/kernel/include/",
174                      Str "-D__ASSEMBLER__", 
175                      Str "-P", In SrcTree "src" "/kernel/arch/k1om/linker.lds.in",
176                      Out arch linkscript 
177                    ]
178             ]