Skip to content
Snippets Groups Projects
Commit 01684c08 authored by Cheng Shao's avatar Cheng Shao :beach: Committed by Zubin
Browse files

compiler: fix checkNonStdWay for targets that require dynamic libraries

This commit fixes checkNonStdWay to ensure that for targets whose RTS
linker can only load dynamic code, the dynamic way of object is
selected.

(cherry picked from commit 94ef949e)
(cherry picked from commit 38474be0)
parent 46f944be
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,7 @@ import System.Directory
data LinkDepsOpts = LinkDepsOpts
{ ldObjSuffix :: !String -- ^ Suffix of .o files
, ldForceDyn :: !Bool -- ^ Always use .dyn_o?
, ldOneShotMode :: !Bool -- ^ Is the driver in one-shot mode?
, ldModuleGraph :: !ModuleGraph
, ldUnitEnv :: !UnitEnv
......@@ -351,6 +352,16 @@ throwProgramError opts doc = throwGhcExceptionIO (ProgramError (renderWithContex
checkNonStdWay :: LinkDepsOpts -> Interp -> SrcSpan -> IO (Maybe FilePath)
checkNonStdWay _opts interp _srcspan
-- On some targets (e.g. wasm) the RTS linker only supports loading
-- dynamic code, in which case we need to ensure the .dyn_o object
-- is picked (instead of .o which is also present because of
-- -dynamic-too)
| ldForceDyn _opts = do
let target_ways = fullWays $ ldWays _opts
pure $ if target_ways `hasWay` WayDyn
then Nothing
else Just $ waysTag (WayDyn `addWay` target_ways) ++ "_o"
| ExternalInterp {} <- interpInstance interp = return Nothing
-- with -fexternal-interpreter we load the .o files, whatever way
-- they were built. If they were built for a non-std way, then
......
......@@ -639,6 +639,7 @@ initLinkDepsOpts hsc_env = opts
where
opts = LinkDepsOpts
{ ldObjSuffix = objectSuf dflags
, ldForceDyn = sTargetRTSLinkerOnlySupportsSharedLibs $ settings dflags
, ldOneShotMode = isOneShot (ghcMode dflags)
, ldModuleGraph = hsc_mod_graph hsc_env
, ldUnitEnv = hsc_unit_env hsc_env
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment