Skip to content

Invalid PATH set for `-B` dirs when calling gcc to link

Summary

When -B values are set in -optl, GHC constructs a seemingly invalid PATH from it, using ; instead of : to prepend to the existing PATH.

Steps to reproduce

On a system where all executables needed to run GHC are in /bin:

$ cat Main.hs
module Main where

main = return ()
$ PATH=/bin ghc -optl-B/var/tmp Main
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking Main ...
collect2: fatal error: cannot find 'ld'
compilation terminated.

(strace shows PATH="/var/tmp";/bin being set in the environment).

Expected behavior

Link sample program successfully.

Environment

  • GHC version used: 7.6.3 and 8.4.4

Optional:

  • Operating System: linux
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information