X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fmain%2FDriverPipeline.hs;h=f8f06765a33cc0ef8d2b626320cd56581058c7b4;hp=6557c05c4e610e4eb90cefb144db7bd085b743bc;hb=3d411991d3c697e5a93e6922582fe8299210e83d;hpb=8844513929ccd58854227ddb6275095a1f1742ad diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 6557c05..f8f0676 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -296,6 +296,26 @@ link NoLink _ _ _ = return Succeeded link LinkBinary dflags batch_attempt_linking hpt + = link' dflags batch_attempt_linking hpt + +link LinkDynLib dflags batch_attempt_linking hpt + = link' dflags batch_attempt_linking hpt + +#ifndef GHCI +-- warning suppression +link other _ _ _ = panicBadLink other +#endif + +panicBadLink :: GhcLink -> a +panicBadLink other = panic ("link: GHC not built to link this way: " ++ + show other) + +link' :: DynFlags -- dynamic flags + -> Bool -- attempt linking in batch mode? + -> HomePackageTable -- what to link + -> IO SuccessFlag + +link' dflags batch_attempt_linking hpt | batch_attempt_linking = do let @@ -347,13 +367,6 @@ link LinkBinary dflags batch_attempt_linking hpt text " Main.main not exported; not linking.") return Succeeded --- warning suppression -link other _ _ _ = panicBadLink other - -panicBadLink :: GhcLink -> a -panicBadLink other = panic ("link: GHC not built to link this way: " ++ - show other) - linkingNeeded :: DynFlags -> [Linkable] -> [PackageId] -> IO Bool linkingNeeded dflags linkables pkg_deps = do @@ -1098,6 +1111,7 @@ runPhase As _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc -- might be a hierarchical module. createDirectoryHierarchy (takeDirectory output_fn) + let (md_c_flags, _) = machdepCCOpts dflags SysTools.runAs dflags (map SysTools.Option as_opts ++ [ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ] @@ -1115,7 +1129,8 @@ runPhase As _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc , SysTools.FileOption "" input_fn , SysTools.Option "-o" , SysTools.FileOption "" output_fn - ]) + ] + ++ map SysTools.Option md_c_flags) return (StopLn, dflags, maybe_loc, output_fn) @@ -1146,6 +1161,7 @@ runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc split_obj n = split_odir takeFileName base_o ++ "__" ++ show n <.> osuf + let (md_c_flags, _) = machdepCCOpts dflags let assemble_file n = SysTools.runAs dflags (map SysTools.Option as_opts ++ @@ -1163,7 +1179,8 @@ runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc , SysTools.Option "-o" , SysTools.FileOption "" (split_obj n) , SysTools.FileOption "" (split_s n) - ]) + ] + ++ map SysTools.Option md_c_flags) mapM_ assemble_file [1..n] @@ -1174,7 +1191,9 @@ runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc SysTools.Option "-Wl,-r", SysTools.Option ld_x_flag, SysTools.Option "-o", - SysTools.FileOption "" output_fn ] ++ args) + SysTools.FileOption "" output_fn ] + ++ map SysTools.Option md_c_flags + ++ args) ld_x_flag | null cLD_X = "" | otherwise = "-Wl,-x" @@ -1376,12 +1395,6 @@ linkBinary dflags o_files dep_packages = do framework_opts = concat [ ["-framework", fw] | fw <- reverse frameworks ] -- reverse because they're added in reverse order from the cmd line #endif -#ifdef mingw32_TARGET_OS - let dynMain = if not opt_Static then - (head (libraryDirs (getPackageDetails (pkgState dflags) rtsPackageId))) ++ "/Main.dyn_o" - else - "" -#endif -- probably _stub.o files extra_ld_inputs <- readIORef v_Ld_inputs @@ -1423,9 +1436,6 @@ linkBinary dflags o_files dep_packages = do ++ map SysTools.Option ( md_c_flags ++ o_files -#ifdef mingw32_TARGET_OS - ++ [dynMain] -#endif ++ extra_ld_inputs ++ lib_path_opts ++ extra_ld_opts