1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +03:00

Do not use custom LDFLAGS for linking mold-wrapper.so

Linking a dynamic library with `-static` would prevent it from being
loadable.

Fixes #191.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
This commit is contained in:
Christoph Erhardt 2021-12-23 10:39:50 +01:00
parent 8c86c28496
commit d858068975
2 changed files with 6 additions and 6 deletions

View File

@ -105,7 +105,7 @@ endif
all: mold mold-wrapper.so
mold: $(OBJS) $(MIMALLOC_LIB) $(TBB_LIB) $(XXHASH_LIB)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) -o $@ $(LIBS)
ln -sf mold ld
ln -sf mold ld64.mold

View File

@ -23,16 +23,16 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
EOF
LDFLAGS='-fuse-ld=lld -static'
EXTRA_LDFLAGS='-fuse-ld=lld -static'
# libstdc++'s `std::__glibcxx_rwlock_rdlock` refers these symbols
# as weak symbols, although they need to be defined. Otherwise,
# the program crashes after juping to address 0.
# So, we force loading symbols as a workaround.
LDFLAGS="$LDFLAGS -Wl,-u,pthread_rwlock_rdlock"
LDFLAGS="$LDFLAGS -Wl,-u,pthread_rwlock_unlock"
LDFLAGS="$LDFLAGS -Wl,-u,pthread_rwlock_wrlock"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-u,pthread_rwlock_rdlock"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-u,pthread_rwlock_unlock"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-u,pthread_rwlock_wrlock"
docker run -it --rm -v "`pwd`:/mold" -u $(id -u):$(id -g) \
mold-build-ubuntu20 \
make -C /mold -j$(nproc) LDFLAGS="$LDFLAGS"
make -C /mold -j$(nproc) EXTRA_LDFLAGS="$EXTRA_LDFLAGS"