hake: fixing linking order of static libraries by grouping them, removing newlib...
authorAdam Turowski <adam.turowski@inf.ethz.ch>
Thu, 22 Jun 2017 06:59:39 +0000 (08:59 +0200)
committerAdam Turowski <adam.turowski@inf.ethz.ch>
Thu, 22 Jun 2017 07:03:53 +0000 (09:03 +0200)
Signed-off-by: Adam Turowski <adam.turowski@inf.ethz.ch>

hake/ARMv7.hs
hake/ArchDefaults.hs
hake/Config.hs.template
hake/RuleDefs.hs

index 1149fe4..d88b3ae 100644 (file)
@@ -43,6 +43,8 @@ ourCommonFlags = [ Str "-fno-unwind-tables",
                    Str "-march=armv7-a",
                    Str "-mapcs",
                    Str "-mabi=aapcs-linux",
+                   Str "-mfloat-abi=hard",
+                   Str "-mfpu=vfpv3",
                    Str "-msingle-pic-base",
                    Str "-mpic-register=r9",
                    Str "-DPIC_REGISTER=R9",
@@ -54,7 +56,7 @@ ourCommonFlags = [ Str "-fno-unwind-tables",
                    Str "-Wno-format"
  ]
 
-cFlags = ArchDefaults.commonCFlags 
+cFlags = ArchDefaults.commonCFlags
          ++ ArchDefaults.commonFlags
          ++ ourCommonFlags
 
@@ -73,11 +75,11 @@ ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
 
 stdLibs = ArchDefaults.stdLibs arch
 
-options = (ArchDefaults.options arch archFamily) { 
+options = (ArchDefaults.options arch archFamily) {
             optFlags = cFlags,
             optCxxFlags = cxxFlags,
             optDefines = cDefines,
-            optDependencies = 
+            optDependencies =
                 [ PreDep InstallTree arch "/include/trace_definitions/trace_defs.h",
                   PreDep InstallTree arch "/include/errors/errno.h",
                   PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
@@ -118,7 +120,7 @@ kernelCFlags = [ Str s | s <- [ "-fno-builtin",
                                 "-march=armv7-a",
                                 "-mapcs",
                                 "-mabi=aapcs-linux",
-                                "-mfloat-abi=soft",
+                                "-mfloat-abi=hard",
                                 "-fPIE",
                                 "-U__linux__",
                                 "-Wall",
@@ -184,10 +186,10 @@ linkKernel opts objs libs name driverType =
                     (ArchDefaults.kernelLibs arch)
                    ),
               -- Generate kernel assembly dump
-              Rule [ Str objdump, 
-                     Str "-d", 
+              Rule [ Str objdump,
+                     Str "-d",
                      Str "-M reg-names-raw",
-                     In BuildTree arch kbinary, 
+                     In BuildTree arch kbinary,
                      Str ">", Out arch kasmdump ],
               Rule [ Str "cpp",
                      NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv7",
index 705c3d3..9484890 100644 (file)
@@ -30,7 +30,6 @@ commonFlags = [ Str s | s <- [ "-fno-builtin",
                                 "-Werror" ] ]
 
 commonCFlags = [ Str s | s <- [ "-std=c99",
-                                "-U__STRICT_ANSI__", -- for newlib headers
                                 "-Wstrict-prototypes",
                                 "-Wold-style-definition",
                                 "-Wmissing-prototypes" ] ]
@@ -52,8 +51,7 @@ cxxFlags = [ Str s | s <- [ "-Wno-packed-bitfield-compat" ] ]
        ++ commonCxxFlags
 
 cDefines options = [ Str ("-D"++s) | s <- [ "BARRELFISH",
-                                            "BF_BINARY_PREFIX=\\\"\\\"",
-                                            "_WANT_IO_C99_FORMATS" -- newlib C99 printf format specifiers
+                                            "BF_BINARY_PREFIX=\\\"\\\""
                                           ]
                    ]
                    ++ Config.defines
@@ -62,11 +60,7 @@ cDefines options = [ Str ("-D"++s) | s <- [ "BARRELFISH",
 cStdIncs arch archFamily =
     [ NoDep BFSrcTree "src" "/include",
       NoDep BFSrcTree "src" ("/include/arch" </> archFamily),
-      NoDep BFSrcTree "src" "/lib/newlib/newlib/libc/include",
-      NoDep BFSrcTree "src" "/include/c",
       NoDep BFSrcTree "src" ("/include/target" </> archFamily),
-      NoDep BFSrcTree "src" Config.lwipxxxInc, -- XXX
-      NoDep BFSrcTree "src" Config.lwipInc,
       NoDep InstallTree arch "/include",
       NoDep BFSrcTree "src" ".",
       NoDep SrcTree "src" ".",
@@ -95,7 +89,7 @@ stdLibs arch =
       In InstallTree arch "/lib/libterm_client.a",
       In InstallTree arch "/lib/liboctopus_parser.a", -- XXX: For NS client in libbarrelfish
       In InstallTree arch "/errors/errno.o",
-      In InstallTree arch ("/lib/libnewlib.a"),
+      In InstallTree arch ("/lib/libc.a"),
       In InstallTree arch "/lib/libcompiler-rt.a",
       --In InstallTree arch "/lib/libposixcompat.a",
       --In InstallTree arch "/lib/libvfs.a",
@@ -313,11 +307,15 @@ linker arch compiler opts objs libs mods bin =
     ++
     [ In BuildTree arch o | o <- objs ]
     ++
+    [Str "-Wl,--start-group"]
+    ++
     [ In BuildTree arch l | l <- libs ]
     ++
     [Str "-Wl,--whole-archive"] ++ [ In BuildTree arch l | l <- mods ] ++ [Str "-Wl,--no-whole-archive"]
     ++
     (optLibs opts)
+    ++
+    [Str "-Wl,--end-group"]
 
 
 --
@@ -336,9 +334,11 @@ cxxlinker arch cxxcompiler opts objs libs mods bin =
     ++
     [ In BuildTree arch l | l <- libs ]
     ++
-    [Str "-Wl,--whole-archive"] ++ [ In BuildTree arch l | l <- mods ] ++ [Str "-Wl,--no-whole-archive"]
+    [Str "-Wl,--start-group -Wl,--whole-archive"] ++ [ In BuildTree arch l | l <- mods ] ++ [Str "-Wl,--no-whole-archive"]
     ++
     (optCxxLibs opts)
+    ++
+    [Str "-Wl,--end-group"]
 
 --
 -- Strip debug symbols from an executable
index 888334d..8a1c27d 100644 (file)
@@ -9,7 +9,7 @@
 -- Attn: Systems Group.
 --
 -- Configuration options for Hake
--- 
+--
 --------------------------------------------------------------------------
 
 module Config where
@@ -114,7 +114,7 @@ dot          = "dot"       --   "    "
 inkscape     = "inkscape"
 
 -- path to source and install directories; these are automatically set by
--- hake.sh at setup time 
+-- hake.sh at setup time
 source_dir :: String
 -- source_dir = undefined -- (set by hake.sh, see end of file)
 
@@ -204,7 +204,7 @@ ethersrv_debug = False
 netd_debug :: Bool
 netd_debug = False
 
-libacpi_debug :: Bool 
+libacpi_debug :: Bool
 libacpi_debug = False
 
 acpi_interface_debug :: Bool
@@ -417,12 +417,6 @@ defines = [ Str ("-D" ++ d) | d <- [
              ], d /= "" ]
 
 
--- Sets the include path for lwIP
-lwipInc :: String
-lwipInc = "/lib/lwip/src/include"
-lwipxxxInc :: String
-lwipxxxInc = "/lib/lwip/src/include/ipv4"
-
 -- some defines depend on the architecture/compile options
 arch_defines :: Options -> [RuleToken]
 arch_defines opts
@@ -436,19 +430,3 @@ arch_defines opts
        | d <- ["CONFIG_FLOUNDER_BACKEND_" ++ (map toUpper n)
                | n <- optFlounderBackends opts]
       ]
-
--- newlib common compile flags (maybe put these in a config.h file?)
-newlibAddCFlags :: [String]
-newlibAddCFlags = [ "-DPACKAGE_NAME=\"newlib\"" ,
-                    "-DPACKAGE_TARNAME=\"newlib\"",
-                    "-DPACKAGE_VERSION=\"1.19.0\"",
-                    "-DPACKAGE_BUGREPORT=\"\"",
-                    "-DPACKAGE_URL=\"\"",
-                    "-D_I386MACH_ALLOW_HW_INTERRUPTS",
-                    "-DMISSING_SYSCALL_NAMES",
-                    "-D_WANT_IO_C99_FORMATS",
-                    "-D_COMPILING_NEWLIB",
-                    "-D_WANT_IO_LONG_LONG",
-                    "-D_WANT_IO_LONG_DOUBLE",
-                    "-D_MB_CAPABLE",
-                    "-D__BSD_VISIBLE"]
index 9b528fe..1a1ed55 100644 (file)
@@ -123,8 +123,6 @@ kernelIncludes arch = [ NoDep BuildTree arch f | f <- [
                     "/kernel/include",
                     "/include",
                     "/include/arch" </> archFamily arch,
-                    "/lib/newlib/newlib/libc/include",
-                    "/include/c",
                     "/include/target" </> archFamily arch]]
                  ++ kernelOptIncludes arch
 
@@ -1085,7 +1083,9 @@ appGetOptionsForArch arch args =
     (options arch) { extraIncludes =
                          [ NoDep SrcTree "src" a | a <- Args.addIncludes args]
                          ++
-                         [ NoDep BuildTree arch a | a <- Args.addGeneratedIncludes args],
+                         [ NoDep BuildTree arch a | a <- Args.addGeneratedIncludes args]
+                         ++
+                         [ NoDep SrcTree "src" ("/include" </> l) | l <- Args.addLibraries args ],
                      optIncludes = (optIncludes $ options arch) \\
                          [ NoDep SrcTree "src" i | i <- Args.omitIncludes args ],
                      optFlags = (optFlags $ options arch) \\
@@ -1216,7 +1216,9 @@ libraryBuildFn tdb tf args =
 
 libGetOptionsForArch arch args =
     (options arch) { extraIncludes =
-                         [ NoDep SrcTree "src" a | a <- Args.addIncludes args],
+                         [ NoDep SrcTree "src" a | a <- Args.addIncludes args]
+                         ++
+                         [ NoDep SrcTree "src" ("/include" </> l) | l <- Args.addLibraries args ],
                      optIncludes = (optIncludes $ options arch) \\
                          [ NoDep SrcTree "src" i | i <- Args.omitIncludes args ],
                      optFlags = (optFlags $ options arch) \\