Skip to content

ld -l:filename.dylib does not appear to be portable

In GHCi, we seem to use -l: to ask the linker to link a specific filename, instead of munging the filename. Unfortunately, this does not appear to be universally supported by all versions of ld. Here is the manpage ld that comes with Mac OS X 10.10.1:

   Options that control libraries
     -lx         This option tells the linker to search for libx.dylib or libx.a in
                 the library search path.  If string x is of the form y.o, then that
                 file is searched for in the same places, but without prepending
                 `lib' or appending `.a' or `.dylib' to the filename.

It causes T2276_ghci, prog003, T8696 and ghci058 to fail:

--- /dev/null   2014-12-09 20:57:29.000000000 -0500
+++ ./T2276_ghci.run.stderr     2014-12-09 20:57:30.000000000 -0500
@@ -0,0 +1,3 @@
+ld: library not found for -l:ghc75404_1.dylib
+clang: error: linker command failed with exit code 1 (use -v to see invocation)
+phase `Linker' failed (exitcode = 1)
*** unexpected failure for T2276_ghci(ghci

Regression seems to have been introduced by:

commit 383733b9191a36e2d3f757700842dbc3855911d9
Author: Peter Trommler <ptrommler@acm.org>
Date:   Sun Nov 30 12:00:39 2014 -0600

    Fix obscure problem with using the system linker (#8935)

Probably we can fix it by not using colon and making sure the libraries we generate have the right file format.

Edited by Edward Z. Yang
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information