X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FDriverPipeline.hs;h=9ac8fe4586db068bd0c5f125390af8c43a7be6e5;hb=2c77e092c3a6a5b936838afb7b338af70de2c689;hp=3daa76e4cbadbbe29ebac0e29440f4748dcf9437;hpb=07e06f2e67518dd0db10ecd1115a2ac00249af53;p=ghc-hetmet.git diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 3daa76e..9ac8fe4 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -260,11 +260,10 @@ compile' (nothingCompiler, interactiveCompiler, batchCompiler) compileStub :: GhcMonad m => HscEnv -> Module -> ModLocation -> m FilePath compileStub hsc_env mod location = do - let (o_base, o_ext) = splitExtension (ml_obj_file location) - stub_o = (o_base ++ "_stub") <.> o_ext - -- compile the _stub.c file w/ gcc - let (stub_c,_,_) = mkStubPaths (hsc_dflags hsc_env) (moduleName mod) location + let (stub_c,_,stub_o) = mkStubPaths (hsc_dflags hsc_env) + (moduleName mod) location + runPipeline StopLn hsc_env (stub_c,Nothing) Nothing (SpecificFile stub_o) Nothing{-no ModLocation-} @@ -297,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 @@ -348,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 @@ -1099,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 ] @@ -1116,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) @@ -1147,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 ++ @@ -1164,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] @@ -1175,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"