ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.22k stars 262 forks source link

ldc 1.5.0-beta1: Build failures with LTO for phobos/druntime on OS X #2379

Closed jondegenhardt closed 7 years ago

jondegenhardt commented 7 years ago

Getting link failures when trying to use ldc-build-runtime to build phobos/druntime with LTO on OS X. Setup:

Test program:

void main(string[] args)
{
    import std.stdio;
    writeln("Hello World!");
}

ldc-build-runtime command:

$ ldc-build-runtime --reset --dFlags="-flto=full;-ar" BUILD_SHARED_LIBS=OFF RT_ARCHIVE_WITH_LDC=OFF

Compilation:

$ ldc2 -flto=full -L-L./ldc-build-runtime.tmp/lib helloworld.d

The ldc-build-command succeeds, but the compilation fails. The compilation failure:

undef: __d_eh_personality
undef: __d_run_main
undef: __d_dso_registry
... [snip] ...
Undefined symbols for architecture x86_64:
  "__d_eh_personality", referenced from:
      Dwarf Exception Unwind Info (__eh_frame) in lto.o
  "__d_run_main", referenced from:
      _main in lto.o
... [snip] ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /usr/bin/gcc failed with status: 1
kinke commented 7 years ago

--dFlags="-flto=full;-ar"

-ar=. The way you wrote it, the next arg would be used as archiver. It needs to be explicitly set to an empty arg to enforce the LLVM archiver.

kinke commented 7 years ago

Oh but you're disabling the internal archiver via RT_ARCHIVE_WITH_LDC=OFF. You need to settle for one archiver. ;) - See issue #2350 for more context.

jondegenhardt commented 7 years ago

That worked, thanks! Specifically:

$ ldc-build-runtime --reset --dFlags="-flto=full;-ar=" BUILD_SHARED_LIBS=OFF
$ ldc2 -flto=full -L-L./ldc-build-runtime.tmp/lib helloworld.d

I'll try with my full programs rather than the simple helloworld.d. If that succeeds I'll close the issue.

kinke commented 7 years ago

Alright, so the internal archiver really seems to be working with Xcode 9.0.1 again, only Xcode 9.0.0 showing that bug. @JohanEngelen: should we get rid of the workaround so that LTO (and cross-archiving to OSX) works out of the box again? Does Xcode update itself by default?

jondegenhardt commented 7 years ago

My other programs look good. Thanks much the help. As to Xcode updates - The app store prompts you to update. You aren't required to update, but it does make it annoying not to.

kinke commented 7 years ago

Thanks Jon for testing; looking forward to your updated benchmark numbers. :)

So I guess we can safely bury the workaround.

kinke commented 7 years ago

@JohanEngelen, @klickverbot: Okay to get rid of the workaround and mention the 9.0.1 requirement it in the release notes instead?

JohanEngelen commented 7 years ago

Yes, let's remove the workaround. (we can mention that one shouldn't use xcode 9.0.0 in the release notes, but not really necessary i think)