Skip to content

Commit

Permalink
vagrant: use LDFLAGS="-Wl,--no-as-needed" in sanitizer runs
Browse files Browse the repository at this point in the history
Since version 10, both gcc and clang started to ignore certain linker errors
when compiling with -fsanitize=address. This eventually leads up to -lcrypt
not being correctly propagated, but the fact is masked by the aforementioned
issue. However, when the binary attempts to load a symbol from the libcrypt
binary, it crashes since it's not linked correctly against it.
Negating the -Wl,--as-needed used by default by -Wl,--no-as-needed seems to
help in this case.

See:
  https://bugzilla.redhat.com/show_bug.cgi?id=1827338#c3
  #247
  • Loading branch information
mrc0mmand committed May 15, 2020
1 parent 4097895 commit 18b7044
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vagrant/bootstrap_scripts/arch-sanitizers-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ export CC=clang
export CXX=clang++
export CFLAGS="-shared-libasan"
export CXXFLAGS="-shared-libasan"
# FIXME
# Since version 10, both gcc and clang started to ignore certain linker errors
# when compiling with -fsanitize=address. This eventually leads up to -lcrypt
# not being correctly propagated, but the fact is masked by the aforementioned
# issue. However, when the binary attempts to load a symbol from the libcrypt
# binary, it crashes since it's not linked correctly against it.
# Negating the -Wl,--as-needed used by default by -Wl,--no-as-needed seems to
# help in this case.
#
# See:
# https://bugzilla.redhat.com/show_bug.cgi?id=1827338#c3
# https://github.com/systemd/systemd-centos-ci/issues/247
export LDFLAGS="-Wl,--no-as-needed"

meson "$BUILD_DIR" \
--werror \
Expand Down
15 changes: 15 additions & 0 deletions vagrant/bootstrap_scripts/arch-sanitizers-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ rm -fr "$BUILD_DIR"
# Build phase
# Compile systemd with the Address Sanitizer (ASan) and Undefined Behavior
# Sanitizer (UBSan)

# FIXME
# Since version 10, both gcc and clang started to ignore certain linker errors
# when compiling with -fsanitize=address. This eventually leads up to -lcrypt
# not being correctly propagated, but the fact is masked by the aforementioned
# issue. However, when the binary attempts to load a symbol from the libcrypt
# binary, it crashes since it's not linked correctly against it.
# Negating the -Wl,--as-needed used by default by -Wl,--no-as-needed seems to
# help in this case.
#
# See:
# https://bugzilla.redhat.com/show_bug.cgi?id=1827338#c3
# https://github.com/systemd/systemd-centos-ci/issues/247
export LDFLAGS="-Wl,--no-as-needed"

meson "$BUILD_DIR" \
--werror \
-Dc_args='-fno-omit-frame-pointer -ftrapv' \
Expand Down

0 comments on commit 18b7044

Please sign in to comment.