ldc-developers / ldc

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

Can't build 1.0.0 with cmake #1544

Closed mihails-strasuns closed 8 years ago

mihails-strasuns commented 8 years ago

Trying to use my usual build script which looks like this:

    cd $srcdir/ldc

    git submodule update --init --recursive

    mkdir -p build && cd build
    cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_SKIP_RPATH=ON \
    -DINCLUDE_INSTALL_DIR=/usr/include/dlang/ldc \
    -DBUILD_SHARED_LIBS=ON \
    ..
    make -j 4

LDC does build bunch of files just fine but whenever it gets to linking, this error shows up:

/usr/bin/ld: unrecognized option '-Wl,-O1,--sort-common,--as-needed,-z,relro'

Arch Linux x86_64 (ld 2.26.0 , cmake 3.5.2)

yannick commented 8 years ago

hmm, for me it works, at least for the static PKGBUILD i have and also for ldc-git, @Dicebot checkout a possible fix in: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ldc-git

JohanEngelen commented 8 years ago

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ldc-git

Perhaps with -DCMAKE_EXE_LINKER_FLAGS='-static-libstdc++ -Wl,-rpath,\$ORIGIN' \ you override the default linker flags that contain stuff that our build script / the D compiler doesn't like?

Kozzi11 commented 8 years ago

Problem is with Archlinux /etc/makepkg.conf it defines:

LDFLAGS="-Wl,O1,--sort-common,--as-needed,-z,relro"

which does not work with ldmd.

One workaround is to use this in PKGBUILD before cmake

export LDFLAGS="-L-O1 -L--sort-common -L--as-needed -L-z -Lrelro"
Kozzi11 commented 8 years ago

But you still need to uninstall ldc first and use dmd to build ldc 1.0.0. Because there is a some ABI(different mangling symbol) issue with ldc 0.17.1. And after thatr you can use ldc 1.0.0 tu rebuild itself

wilzbach commented 8 years ago

Related to #1530

dnadlinger commented 8 years ago

We could of course add another special case to the CMake script that properly splits up such flags, but what we should really do is to add something like a -linker-driver-arg=… command line switch similar to -L that does not prepend -Xlinker. We can just forward the flags from llvm-config, pkg-config, CMAKE_EXE_LINKER_FLAGS (which is the issue here) and so on then. Everything else seems very brittle.

mihails-strasuns commented 8 years ago

Thanks for hints/explanation. I will go with export workaround for now, updated package should propagate to mirrors in few hours.

dnadlinger commented 8 years ago

@Dicebot: It would be great if you could give master a quick try on Arch without the LDFLAGS workaround to see whether there are any remaining issues. The fix should be part of 1.1.0-beta2 otherwise.

kinke commented 8 years ago

I assume this is fixed by now. Feel free to reopen if it still doesn't work.

mihails-strasuns commented 8 years ago

Correct, works for me on master.