Skip to content

Commit 87efb24

Browse files
wismillmergify[bot]
authored andcommitted
Ensure js-sources are used only with JavaScript arch
1 parent bae536f commit 87efb24

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Cabal/src/Distribution/Simple/GHC.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do
523523
comp = compiler lbi
524524
ghcVersion = compilerVersion comp
525525
implInfo = getImplInfo comp
526-
platform@(Platform _hostArch hostOS) = hostPlatform lbi
526+
platform@(Platform hostArch hostOS) = hostPlatform lbi
527+
hasJsSupport = hostArch == JavaScript
527528
has_code = not (componentIsIndefinite clbi)
528529

529530
relLibTargetDir <- makeRelativeToCurrentDirectory libTargetDir
@@ -567,11 +568,13 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do
567568
, toNubListR (cxxSources libBi)
568569
, toNubListR (cmmSources libBi)
569570
, toNubListR (asmSources libBi)
570-
, toNubListR (jsSources libBi)
571+
, if hasJsSupport
571572
-- JS files are C-like with GHC's JS backend: they are
572573
-- "compiled" into `.o` files (renamed with a header).
573574
-- This is a difference from GHCJS, for which we only
574575
-- pass the JS files at link time.
576+
then toNubListR (jsSources libBi)
577+
else mempty
575578
]
576579
cLikeObjs = map (`replaceExtension` objExtension) cLikeSources
577580
baseOpts = componentGhcOptions verbosity lbi libBi clbi libTargetDir
@@ -730,7 +733,7 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do
730733
| filename <- cSources libBi]
731734

732735
-- build any JS sources
733-
unless (not has_code || null (jsSources libBi)) $ do
736+
unless (not has_code || not hasJsSupport || null (jsSources libBi)) $ do
734737
info verbosity "Building JS Sources..."
735738
sequence_
736739
[ do let vanillaJsOpts = Internal.componentJsGhcOptions verbosity implInfo
@@ -2087,7 +2090,10 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir pkg lib clbi = do
20872090
&& null (cxxSources (libBuildInfo lib))
20882091
&& null (cmmSources (libBuildInfo lib))
20892092
&& null (asmSources (libBuildInfo lib))
2090-
&& null (jsSources (libBuildInfo lib))
2093+
&& (null (jsSources (libBuildInfo lib)) || not hasJsSupport)
2094+
hasJsSupport = case hostPlatform lbi of
2095+
Platform JavaScript _ -> True
2096+
_ -> False
20912097
has_code = not (componentIsIndefinite clbi)
20922098
whenHasCode = when has_code
20932099
whenVanilla = when (hasLib && withVanillaLib lbi)

Cabal/src/Distribution/Simple/Register.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,11 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
466466
|| not (null (asmSources bi))
467467
|| not (null (cmmSources bi))
468468
|| not (null (cxxSources bi))
469-
|| not (null (jsSources bi)))
469+
|| (not (null (jsSources bi)) && hasJsSupport))
470470
&& not (componentIsIndefinite clbi)
471+
hasJsSupport = case hostPlatform lbi of
472+
Platform JavaScript _ -> True
473+
_ -> False
471474
libdirsStatic
472475
| hasLibrary = libdir installDirs : extraLibDirsStaticOrFallback
473476
| otherwise = extraLibDirsStaticOrFallback

0 commit comments

Comments
 (0)