From 9f24272e04e02601382b73962904da5ed6b89861 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 2 Mar 2022 17:56:37 -0500 Subject: [PATCH] asan,build: fix linker flags for -fsanitize builds Fix #44361 Fix #42540 --- .buildkite/pipelines/main/misc/sanitizers.yml | 1 - Make.inc | 18 ++++++------------ src/julia.expmap | 2 -- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.buildkite/pipelines/main/misc/sanitizers.yml b/.buildkite/pipelines/main/misc/sanitizers.yml index c8ebee340a48e..d5e83fb91cf68 100644 --- a/.buildkite/pipelines/main/misc/sanitizers.yml +++ b/.buildkite/pipelines/main/misc/sanitizers.yml @@ -21,7 +21,6 @@ steps: timeout_in_minutes: 120 if: | # We only run the `asan` job on Julia 1.8 and later. (pipeline.slug != "julia-release-1-dot-6") && (pipeline.slug != "julia-release-1-dot-7") - soft_fail: true # TODO: delete this line (and thus disallow failures) once JuliaLang/julia#42540 is fixed commands: | echo "--- Build julia-debug with ASAN" contrib/asan/build.sh ./tmp/test-asan -j$${JULIA_CPU_THREADS:?} debug diff --git a/Make.inc b/Make.inc index 17d67d379ae7c..0d235eb4f1805 100644 --- a/Make.inc +++ b/Make.inc @@ -483,9 +483,6 @@ endif endif ifeq ($(USEGCC),1) -ifeq ($(SANITIZE),1) -$(error Sanitizers are only supported with clang. Try setting SANITIZE=0) -endif CC := $(CROSS_COMPILE)gcc CXX := $(CROSS_COMPILE)g++ JCFLAGS := -std=gnu99 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 @@ -519,6 +516,8 @@ JCPPFLAGS += -D_LARGEFILE_SOURCE -D_DARWIN_USE_64_BIT_INODE=1 endif endif +JLDFLAGS := + ifeq ($(USECCACHE), 1) # Expand CC, CXX and FC here already because we want the original definition and not the ccache version. CC_ARG := $(CC) @@ -1237,15 +1236,11 @@ IFUNC_DETECT_SRC := 'void (*f0(void))(void) { return (void(*)(void))0L; }; void ifeq (supported, $(shell echo $(IFUNC_DETECT_SRC) | $(CC) -Werror -x c - -S -o /dev/null > /dev/null 2>&1 && echo supported)) JCPPFLAGS += -DJULIA_HAS_IFUNC_SUPPORT=1 endif -JLDFLAGS := -Wl,-Bdynamic -ifneq ($(SANITIZE),1) -ifneq ($(SANITIZE_MEMORY),1) -ifneq ($(LLVM_SANITIZE),1) +JLDFLAGS += -Wl,-Bdynamic OSLIBS += -Wl,--version-script=$(JULIAHOME)/src/julia.expmap +ifneq ($(SANITIZE),1) JLDFLAGS += -Wl,-no-undefined endif -endif -endif ifeq (-Bsymbolic-functions, $(shell $(LD) --help | grep -o -e "-Bsymbolic-functions")) JLIBLDFLAGS := -Wl,-Bsymbolic-functions else @@ -1258,7 +1253,7 @@ JLIBLDFLAGS := endif ifeq ($(OS), FreeBSD) -JLDFLAGS := -Wl,-Bdynamic +JLDFLAGS += -Wl,-Bdynamic OSLIBS += -lelf -lkvm -lrt -lpthread -latomic # Tweak order of libgcc_s in DT_NEEDED, @@ -1276,7 +1271,6 @@ SHLIB_EXT := dylib OSLIBS += -framework CoreFoundation WHOLE_ARCHIVE := -Xlinker -all_load NO_WHOLE_ARCHIVE := -JLDFLAGS := HAVE_SSP := 1 JLIBLDFLAGS := -Wl,-compatibility_version,$(SOMAJOR) -Wl,-current_version,$(JULIA_MAJOR_VERSION).$(JULIA_MINOR_VERSION).$(JULIA_PATCH_VERSION) endif @@ -1285,7 +1279,7 @@ ifeq ($(OS), WINNT) HAVE_SSP := 1 OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \ $(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -JLDFLAGS := -Wl,--stack,8388608 +JLDFLAGS += -Wl,--stack,8388608 ifeq ($(ARCH),i686) JLDFLAGS += -Wl,--large-address-aware endif diff --git a/src/julia.expmap b/src/julia.expmap index 27c1b604244df..13de1b873f7c3 100644 --- a/src/julia.expmap +++ b/src/julia.expmap @@ -1,7 +1,5 @@ { global: - __asan*; - __tsan*; pthread*; __stack_chk_guard; asprintf;