[libunwind] Fix testing with sanitizers enabled

When testing with sanitizers enabled, we need to link against a plethora
of system libraries. Using `-nodefaultlibs` like we used to breaks this,
and we would have to add all these system libraries manually, which is
not portable and error prone. Instead, stop using `-nodefaultlibs` so
that we get the libraries added by default by the compiler.

The only caveat with this approach is that we are now relying on the
fact that `-L <path-to-local-libunwind>` will cause the just built
libunwind to be selected before the system implementation (either of
libunwind or libgcc_s.so), which is somewhat fragile.

This patch also turns the 32 bit multilib build into a soft failure
since we are in the process of removing it anyway, see D114473 for
details. This patch is incompatible with the 32 bit multilib build
because Ubuntu does not provide a proper libstdc++ for 32 bits, and
that is required when running with sanitizers enabled.

Differential Revision: https://reviews.llvm.org/D114385
This commit is contained in:
Louis Dionne 2021-11-22 14:51:09 -05:00
parent bc41653a1f
commit ebfeeec4c4
12 changed files with 6 additions and 33 deletions

View file

@ -385,6 +385,8 @@ steps:
automatic:
- exit_status: -1 # Agent was lost
limit: 2
soft_fail:
- exit_status: 1
timeout_in_minutes: 120
- label: "Single-threaded"

View file

@ -47,7 +47,7 @@ config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' '.join(compile_flags))
))
config.substitutions.append(('%{link_flags}',
'-nodefaultlibs -L {0} -Wl,-rpath,{0} -lunwind -ldl -lc {1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
'-L {0} -Wl,-rpath,{0} -lunwind -ldl {1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
))
config.substitutions.append(('%{exec}', ''))

View file

@ -49,7 +49,7 @@ config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' '.join(compile_flags))
))
config.substitutions.append(('%{link_flags}',
'-nodefaultlibs {}/libunwind.a -ldl -lc {}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
'{}/libunwind.a -ldl {}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
))
config.substitutions.append(('%{exec}', ''))

View file

@ -9,9 +9,6 @@
// REQUIRES: linux
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
// Basic test for _Unwind_ForcedUnwind.
// See libcxxabi/test/forced_unwind* tests too.

View file

@ -1,6 +1,3 @@
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
// The other libunwind tests don't test internal interfaces, so the include path
// is a little wonky.
#include "../src/config.h"

View file

@ -1,6 +1,3 @@
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
// TODO: Investigate these failures on x86_64 macOS back deployment
// UNSUPPORTED: target=x86_64-apple-darwin{{.+}}

View file

@ -1,6 +1,3 @@
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
#include <assert.h>
#include <stdlib.h>
#include <unwind.h>

View file

@ -2,9 +2,6 @@
# RUN: %{build}
# RUN: %{run}
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
// TODO: Investigate this failure
// XFAIL: 32bits-on-64bits

View file

@ -9,9 +9,6 @@
// Ensure that functions marked as signal frames are reported as such.
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
// TODO: Investigate this failure on macOS
// XFAIL: target={{.+}}-apple-darwin{{.+}}

View file

@ -10,9 +10,6 @@
// Ensure that the unwinder can cope with the signal handler.
// REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
#include <assert.h>
#include <dlfcn.h>
#include <signal.h>

View file

@ -1,6 +1,3 @@
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
#include <assert.h>
#include <libunwind.h>

View file

@ -10,9 +10,6 @@
// Ensure that leaf function can be unwund.
// REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
// TODO: Investigate these failures
// XFAIL: asan, tsan, ubsan
#include <assert.h>
#include <dlfcn.h>
#include <signal.h>
@ -41,10 +38,8 @@ void signal_handler(int signum) {
_Exit(-1);
}
int* faultyPointer = NULL;
__attribute__((noinline)) void crashing_leaf_func(void) {
*faultyPointer = 0;
raise(SIGSEGV);
}
int main(int, char**) {