-- deal with the way flags: the way (eg. prof) gives rise to
-- further flags, some of which might be static.
- way_flags <- findBuildTag
+ way_flags <- getWayFlags
let way_flags' = map (mkGeneralLocated "in way flags") way_flags
-- if we're unregisterised, add some more flags
----- Linker --------------------------------------------------------
, Flag "static" (PassFlag addOpt) Supported
- , Flag "dynamic" (NoArg (removeOpt "-static")) Supported
+ , Flag "dynamic" (NoArg (removeOpt "-static" >> addWay WayDyn)) Supported
-- ignored for compat w/ gcc:
, Flag "rdynamic" (NoArg (return ())) Supported
, Flag "Rghc-timing" (NoArg (enableTimingStats)) Supported
------ Compiler flags -----------------------------------------------
+
+ -- -fPIC requires extra checking: only the NCG supports it.
+ -- See also DynFlags.parseDynamicFlags.
+ , Flag "fPIC" (PassFlag setPIC) Supported
+
-- All other "-fno-<blah>" options cancel out "-f<blah>" on the hsc cmdline
, Flag "fno-"
(PrefixPred (\s -> isStaticFlag ("f"++s)) (\s -> removeOpt ("-f"++s)))
, Flag "f" (AnySuffixPred isStaticFlag addOpt) Supported
]
+setPIC :: String -> IO ()
+setPIC | cGhcWithNativeCodeGen == "YES" || cGhcUnregisterised == "YES"
+ = addOpt
+ | otherwise
+ = ghcError $ CmdLineError "-fPIC is not supported on this platform"
+
isStaticFlag :: String -> Bool
isStaticFlag f =
f `elem` [
"static",
"fhardwire-lib-paths",
"funregisterised",
- "fext-core",
"fcpr-off",
"ferror-spans",
"fPIC",