diff --git a/Cabal/src/Distribution/Simple/GHC/Build.hs b/Cabal/src/Distribution/Simple/GHC/Build.hs index d4cff2e80c4..d31b8e2b608 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build.hs @@ -49,6 +49,12 @@ rapidly reach this limit, in part, due to the long length of cabal v2 prefixes. To minimize the likelihood, we use `makeRelativeToCurrentDirectory` to shorten the paths used in invocations (see da6321bb). + +However, in executables, we don't do this. It seems that we don't need to do it +for executable-like components because the linking step, instead of passing as +an argument the path to each module, it simply passes the module name, the sources dir, and --make. +RM: I believe we can use --make + module names instead of paths-to-objects +for linking libraries too (2024-01) (TODO) -} -- | The main build phase of building a component. @@ -80,8 +86,11 @@ build numJobs pkg_descr = do liftIO do createDirectoryIfMissingVerbose verbosity True targetDir_absolute createDirectoryIfMissingVerbose verbosity True buildTargetDir_absolute + + -- See Note [Build Target Dir vs Target Dir] as well targetDir <- makeRelativeToCurrentDirectory targetDir_absolute & liftIO - buildTargetDir <- makeRelativeToCurrentDirectory buildTargetDir_absolute & liftIO + buildTargetDir <- if isLib then makeRelativeToCurrentDirectory buildTargetDir_absolute & liftIO + else return buildTargetDir_absolute (ghcProg, _) <- requireProgram verbosity ghcProgram (withPrograms lbi) & liftIO diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index 853cbb02fd4..8cfe7b30c06 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -88,6 +88,7 @@ linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir) ( PD.ldOptions bi ++ [ "-static" | withFullyStaticExe lbi -- ROMES:TODO: wb withStaticLib?? + -- ROMES:TODO: wouldn't this be best handled by re-using the build opt for the way being linked? ] -- Pass extra `ld-options` given -- through to GHC's linker.