Skip to content

Commit 7324966

Browse files
authored
asan,build: fix linker flags for -fsanitize builds (#44420)
Fix #44361 Fix #42540
1 parent 9c1572d commit 7324966

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

.buildkite/pipelines/main/misc/sanitizers.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ steps:
2121
timeout_in_minutes: 120
2222
if: | # We only run the `asan` job on Julia 1.8 and later.
2323
(pipeline.slug != "julia-release-1-dot-6") && (pipeline.slug != "julia-release-1-dot-7")
24-
soft_fail: true # TODO: delete this line (and thus disallow failures) once JuliaLang/julia#42540 is fixed
2524
commands: |
2625
echo "--- Build julia-debug with ASAN"
2726
contrib/asan/build.sh ./tmp/test-asan -j$${JULIA_CPU_THREADS:?} debug

Make.inc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,6 @@ endif
483483
endif
484484

485485
ifeq ($(USEGCC),1)
486-
ifeq ($(SANITIZE),1)
487-
$(error Sanitizers are only supported with clang. Try setting SANITIZE=0)
488-
endif
489486
CC := $(CROSS_COMPILE)gcc
490487
CXX := $(CROSS_COMPILE)g++
491488
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
519516
endif
520517
endif
521518

519+
JLDFLAGS :=
520+
522521
ifeq ($(USECCACHE), 1)
523522
# Expand CC, CXX and FC here already because we want the original definition and not the ccache version.
524523
CC_ARG := $(CC)
@@ -1237,15 +1236,11 @@ IFUNC_DETECT_SRC := 'void (*f0(void))(void) { return (void(*)(void))0L; }; void
12371236
ifeq (supported, $(shell echo $(IFUNC_DETECT_SRC) | $(CC) -Werror -x c - -S -o /dev/null > /dev/null 2>&1 && echo supported))
12381237
JCPPFLAGS += -DJULIA_HAS_IFUNC_SUPPORT=1
12391238
endif
1240-
JLDFLAGS := -Wl,-Bdynamic
1241-
ifneq ($(SANITIZE),1)
1242-
ifneq ($(SANITIZE_MEMORY),1)
1243-
ifneq ($(LLVM_SANITIZE),1)
1239+
JLDFLAGS += -Wl,-Bdynamic
12441240
OSLIBS += -Wl,--version-script=$(JULIAHOME)/src/julia.expmap
1241+
ifneq ($(SANITIZE),1)
12451242
JLDFLAGS += -Wl,-no-undefined
12461243
endif
1247-
endif
1248-
endif
12491244
ifeq (-Bsymbolic-functions, $(shell $(LD) --help | grep -o -e "-Bsymbolic-functions"))
12501245
JLIBLDFLAGS := -Wl,-Bsymbolic-functions
12511246
else
@@ -1258,7 +1253,7 @@ JLIBLDFLAGS :=
12581253
endif
12591254

12601255
ifeq ($(OS), FreeBSD)
1261-
JLDFLAGS := -Wl,-Bdynamic
1256+
JLDFLAGS += -Wl,-Bdynamic
12621257
OSLIBS += -lelf -lkvm -lrt -lpthread -latomic
12631258

12641259
# Tweak order of libgcc_s in DT_NEEDED,
@@ -1276,7 +1271,6 @@ SHLIB_EXT := dylib
12761271
OSLIBS += -framework CoreFoundation
12771272
WHOLE_ARCHIVE := -Xlinker -all_load
12781273
NO_WHOLE_ARCHIVE :=
1279-
JLDFLAGS :=
12801274
HAVE_SSP := 1
12811275
JLIBLDFLAGS := -Wl,-compatibility_version,$(SOMAJOR) -Wl,-current_version,$(JULIA_MAJOR_VERSION).$(JULIA_MINOR_VERSION).$(JULIA_PATCH_VERSION)
12821276
endif
@@ -1285,7 +1279,7 @@ ifeq ($(OS), WINNT)
12851279
HAVE_SSP := 1
12861280
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
12871281
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic
1288-
JLDFLAGS := -Wl,--stack,8388608
1282+
JLDFLAGS += -Wl,--stack,8388608
12891283
ifeq ($(ARCH),i686)
12901284
JLDFLAGS += -Wl,--large-address-aware
12911285
endif

src/julia.expmap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
global:
3-
__asan*;
4-
__tsan*;
53
pthread*;
64
__stack_chk_guard;
75
asprintf;

0 commit comments

Comments
 (0)