import UniqFM ( eltsUFM )
import ErrUtils
import DynFlags
-import StaticFlags ( v_Ld_inputs, opt_Static, WayName(..) )
+import StaticFlags ( v_Ld_inputs, opt_Static, opt_HardwireLibPaths, WayName(..) )
import Config
import Panic
import Util
return (CompOK details iface maybe_old_linkable)
handleBatch (HscRecomp hasStub, iface, details)
| isHsBoot src_flavour
- = return (CompOK details iface Nothing)
+ = do SysTools.touch dflags' "Touching object file"
+ object_filename
+ return (CompOK details iface Nothing)
| otherwise
= do stub_unlinked <- getStubLinkable hasStub
(hs_unlinked, unlinked_time) <-
-- dependencies, and eliminating duplicates.
pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
- let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
+ let pkg_lib_path_opts = concat (map get_pkg_lib_path_opts pkg_lib_paths)
+ get_pkg_lib_path_opts l | opt_HardwireLibPaths && not opt_Static = ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l]
+ | otherwise = ["-L" ++ l]
let lib_paths = libraryPaths dflags
let lib_path_opts = map ("-L"++) lib_paths
let static = opt_Static
let no_hs_main = dopt Opt_NoHsMain dflags
let o_file = outputFile dflags
- let output_fn = case o_file of { Just s -> s; Nothing -> "HSdll.dll"; }
pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
-- probably _stub.o files
extra_ld_inputs <- readIORef v_Ld_inputs
- -- opts from -optdll-<blah>
+ let (md_c_flags, _) = machdepCCOpts dflags
+#if defined(mingw32_HOST_OS)
+ -----------------------------------------------------------------------------
+ -- Making a DLL
+ -----------------------------------------------------------------------------
+
+ let output_fn = case o_file of { Just s -> s; Nothing -> "HSdll.dll"; }
+
+ -- opts from -optdll-<blah>
let extra_ld_opts = getOpts dflags opt_dll
let pstate = pkgState dflags
then []
else [ head (libraryDirs rts_pkg) ++ "/Main.dll_o",
head (libraryDirs base_pkg) ++ "/PrelMain.dll_o" ]
-
- let (md_c_flags, _) = machdepCCOpts dflags
SysTools.runMkDLL dflags
([ SysTools.Option verb
, SysTools.Option "-o"
then [ "" ]
else [ "--export-all" ])
))
-
+#else
+ -----------------------------------------------------------------------------
+ -- Making a DSO
+ -----------------------------------------------------------------------------
+ -- opts from -optl-<blah>
+ let extra_ld_opts = getOpts dflags opt_l
+ let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
+
+ SysTools.runLink dflags
+ ([ SysTools.Option verb
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ]
+ ++ map SysTools.Option (
+ md_c_flags
+ ++ o_files
+ ++ [ "-shared", "-Wl,-Bsymbolic" ] -- we need symbolic linking to resolve non-PIC intra-package-relocations
+ ++ extra_ld_inputs
+ ++ lib_path_opts
+ ++ extra_ld_opts
+ ++ pkg_lib_path_opts
+ ++ pkg_link_opts
+ ))
+#endif
-- -----------------------------------------------------------------------------
-- Running CPP
hscMaybeAdjustTarget :: DynFlags -> Phase -> HscSource -> HscTarget -> HscTarget
-hscMaybeAdjustTarget dflags stop HsBootFile current_hsc_lang
- = HscNothing -- No output (other than Foo.hi-boot) for hs-boot files
hscMaybeAdjustTarget dflags stop other current_hsc_lang
= hsc_lang
where