From: wolfgang Date: Mon, 31 Jan 2005 05:27:16 +0000 (+0000) Subject: [project @ 2005-01-31 05:27:14 by wolfgang] X-Git-Tag: Initial_conversion_from_CVS_complete~1150 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=c560ae86eb28062f965b39fd43792d9dd4950011 [project @ 2005-01-31 05:27:14 by wolfgang] Reorganise handling of -fPIC flags passed to C compiler. The flags expected by gcc differ only slightly per platform (basically depending whether you are on a Mac or not), we don't need separate cases for every processor. TODO: Display an error message for platforms where -fPIC -fvia-C is not supported. --- diff --git a/ghc/compiler/main/DriverFlags.hs b/ghc/compiler/main/DriverFlags.hs index f99f20e..1dcfda3 100644 --- a/ghc/compiler/main/DriverFlags.hs +++ b/ghc/compiler/main/DriverFlags.hs @@ -13,6 +13,7 @@ module DriverFlags ( addCmdlineHCInclude, buildStaticHscOpts, machdepCCOpts, + picCCOpts, processArgs, OptKind(..), -- for DriverMkDepend only ) where @@ -711,23 +712,33 @@ machdepCCOpts dflags -- Disable Apple's precompiling preprocessor. It's a great thing -- for "normal" programs, but it doesn't support register variable -- declarations. + = return ( [], ["-no-cpp-precomp"] ) +#else + = return ( [], [] ) +#endif + +picCCOpts dflags +#if darwin_TARGET_OS + -- Apple prefers to do things the other way round. + -- PIC is on by default. -- -mdynamic-no-pic: - -- Turn off PIC code generation to save space and time. + -- Turn off PIC code generation. -- -fno-common: -- Don't generate "common" symbols - these are unwanted -- in dynamic libraries. - = if opt_PIC - then return ( ["-no-cpp-precomp", "-fno-common"], - ["-fno-common"] ) - else return ( ["-no-cpp-precomp", "-mdynamic-no-pic"], - ["-mdynamic-no-pic"] ) - -#elif powerpc_TARGET_ARCH - | opt_PIC - = return ( ["-fPIC"], ["-fPIC"] ) - | otherwise - = return ( [], [] ) + | opt_PIC + = return ["-fno-common"] + | otherwise + = return ["-mdynamic-no-pic"] +#elif mingw32_TARGET_OS + -- no -fPIC for Windows + = return [] +#else + | opt_PIC + = return ["-fPIC"] + | otherwise + = return [] #endif ----------------------------------------------------------------------------- diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index 6674f14..f2709ad 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -765,6 +765,7 @@ runPhase cc_phase todo dflags basename suff input_fn get_output_fn maybe_loc (cmdline_include_paths ++ pkg_include_dirs) (md_c_flags, md_regd_c_flags) <- machdepCCOpts dflags + pic_c_flags <- picCCOpts dflags let verb = getVerbFlag dflags @@ -795,6 +796,7 @@ runPhase cc_phase todo dflags basename suff input_fn get_output_fn maybe_loc ] ++ map SysTools.Option ( md_c_flags + ++ pic_c_flags ++ (if hcc && mangle then md_regd_c_flags else [])