Skip to content

Commit

Permalink
asan,build: fix linker flags for -fsanitize builds (#44420)
Browse files Browse the repository at this point in the history
Fix #44361
Fix #42540

(cherry picked from commit 7324966)
  • Loading branch information
vtjnash authored and KristofferC committed Mar 4, 2022
1 parent 5bb9e64 commit b2dd618
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
1 change: 0 additions & 1 deletion .buildkite/pipelines/main/misc/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 6 additions & 12 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -1256,7 +1251,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,
Expand All @@ -1274,7 +1269,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
Expand All @@ -1283,7 +1277,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
Expand Down
2 changes: 0 additions & 2 deletions src/julia.expmap
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
global:
__asan*;
__tsan*;
pthread*;
__stack_chk_guard;
asprintf;
Expand Down

0 comments on commit b2dd618

Please sign in to comment.