X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FDriverPipeline.hs;h=f8073c92113b76ca8bc0fb39fe195f5712721db7;hb=95a3e5532edfbf62cafa59067021d89d7e1c6852;hp=c4ac65f7b6ea2241093bcebf411a2ae442e4a2a5;hpb=269949584b7c124e95543c5c006822db4cec4d8b;p=ghc-hetmet.git diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index c4ac65f..f8073c9 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -974,21 +974,21 @@ runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc then [] else [ "-ffloat-store" ]) ++ #endif + -- gcc's -fstrict-aliasing allows two accesses to memory -- to be considered non-aliasing if they have different types. -- This interacts badly with the C code we generate, which is -- very weakly typed, being derived from C--. ["-fno-strict-aliasing"] - - liftIO $ SysTools.runCc dflags ( -- force the C compiler to interpret this file as C when -- compiling .hc files, by adding the -x c option. -- Also useful for plain .c files, just in case GHC saw a -- -x c option. [ SysTools.Option "-x", if cc_phase `eqPhase` Ccpp - then SysTools.Option "c++" else SysTools.Option "c"] ++ + then SysTools.Option "c++" + else SysTools.Option "c"] ++ [ SysTools.FileOption "" input_fn , SysTools.Option "-o" , SysTools.FileOption "" output_fn @@ -996,6 +996,18 @@ runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc ++ map SysTools.Option ( md_c_flags ++ pic_c_flags + +#if defined(mingw32_TARGET_OS) + -- Stub files generated for foreign exports references the runIO_closure + -- and runNonIO_closure symbols, which are defined in the base package. + -- These symbols are imported into the stub.c file via RtsAPI.h, and the + -- way we do the import depends on whether we're currently compiling + -- the base package or not. + ++ (if thisPackage dflags == basePackageId + then [ "-DCOMPILING_BASE_PACKAGE" ] + else []) +#endif + #ifdef sparc_TARGET_ARCH -- We only support SparcV9 and better because V8 lacks an atomic CAS -- instruction. Note that the user can still override this @@ -1005,13 +1017,6 @@ runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc -- This is a temporary hack. ++ ["-mcpu=v9"] #endif -#if defined(darwin_TARGET_OS) && defined(i386_TARGET_ARCH) - -- By default, gcc on OS X will generate SSE - -- instructions, which need things 16-byte aligned, - -- but we don't 16-byte align things. Thus drop - -- back to generic i686 compatibility. Trac #2983. - ++ ["-march=i686"] -#endif ++ (if hcc && mangle then md_regd_c_flags else []) @@ -1141,8 +1146,8 @@ runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc output_fn <- get_output_fn dflags StopLn maybe_loc let base_o = dropExtension output_fn - split_odir = base_o ++ "_split" osuf = objectSuf dflags + split_odir = base_o ++ "_" ++ osuf ++ "_split" createDirectoryHierarchy split_odir @@ -1423,7 +1428,7 @@ linkBinary dflags o_files dep_packages = do let thread_opts | WayThreaded `elem` ways = [ -#if !defined(mingw32_TARGET_OS) && !defined(freebsd_TARGET_OS) +#if !defined(mingw32_TARGET_OS) && !defined(freebsd_TARGET_OS) && !defined(haiku_TARGET_OS) "-lpthread" #endif #if defined(osf3_TARGET_OS) @@ -1442,6 +1447,12 @@ linkBinary dflags o_files dep_packages = do ] ++ map SysTools.Option ( md_c_flags + +#ifdef mingw32_TARGET_OS + -- Permit the linker to auto link _symbol to _imp_symbol. + -- This lets us link against DLLs without needing an "import library". + ++ ["-Wl,--enable-auto-import"] +#endif ++ o_files ++ extra_ld_inputs ++ lib_path_opts @@ -1597,6 +1608,11 @@ linkDynLib dflags o_files dep_packages = do ++ map (SysTools.FileOption "") o_files ++ map SysTools.Option ( md_c_flags + + -- Permit the linker to auto link _symbol to _imp_symbol + -- This lets us link against DLLs without needing an "import library" + ++ ["-Wl,--enable-auto-import"] + ++ extra_ld_inputs ++ lib_path_opts ++ extra_ld_opts @@ -1627,16 +1643,22 @@ linkDynLib dflags o_files dep_packages = do -- later, so that it will not complain about the use of the option -- -undefined dynamic_lookup above. -- -install_name - -- Causes the dynamic linker to ignore the DYLD_LIBRARY_PATH when loading - -- this lib and instead look for it at its absolute path. - -- When installing the .dylibs (see target.mk), we'll change that path to - -- point to the place they are installed. Therefore, we won't have to set - -- up DYLD_LIBRARY_PATH specifically for ghc. + -- Mac OS/X stores the path where a dynamic library is (to be) installed + -- in the library itself. It's called the "install name" of the library. + -- Then any library or executable that links against it before it's + -- installed will search for it in its ultimate install location. By + -- default we set the install name to the absolute path at build time, but + -- it can be overridden by the -dylib-install-name option passed to ghc. + -- Cabal does this. ----------------------------------------------------------------------------- let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; } - pwd <- getCurrentDirectory + instName <- case dylibInstallName dflags of + Just n -> return n + Nothing -> do + pwd <- getCurrentDirectory + return $ pwd `combine` output_fn SysTools.runLink dflags ([ SysTools.Option verb , SysTools.Option "-dynamiclib" @@ -1646,7 +1668,8 @@ linkDynLib dflags o_files dep_packages = do ++ map SysTools.Option ( md_c_flags ++ o_files - ++ [ "-undefined", "dynamic_lookup", "-single_module", "-Wl,-macosx_version_min","-Wl,10.3", "-install_name " ++ (pwd output_fn) ] + ++ [ "-undefined", "dynamic_lookup", "-single_module", "-Wl,-macosx_version_min","-Wl,10.5", + "-Wl,-read_only_relocs,suppress", "-install_name", instName ] ++ extra_ld_inputs ++ lib_path_opts ++ extra_ld_opts