Open Bug 1538724 Opened 7 years ago Updated 3 years ago

warn lld not supported on macOS when running configure

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: jwatt, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug)

Given that lld is supposed to provide a decent build time perf boost it would be nice to be able to use it on macOS. I gave it a try, first by adding the following to my .mozconfig:

export LDFLAGS=-fuse-ld=lld

which resulted in the error:

 0:20.86 configure: error: compiler is incompatible with sanitize options
 0:20.86 DEBUG: <truncated - see config.log for full output>
 0:20.86 DEBUG: configure: failed program was:
 0:20.86 DEBUG: #line 2791 "configure"
 0:20.86 DEBUG: #include "confdefs.h"
 0:20.86 DEBUG:
 0:20.86 DEBUG: int main() {
 0:20.86 DEBUG: XtMalloc()
 0:20.86 DEBUG: ; return 0; }
 0:20.86 DEBUG: configure:4078: /Users/jwatt/.cargo/bin/sccache /usr/local/Cellar/llvm/8.0.0/bin/clang -isysroot /Users/jwatt/Applications-archive/SDKs/MacOSX10.13.sdk/ -std=gnu99 -o conftest  -Qunused-arguments  -fuse-ld=lld -Wl,-syslibroot,/Users/jwatt/Applications-archive/SDKs/MacOSX10.13.sdk/ conftest.c  1>&5
 0:20.86 DEBUG: ld64.lld: warning: ignoring unknown argument: -no_deduplicate
 0:20.86 DEBUG: ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
 0:20.86 DEBUG: ld64.lld: error: Unable to find library for -lSystem
 0:20.86 DEBUG: clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
 0:20.86 DEBUG: configure: failed program was:
 0:20.86 DEBUG: #line 4071 "configure"
 0:20.86 DEBUG: #include "confdefs.h"
 0:20.86 DEBUG:
 0:20.86 DEBUG: int main() {
 0:20.86 DEBUG:
 0:20.86 DEBUG: ; return 0; }
 0:20.86 DEBUG: configure: error: compiler is incompatible with sanitize options
 0:20.86 ERROR: old-configure failed
 0:20.92 *** Fix above errors and then restart with               "./mach build"
 0:20.92 make: *** [configure] Error 1

I then tried adding the following instead:

ac_add_options --enable-linker=lld

which resulted in the error:

 0:03.91 DEBUG: Executing: `/Users/jwatt/.cargo/bin/sccache /usr/local/Cellar/llvm/8.0.0/bin/clang -isysroot /Users/jwatt/Applications-archive/SDKs/MacOSX10.13.sdk/ -std=gnu99 -fuse-ld=lld -Wl,--version`
 0:03.91 ERROR: Could not use lld as linker
 0:03.97 *** Fix above errors and then restart with               "./mach build"
 0:03.97 make: *** [configure] Error 1

One issue seems to be that lld on macOS only accepts -v and not --version like the Linux version.

The linker command that the clang command that the configure script runs seems to be something like:

"/usr/local/Cellar/llvm/8.0.0/bin/ld64.lld" -demangle -lto_library /usr/local/Cellar/llvm/8.0.0/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.14.0 -o a.out -v -lSystem /usr/local/Cellar/llvm/8.0.0/lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a

which prints out the following and exits with a non-zero result, presumably:

Library search paths:
    /usr/lib
    /usr/local/lib
Framework search paths:
    /Library/Frameworks
    /System/Library/Frameworks
ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Undefined symbol: C entry: _main
symbol(s) not found

I should say that this is with Homebrew installed llvm 8.0.

LLD on OS X appears to be non-functional:

http://lists.llvm.org/pipermail/cfe-dev/2019-March/061666.html

I guess configure should explicitly tell you this if you're trying to use LLD on OS X.

I was about to resolve this wontfix and mid-aired with Nathan. I suppose we can keep this bug open to use as a configure warning.

But yeah, lld is pretty much a separate program for each platform, and the mac one is unmaintained and out of date (it predates the rewrite that gave us the current ELF and COFF linkers).

Also I'm told that ld64 is decent at linking, so the perf boost of lld wouldn't be that great.

Priority: -- → P3
Summary: Support lld on macOS → warn lld not supported on macOS when running configure
Keywords: good-first-bug

NB: work has started on creating a new, functional, macos (macho) backend for lld, although it probably won't be production ready for a while. https://reviews.llvm.org/rG03f43b3aca3

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.