[swift-users] Building Swift on linux, fails at linking of libswiftCore.so

Dmitri Gribenko gribozavr at gmail.com
Wed Mar 9 16:23:07 CST 2016

On Wed, Mar 9, 2016 at 1:42 PM, Bart Overkamp via swift-users
<swift-users at swift.org> wrote:
> Both the standard linker and the gold one.
> I did:
> $ sudo aptitude install git cmake ninja-build clang python uuid-dev
> libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev
> swig libpython-dev libncurses5-dev pkg-config
> $ git clone https://github.com/apple/swift.git
> $ cd swift
> $ utils/update-checkout --clone
> $ utils/build-script -t -j 1
> and
> $ utils/build-script -t -j 1 -- --use-gold-linker
> both fail
> On Debian/testing
> [500/528] Linking CXX shared library lib/swift/linux/x86_64/libswiftCore.so
> FAILED: : && /usr/bin/clang++  -fPIC -fPIC -fvisibility-inlines-hidden -Wall
> -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor
> -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics
> -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code
> -Woverloaded-virtual -g  -Wl,-z,defs   -target x86_64-unknown-linux-gnu
> -isysroot / -lpthread -ldl
> -L/home/boiert/Pruts/swift/build/Ninja-DebugAssert/swift-linux-x86_64/./lib/swift/linux/x86_64
> -L/home/boiert/Pruts/swift/build/Ninja-DebugAssert/swift-linux-x86_64/./bin/../lib/swift/linux/x86_64
> -L/home/boiert/Pruts/swift/build/Ninja-DebugAssert/swift-linux-x86_64/./bin/../lib/swift/linux
> -shared -Wl,-soname,libswiftCore.so -o
> lib/swift/linux/x86_64/libswiftCore.so lib/swift/linux/x86_64/swift_begin.o
> stdlib/public/core/linux/x86_64/Swift.o lib/swift/linux/x86_64/swift_end.o
> -L/home/boiert/Pruts/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib
> -L/home/boiert/Pruts/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/./lib
> lib/swift/linux/x86_64/libswiftRuntime.a
> lib/swift/linux/x86_64/libswiftStdlibStubs.a -licuuc -licui18n -lbsd
> -Wl,-rpath,"\$ORIGIN:/usr/lib/swift/linux" && :
> /usr/bin/ld: lib/swift/linux/x86_64/libswiftRuntime.a(HeapObject.cpp.o):
> relocation R_X86_64_PC32 against protected symbol `_swift_allocObject' can
> not be used when making a shared object
> /usr/bin/ld: final link failed: Bad value
> Any ideas?

Hi Bart,

If you are running binutils 2.26, this is a known issue.  A workaround
is to use the gold linker (build-script-impl has an option for this).

IIRC there is no issue in the bug tracker, please feel free to file one!

Also, if you are familiar with binutils internals, it might be helpful
to bisect the linker.

Meador Inge has also mentioned this bug:

Right now, it does not seem clear to me that we have an understanding
what the issue is, which component is broken (LLVM, Swift's IRGen, or
binutils), and if the breakage was accidental or intentional (e.g., to
fix something else).

Previous thread on this topic:



(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the swift-users mailing list