From 0f7674e22665e80c5003dc3f0af1d46d814edc9e Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Wed, 17 Apr 2024 11:44:55 -0300 Subject: [PATCH] Fix libasan runpath behaviour. (#54104) This is necessary with LLVM 17 but was extracted to a separate patch xref https://github.com/JuliaLang/julia/pull/53070 --- cli/Makefile | 4 ++-- contrib/asan/Make.user.asan | 1 + contrib/asan/build.sh | 2 +- deps/sanitizers.mk | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/Makefile b/cli/Makefile index 017f713446e1a..6e2696538e216 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -119,7 +119,7 @@ STRIP_EXPORTED_FUNCS := $(shell $(CPP_STDOUT) -I$(JULIAHOME)/src $(SRCDIR)/list_ endif $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS) $(SRCDIR)/list_strip_symbols.h $(BUILDDIR)/julia.expmap | $(build_shlibdir) $(build_libdir) - @$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -shared $(SHIPFLAGS) $(LIB_OBJS) -o $@ \ + @$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -shared $(SHIPFLAGS) $(LIB_OBJS) $(RPATH_LIB) -o $@ \ $(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(VERSIONSCRIPT) $(call SONAME_FLAGS,libjulia.$(JL_MAJOR_SHLIB_EXT))) @$(INSTALL_NAME_CMD)libjulia.$(JL_MAJOR_SHLIB_EXT) $@ @$(DSYMUTIL) $@ @@ -130,7 +130,7 @@ ifeq ($(OS), WINNT) endif $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS) $(SRCDIR)/list_strip_symbols.h $(BUILDDIR)/julia.expmap | $(build_shlibdir) $(build_libdir) - @$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -shared $(DEBUGFLAGS) $(LIB_DOBJS) -o $@ \ + @$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -shared $(DEBUGFLAGS) $(LIB_DOBJS) $(RPATH_LIB) -o $@ \ $(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(VERSIONSCRIPT) $(call SONAME_FLAGS,libjulia-debug.$(JL_MAJOR_SHLIB_EXT))) @$(INSTALL_NAME_CMD)libjulia-debug.$(JL_MAJOR_SHLIB_EXT) $@ @$(DSYMUTIL) $@ diff --git a/contrib/asan/Make.user.asan b/contrib/asan/Make.user.asan index 96ed13b54e0f9..a97631f7c8080 100644 --- a/contrib/asan/Make.user.asan +++ b/contrib/asan/Make.user.asan @@ -6,6 +6,7 @@ TOOLDIR=$(TOOLCHAIN)/usr/tools USECLANG=1 override CC=$(TOOLDIR)/clang override CXX=$(TOOLDIR)/clang++ +override PATCHELF=$(TOOLDIR)/patchelf export ASAN_SYMBOLIZER_PATH=$(TOOLDIR)/llvm-symbolizer USE_BINARYBUILDER_LLVM=1 diff --git a/contrib/asan/build.sh b/contrib/asan/build.sh index 77f3078b35c42..2e7f243772c81 100755 --- a/contrib/asan/build.sh +++ b/contrib/asan/build.sh @@ -40,7 +40,7 @@ if [ ! -d "$TOOLCHAIN" ]; then cp "$HERE/Make.user.tools" "$TOOLCHAIN/Make.user" fi -make -C "$TOOLCHAIN/deps" install-clang install-llvm-tools +make -C "$TOOLCHAIN/deps" install-clang install-llvm-tools install-patchelf echo echo "Building Julia..." diff --git a/deps/sanitizers.mk b/deps/sanitizers.mk index 1a272321c05fa..d5bb6fce5b807 100644 --- a/deps/sanitizers.mk +++ b/deps/sanitizers.mk @@ -14,6 +14,8 @@ define copy_sanitizer_lib install-sanitizers: $$(addprefix $$(build_libdir)/, $$(notdir $$(call pathsearch_all,$(1),$$(SANITIZER_LIB_PATH)))) | $$(build_shlibdir) $$(addprefix $$(build_shlibdir)/,$(2)): $$(addprefix $$(SANITIZER_LIB_PATH)/,$(2)) | $$(build_shlibdir) -cp $$< $$@ + $(if $(filter $(OS), Linux), \ + -$(PATCHELF) $(PATCHELF_SET_RPATH_ARG) '$$$$ORIGIN' $$@ , 0) endef ifeq ($(USECLANG),1)