-import StringBuffer ( hGetStringBuffer )
-import BasicTypes ( SuccessFlag(..) )
-import Maybes ( expectJust )
-import ParserCoreUtils ( getCoreModuleName )
+import StringBuffer ( hGetStringBuffer )
+import BasicTypes ( SuccessFlag(..) )
+import Maybes ( expectJust )
+import ParserCoreUtils ( getCoreModuleName )
-> (FilePath, Maybe Phase) -- ^ filename and starting phase
-> m (DynFlags, FilePath)
preprocess hsc_env (filename, mb_phase) =
-> (FilePath, Maybe Phase) -- ^ filename and starting phase
-> m (DynFlags, FilePath)
preprocess hsc_env (filename, mb_phase) =
o_time <- liftIO $ getModificationTime object_filename
return ([DotO object_filename], o_time)
let linkable = LM unlinked_time this_mod
o_time <- liftIO $ getModificationTime object_filename
return ([DotO object_filename], o_time)
let linkable = LM unlinked_time this_mod
-- results in obj/A.o, and src/A_stub.c. If we compile src/A_stub.c with
-- -odir obj, we would get obj/src/A_stub.o, which is wrong; we want
-- obj/A_stub.o.
-- results in obj/A.o, and src/A_stub.c. If we compile src/A_stub.c with
-- -odir obj, we would get obj/src/A_stub.o, which is wrong; we want
-- obj/A_stub.o.
let (errs,extra_times) = splitEithers e_extra_times
let obj_times = map linkableTime linkables ++ extra_times
if not (null errs) || any (t <) obj_times
let (errs,extra_times) = splitEithers e_extra_times
let obj_times = map linkableTime linkables ++ extra_times
if not (null errs) || any (t <) obj_times
HscEnv -> Phase -> (FilePath, Maybe Phase) -> m FilePath
compileFile hsc_env stop_phase (src, mb_phase) = do
exists <- liftIO $ doesFileExist src
HscEnv -> Phase -> (FilePath, Maybe Phase) -> m FilePath
compileFile hsc_env stop_phase (src, mb_phase) = do
exists <- liftIO $ doesFileExist src
- | StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
- -- -o foo applies to linker
- | Just o_file <- mb_o_file = SpecificFile o_file
- -- -o foo applies to the file we are compiling now
- | otherwise = Persistent
-
- stop_phase' = case stop_phase of
- As | split -> SplitAs
+ | StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
+ -- -o foo applies to linker
+ | Just o_file <- mb_o_file = SpecificFile o_file
+ -- -o foo applies to the file we are compiling now
+ | otherwise = Persistent
+
+ stop_phase' = case stop_phase of
+ As | split -> SplitAs
- -- ^ We want a persistent file, i.e. a file in the current directory
- -- derived from the input filename, but with the appropriate extension.
- -- eg. in "ghc -c Foo.hs" the output goes into ./Foo.o.
+ -- ^ We want a persistent file, i.e. a file in the current directory
+ -- derived from the input filename, but with the appropriate extension.
+ -- eg. in "ghc -c Foo.hs" the output goes into ./Foo.o.
-> HscEnv -- ^ Compilation environment
-> (FilePath,Maybe Phase) -- ^ Input filename (and maybe -x suffix)
-> Maybe FilePath -- ^ original basename (if different from ^^^)
-> HscEnv -- ^ Compilation environment
-> (FilePath,Maybe Phase) -- ^ Input filename (and maybe -x suffix)
-> Maybe FilePath -- ^ original basename (if different from ^^^)
-- this is a function which will be used to calculate output file names
-- as we go along (we partially apply it to some of its inputs here)
let get_output_fn = getOutputFilename stop_phase output basename
-- Execute the pipeline...
-- this is a function which will be used to calculate output file names
-- as we go along (we partially apply it to some of its inputs here)
let get_output_fn = getOutputFilename stop_phase output basename
-- Execute the pipeline...
- (dflags', output_fn, maybe_loc) <-
- pipeLoop hsc_env start_phase stop_phase input_fn
- basename suffix' get_output_fn maybe_loc
+ (dflags', output_fn, maybe_loc) <-
+ pipeLoop hsc_env start_phase stop_phase input_fn
+ basename suffix' get_output_fn maybe_loc
- -> FilePath -> String -> Suffix
- -> (DynFlags -> Phase -> Maybe ModLocation -> IO FilePath)
- -> Maybe ModLocation
- -> m (DynFlags, FilePath, Maybe ModLocation)
+ -> FilePath -> String -> Suffix
+ -> (DynFlags -> Phase -> Maybe ModLocation -> IO FilePath)
+ -> Maybe ModLocation
+ -> m (DynFlags, FilePath, Maybe ModLocation)
- -- Something has gone wrong. We'll try to cover all the cases when
- -- this could happen, so if we reach here it is a panic.
- -- eg. it might happen if the -C flag is used on a source file that
- -- has {-# OPTIONS -fasm #-}.
- = panic ("pipeLoop: at phase " ++ show phase ++
- " but I wanted to stop at phase " ++ show stop_phase)
-
- | otherwise
+ -- Something has gone wrong. We'll try to cover all the cases when
+ -- this could happen, so if we reach here it is a panic.
+ -- eg. it might happen if the -C flag is used on a source file that
+ -- has {-# OPTIONS -fasm #-}.
+ = panic ("pipeLoop: at phase " ++ show phase ++
+ " but I wanted to stop at phase " ++ show stop_phase)
+
+ | otherwise
- func dflags next_phase maybe_location
- | is_last_phase, Persistent <- output = persistent_fn
- | is_last_phase, SpecificFile f <- output = return f
- | keep_this_output = persistent_fn
- | otherwise = newTempName dflags suffix
- where
- hcsuf = hcSuf dflags
- odir = objectDir dflags
- osuf = objectSuf dflags
- keep_hc = dopt Opt_KeepHcFiles dflags
- keep_raw_s = dopt Opt_KeepRawSFiles dflags
- keep_s = dopt Opt_KeepSFiles dflags
-
- myPhaseInputExt HCc = hcsuf
- myPhaseInputExt StopLn = osuf
- myPhaseInputExt other = phaseInputExt other
-
- is_last_phase = next_phase `eqPhase` stop_phase
-
- -- sometimes, we keep output from intermediate stages
- keep_this_output =
- case next_phase of
- StopLn -> True
- Mangle | keep_raw_s -> True
- As | keep_s -> True
- HCc | keep_hc -> True
- _other -> False
-
- suffix = myPhaseInputExt next_phase
-
- -- persistent object files get put in odir
- persistent_fn
- | StopLn <- next_phase = return odir_persistent
- | otherwise = return persistent
-
- persistent = basename <.> suffix
-
- odir_persistent
- | Just loc <- maybe_location = ml_obj_file loc
- | Just d <- odir = d </> persistent
- | otherwise = persistent
+ func dflags next_phase maybe_location
+ | is_last_phase, Persistent <- output = persistent_fn
+ | is_last_phase, SpecificFile f <- output = return f
+ | keep_this_output = persistent_fn
+ | otherwise = newTempName dflags suffix
+ where
+ hcsuf = hcSuf dflags
+ odir = objectDir dflags
+ osuf = objectSuf dflags
+ keep_hc = dopt Opt_KeepHcFiles dflags
+ keep_raw_s = dopt Opt_KeepRawSFiles dflags
+ keep_s = dopt Opt_KeepSFiles dflags
+
+ myPhaseInputExt HCc = hcsuf
+ myPhaseInputExt StopLn = osuf
+ myPhaseInputExt other = phaseInputExt other
+
+ is_last_phase = next_phase `eqPhase` stop_phase
+
+ -- sometimes, we keep output from intermediate stages
+ keep_this_output =
+ case next_phase of
+ StopLn -> True
+ Mangle | keep_raw_s -> True
+ As | keep_s -> True
+ HCc | keep_hc -> True
+ _other -> False
+
+ suffix = myPhaseInputExt next_phase
+
+ -- persistent object files get put in odir
+ persistent_fn
+ | StopLn <- next_phase = return odir_persistent
+ | otherwise = return persistent
+
+ persistent = basename <.> suffix
+
+ odir_persistent
+ | Just loc <- maybe_location = ml_obj_file loc
+ | Just d <- odir = d </> persistent
+ | otherwise = persistent
- Phase -- ^ Do this phase first
- -> Phase -- ^ Stop just before this phase
- -> HscEnv
- -> String -- ^ basename of original input source
- -> String -- ^ its extension
- -> FilePath -- ^ name of file which contains the input to this phase.
- -> (DynFlags -> Phase -> Maybe ModLocation -> IO FilePath)
- -- ^ how to calculate the output filename
- -> Maybe ModLocation -- ^ the ModLocation, if we have one
- -> m (Phase, -- next phase
- DynFlags, -- new dynamic flags
- Maybe ModLocation, -- the ModLocation, if we have one
- FilePath) -- output filename
-
- -- Invariant: the output filename always contains the output
- -- Interesting case: Hsc when there is no recompilation to do
- -- Then the output filename is still a .o file
+ Phase -- ^ Do this phase first
+ -> Phase -- ^ Stop just before this phase
+ -> HscEnv
+ -> String -- ^ basename of original input source
+ -> String -- ^ its extension
+ -> FilePath -- ^ name of file which contains the input to this phase.
+ -> (DynFlags -> Phase -> Maybe ModLocation -> IO FilePath)
+ -- ^ how to calculate the output filename
+ -> Maybe ModLocation -- ^ the ModLocation, if we have one
+ -> m (Phase, -- next phase
+ DynFlags, -- new dynamic flags
+ Maybe ModLocation, -- the ModLocation, if we have one
+ FilePath) -- output filename
+
+ -- Invariant: the output filename always contains the output
+ -- Interesting case: Hsc when there is no recompilation to do
+ -- Then the output filename is still a .o file
runPhase (HsPp sf) _stop hsc_env basename suff input_fn get_output_fn maybe_loc
= do let dflags = hsc_dflags hsc_env
if not (dopt Opt_Pp dflags) then
-- no need to preprocess, just pass input file along
runPhase (HsPp sf) _stop hsc_env basename suff input_fn get_output_fn maybe_loc
= do let dflags = hsc_dflags hsc_env
if not (dopt Opt_Pp dflags) then
-- no need to preprocess, just pass input file along
- else do
- let hspp_opts = getOpts dflags opt_F
- let orig_fn = basename <.> suff
- output_fn <- liftIO $ get_output_fn dflags (Hsc sf) maybe_loc
- liftIO $ SysTools.runPp dflags
- ( [ SysTools.Option orig_fn
- , SysTools.Option input_fn
- , SysTools.FileOption "" output_fn
- ] ++
- map SysTools.Option hspp_opts
- )
+ else do
+ let hspp_opts = getOpts dflags opt_F
+ let orig_fn = basename <.> suff
+ output_fn <- liftIO $ get_output_fn dflags (Hsc sf) maybe_loc
+ liftIO $ SysTools.runPp dflags
+ ( [ SysTools.Option orig_fn
+ , SysTools.Option input_fn
+ , SysTools.FileOption "" output_fn
+ ] ++
+ map SysTools.Option hspp_opts
+ )
-----------------------------------------------------------------------------
-- Hsc phase
-- Compilation of a single module, in "legacy" mode (_not_ under
-- the direction of the compilation manager).
-----------------------------------------------------------------------------
-- Hsc phase
-- Compilation of a single module, in "legacy" mode (_not_ under
-- the direction of the compilation manager).
let dflags0 = hsc_dflags hsc_env
-- we add the current directory (i.e. the directory in which
-- the .hs files resides) to the include path, since this is
-- what gcc does, and it's probably what you want.
let dflags0 = hsc_dflags hsc_env
-- we add the current directory (i.e. the directory in which
-- the .hs files resides) to the include path, since this is
-- what gcc does, and it's probably what you want.
-- Take -o into account if present
-- Very like -ohi, but we must *only* do this if we aren't linking
-- (If we're linking then the -o applies to the linked thing, not to
-- the object file for one module.)
-- Note the nasty duplication with the same computation in compileFile above
-- Take -o into account if present
-- Very like -ohi, but we must *only* do this if we aren't linking
-- (If we're linking then the -o applies to the linked thing, not to
-- the object file for one module.)
-- Note the nasty duplication with the same computation in compileFile above
- let expl_o_file = outputFile dflags
- location4 | Just ofile <- expl_o_file
- , isNoLink (ghcLink dflags)
- = location3 { ml_obj_file = ofile }
- | otherwise = location3
+ let expl_o_file = outputFile dflags
+ location4 | Just ofile <- expl_o_file
+ , isNoLink (ghcLink dflags)
+ = location3 { ml_obj_file = ofile }
+ | otherwise = location3
- -- Set source_unchanged to False unconditionally if
- -- (a) recompilation checker is off, or
- -- (b) we aren't going all the way to .o file (e.g. ghc -S)
- then return False
- -- Otherwise look at file modification dates
- else do o_file_exists <- liftIO $ doesFileExist o_file
- if not o_file_exists
- then return False -- Need to recompile
- else do t2 <- liftIO $ getModificationTime o_file
- if t2 > src_timestamp
- then return True
- else return False
+ -- Set source_unchanged to False unconditionally if
+ -- (a) recompilation checker is off, or
+ -- (b) we aren't going all the way to .o file (e.g. ghc -S)
+ then return False
+ -- Otherwise look at file modification dates
+ else do o_file_exists <- liftIO $ doesFileExist o_file
+ if not o_file_exists
+ then return False -- Need to recompile
+ else do t2 <- liftIO $ getModificationTime o_file
+ if t2 > src_timestamp
+ then return True
+ else return False
- let
- mod_summary = ModSummary { ms_mod = mod,
- ms_hsc_src = src_flavour,
- ms_hspp_file = input_fn,
+ let
+ mod_summary = ModSummary { ms_mod = mod,
+ ms_hsc_src = src_flavour,
+ ms_hspp_file = input_fn,
- ms_hspp_buf = hspp_buf,
- ms_location = location4,
- ms_hs_date = src_timestamp,
- ms_obj_date = Nothing,
- ms_imps = imps,
- ms_srcimps = src_imps }
+ ms_hspp_buf = hspp_buf,
+ ms_location = location4,
+ ms_hs_date = src_timestamp,
+ ms_obj_date = Nothing,
+ ms_imps = imps,
+ ms_srcimps = src_imps }
-- cc-options are not passed when compiling .hc files. Our
-- hc code doesn't not #include any header files anyway, so these
-- options aren't necessary.
-- cc-options are not passed when compiling .hc files. Our
-- hc code doesn't not #include any header files anyway, so these
-- options aren't necessary.
- -- on x86 the floating point regs have greater precision
- -- than a double, which leads to unpredictable results.
- -- By default, we turn this off with -ffloat-store unless
- -- the user specified -fexcess-precision.
- (if dopt Opt_ExcessPrecision dflags
- then []
+ -- on x86 the floating point regs have greater precision
+ -- than a double, which leads to unpredictable results.
+ -- By default, we turn this off with -ffloat-store unless
+ -- the user specified -fexcess-precision.
+ (if dopt Opt_ExcessPrecision dflags
+ then []
- -- 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++"
+ -- 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++"
- -- 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
+ -- 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
- liftIO $ SysTools.runMangle dflags (map SysTools.Option mangler_opts
- ++ [ SysTools.FileOption "" input_fn
- , SysTools.FileOption "" output_fn
- ]
- ++ map SysTools.Option machdep_opts)
+ liftIO $ SysTools.runMangle dflags (map SysTools.Option mangler_opts
+ ++ [ SysTools.FileOption "" input_fn
+ , SysTools.FileOption "" output_fn
+ ]
+ ++ map SysTools.Option machdep_opts)
- SysTools.runSplit dflags
- [ SysTools.FileOption "" input_fn
- , SysTools.FileOption "" split_s_prefix
- , SysTools.FileOption "" n_files_fn
- ]
+ SysTools.runSplit dflags
+ [ SysTools.FileOption "" input_fn
+ , SysTools.FileOption "" split_s_prefix
+ , SysTools.FileOption "" n_files_fn
+ ]
- -- Save the number of split files for future references
- s <- readFile n_files_fn
- let n_files = read s :: Int
- dflags' = dflags { splitInfo = Just (split_s_prefix, n_files) }
+ -- Save the number of split files for future references
+ s <- readFile n_files_fn
+ let n_files = read s :: Int
+ dflags' = dflags { splitInfo = Just (split_s_prefix, n_files) }
- -- we create directories for the object file, because it
- -- might be a hierarchical module.
- createDirectoryHierarchy (takeDirectory output_fn)
+ -- we create directories for the object file, because it
+ -- 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 ]
+ let (md_c_flags, _) = machdepCCOpts dflags
+ SysTools.runAs dflags
+ (map SysTools.Option as_opts
+ ++ [ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ]
- -- (e.g., -mcpu=ultrasparc). GCC picks the "best" -mcpu flag
- -- regardless of the ordering.
- --
- -- This is a temporary hack.
- ++ [ SysTools.Option "-mcpu=v9" ]
+ -- (e.g., -mcpu=ultrasparc). GCC picks the "best" -mcpu flag
+ -- regardless of the ordering.
+ --
+ -- This is a temporary hack.
+ ++ [ SysTools.Option "-mcpu=v9" ]
- ++ [ SysTools.Option "-c"
- , SysTools.FileOption "" input_fn
- , SysTools.Option "-o"
- , SysTools.FileOption "" output_fn
- ]
- ++ map SysTools.Option md_c_flags)
+ ++ [ SysTools.Option "-c"
+ , SysTools.FileOption "" input_fn
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ]
+ ++ map SysTools.Option md_c_flags)
-----------------------------------------------------------------------------
-- MoveBinary sort-of-phase
-- After having produced a binary, move it somewhere else and generate a
-----------------------------------------------------------------------------
-- MoveBinary sort-of-phase
-- After having produced a binary, move it somewhere else and generate a
copy dflags "copying PVM executable" input_fn pvm_executable
-- generate a wrapper script for running a parallel prg under PVM
writeFile input_fn (mk_pvm_wrapper_script pvm_executable pvm_executable_base sysMan)
copy dflags "copying PVM executable" input_fn pvm_executable
-- generate a wrapper script for running a parallel prg under PVM
writeFile input_fn (mk_pvm_wrapper_script pvm_executable pvm_executable_base sysMan)
- case (dynLibLoader dflags) of
- Wrapped wrapmode ->
- do
- let (o_base, o_ext) = splitExtension input_fn
- let wrapped_executable | o_ext == "exe" = (o_base ++ ".dyn") <.> o_ext
- | otherwise = input_fn ++ ".dyn"
- behaviour <- wrapper_behaviour dflags wrapmode dep_packages
+ case (dynLibLoader dflags) of
+ Wrapped wrapmode ->
+ do
+ let (o_base, o_ext) = splitExtension input_fn
+ let wrapped_executable | o_ext == "exe" = (o_base ++ ".dyn") <.> o_ext
+ | otherwise = input_fn ++ ".dyn"
+ behaviour <- wrapper_behaviour dflags wrapmode dep_packages
- , SysTools.Option ("-DBEHAVIOUR=\"" ++ behaviour' ++ "\"")
- , SysTools.Option "-o"
- , SysTools.FileOption "" input_fn
- ] ++ map (SysTools.FileOption "-I") (includeDirs rtsDetails))
- return True
- _ -> return True
+ , SysTools.Option ("-DBEHAVIOUR=\"" ++ behaviour' ++ "\"")
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" input_fn
+ ] ++ map (SysTools.FileOption "-I") (includeDirs rtsDetails))
+ return True
+ _ -> return True
- allpkg <- getPreloadPackagesAnd dflags dep_packages
- putStrLn (unwords (map (packageIdString . packageConfigId) allpkg))
- return $ 'F':s ++ ';':(seperateBySemiColon (map (packageIdString . packageConfigId) allpkg))
+ allpkg <- getPreloadPackagesAnd dflags dep_packages
+ putStrLn (unwords (map (packageIdString . packageConfigId) allpkg))
+ return $ 'F':s ++ ';':(seperateBySemiColon (map (packageIdString . packageConfigId) allpkg))
" if $running_under_some_shell;",
"# =!=!=!=!=!=!=!=!=!=!=!",
"# This script is automatically generated: DO NOT EDIT!!!",
" if $running_under_some_shell;",
"# =!=!=!=!=!=!=!=!=!=!=!",
"# This script is automatically generated: DO NOT EDIT!!!",
-- The list of packages passed to link is the list of packages on
-- which this program depends, as discovered by the compilation
-- manager. It is combined with the list of packages that the user
-- The list of packages passed to link is the list of packages on
-- which this program depends, as discovered by the compilation
-- manager. It is combined with the list of packages that the user
- ([ SysTools.Option verb
- , SysTools.Option "-o"
- , SysTools.FileOption "" output_fn
- , SysTools.Option "-shared"
- ] ++
- [ SysTools.FileOption "-Wl,--out-implib=" (output_fn ++ ".a")
- | dopt Opt_SharedImplib dflags
- ]
- ++ map (SysTools.FileOption "") o_files
- ++ map SysTools.Option (
- md_c_flags
-
+ ([ SysTools.Option verb
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ , SysTools.Option "-shared"
+ ] ++
+ [ SysTools.FileOption "-Wl,--out-implib=" (output_fn ++ ".a")
+ | dopt Opt_SharedImplib dflags
+ ]
+ ++ map (SysTools.FileOption "") o_files
+ ++ map SysTools.Option (
+ md_c_flags
+
-- -undefined dynamic_lookup:
-- Without these options, we'd have to specify the correct dependencies
-- for each of the dylibs. Note that we could (and should) do without this
-- -undefined dynamic_lookup:
-- Without these options, we'd have to specify the correct dependencies
-- for each of the dylibs. Note that we could (and should) do without this
- -- for all libraries except the RTS; all we need to do is to pass the
- -- correct HSfoo_dyn.dylib files to the link command.
- -- This feature requires Mac OS X 10.3 or later; there is a similar feature,
- -- -flat_namespace -undefined suppress, which works on earlier versions,
- -- but it has other disadvantages.
+ -- for all libraries except the RTS; all we need to do is to pass the
+ -- correct HSfoo_dyn.dylib files to the link command.
+ -- This feature requires Mac OS X 10.3 or later; there is a similar feature,
+ -- -flat_namespace -undefined suppress, which works on earlier versions,
+ -- but it has other disadvantages.
- -- Build the dynamic library as a single "module", i.e. no dynamic binding
- -- nonsense when referring to symbols from within the library. The NCG
- -- assumes that this option is specified (on i386, at least).
+ -- Build the dynamic library as a single "module", i.e. no dynamic binding
+ -- nonsense when referring to symbols from within the library. The NCG
+ -- assumes that this option is specified (on i386, at least).
- ([ SysTools.Option verb
- , SysTools.Option "-dynamiclib"
- , SysTools.Option "-o"
- , SysTools.FileOption "" output_fn
- ]
- ++ map SysTools.Option (
- md_c_flags
- ++ o_files
- ++ [ "-undefined", "dynamic_lookup", "-single_module",
+ ([ SysTools.Option verb
+ , SysTools.Option "-dynamiclib"
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ]
+ ++ map SysTools.Option (
+ md_c_flags
+ ++ o_files
+ ++ [ "-undefined", "dynamic_lookup", "-single_module",
- | not include_cc_opts = []
- | otherwise = (optc ++ md_c_flags)
- where
- optc = getOpts dflags opt_c
- (md_c_flags, _) = machdepCCOpts dflags
+ | not include_cc_opts = []
+ | otherwise = (optc ++ md_c_flags)
+ where
+ optc = getOpts dflags opt_c
+ (md_c_flags, _) = machdepCCOpts dflags
- let target_defs =
- [ "-D" ++ HOST_OS ++ "_BUILD_OS=1",
- "-D" ++ HOST_ARCH ++ "_BUILD_ARCH=1",
- "-D" ++ TARGET_OS ++ "_HOST_OS=1",
- "-D" ++ TARGET_ARCH ++ "_HOST_ARCH=1" ]
- -- remember, in code we *compile*, the HOST is the same our TARGET,
- -- and BUILD is the same as our HOST.
+ let target_defs =
+ [ "-D" ++ HOST_OS ++ "_BUILD_OS=1",
+ "-D" ++ HOST_ARCH ++ "_BUILD_ARCH=1",
+ "-D" ++ TARGET_OS ++ "_HOST_OS=1",
+ "-D" ++ TARGET_ARCH ++ "_HOST_ARCH=1" ]
+ -- remember, in code we *compile*, the HOST is the same our TARGET,
+ -- and BUILD is the same as our HOST.
- ++ map SysTools.Option include_paths
- ++ map SysTools.Option hsSourceCppOpts
- ++ map SysTools.Option hscpp_opts
- ++ map SysTools.Option cc_opts
- ++ map SysTools.Option target_defs
- ++ [ SysTools.Option "-x"
- , SysTools.Option "c"
- , SysTools.Option input_fn
- -- We hackily use Option instead of FileOption here, so that the file
- -- name is not back-slashed on Windows. cpp is capable of
- -- dealing with / in filenames, so it works fine. Furthermore
- -- if we put in backslashes, cpp outputs #line directives
- -- with *double* backslashes. And that in turn means that
- -- our error messages get double backslashes in them.
- -- In due course we should arrange that the lexer deals
- -- with these \\ escapes properly.
- , SysTools.Option "-o"
- , SysTools.FileOption "" output_fn
- ])
+ ++ map SysTools.Option include_paths
+ ++ map SysTools.Option hsSourceCppOpts
+ ++ map SysTools.Option hscpp_opts
+ ++ map SysTools.Option cc_opts
+ ++ map SysTools.Option target_defs
+ ++ [ SysTools.Option "-x"
+ , SysTools.Option "c"
+ , SysTools.Option input_fn
+ -- We hackily use Option instead of FileOption here, so that the file
+ -- name is not back-slashed on Windows. cpp is capable of
+ -- dealing with / in filenames, so it works fine. Furthermore
+ -- if we put in backslashes, cpp outputs #line directives
+ -- with *double* backslashes. And that in turn means that
+ -- our error messages get double backslashes in them.
+ -- In due course we should arrange that the lexer deals
+ -- with these \\ escapes properly.
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ])
- [ "-D__HASKELL1__="++cHaskell1Version
- , "-D__GLASGOW_HASKELL__="++cProjectVersionInt
- , "-D__HASKELL98__"
- , "-D__CONCURRENT_HASKELL__"
- ]
+ [ "-D__HASKELL1__="++cHaskell1Version
+ , "-D__GLASGOW_HASKELL__="++cProjectVersionInt
+ , "-D__HASKELL98__"
+ , "-D__CONCURRENT_HASKELL__"
+ ]
- keep_hc = dopt Opt_KeepHcFiles dflags
- hsc_lang
- -- don't change the lang if we're interpreting
- | current_hsc_lang == HscInterpreted = current_hsc_lang
-
- -- force -fvia-C if we are being asked for a .hc file
- | HCc <- stop = HscC
- | keep_hc = HscC
- -- otherwise, stick to the plan
- | otherwise = current_hsc_lang
+ keep_hc = dopt Opt_KeepHcFiles dflags
+ hsc_lang
+ -- don't change the lang if we're interpreting
+ | current_hsc_lang == HscInterpreted = current_hsc_lang
+
+ -- force -fvia-C if we are being asked for a .hc file
+ | HCc <- stop = HscC
+ | keep_hc = HscC
+ -- otherwise, stick to the plan
+ | otherwise = current_hsc_lang