Skip to content

Commit

Permalink
combineObjectFiles: Error if the linker does not support -r
Browse files Browse the repository at this point in the history
The `lld` linker (commonly used on Windows) does not support
relocatable output.
  • Loading branch information
erikd committed Oct 4, 2023
1 parent c308b3f commit 6d16c24
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cabal/src/Distribution/Simple/Program/Ld.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Distribution.Simple.Program.Ld
( combineObjectFiles
) where

import qualified Data.Map.Strict as Map

import Distribution.Compat.Prelude
import Prelude ()

Expand Down Expand Up @@ -67,6 +69,12 @@ combineObjectFiles verbosity lbi ld target files = do
-- have a slight problem. What we have to do is link files in batches into
-- a temp object file and then include that one in the next batch.

case Map.lookup "Supports relocatable output" $ programProperties ld of
Just "YES" -> pure ()
Just "NO" -> error $ "combineObjectFiles: Have been asked to combine object " ++
"files but the configured linker does not support relocations."
_other -> pure () -- This may still fail if the compiler does not support -r.

let simpleArgs = ["-r", "-o", target]

initialArgs = ["-r", "-o", target]
Expand Down

0 comments on commit 6d16c24

Please sign in to comment.