From 1cdf6bf336be8554f44feb5288d57e53bc9ce161 Mon Sep 17 00:00:00 2001 From: stahta01 Date: Mon, 13 Feb 2023 04:20:56 -0500 Subject: [PATCH] don't use hardcode `LLVM_SHARED_LIB_NAME` (#45908) (#48560) Hand edited changes to deps/llvm.version and deps/Versions.make Moved LLVM_VER from Versions.make to llvm.version by Tim S. (cherry picked from commit eb72c2aaf2a7f651e7bd1ad6c3ac2dbe0f7b79e7) Co-authored-by: woclass --- Makefile | 4 +++- deps/Versions.make | 1 - deps/llvm-ver.make | 7 +++++++ deps/llvm.mk | 8 ++++---- deps/llvm.version | 2 ++ src/Makefile | 15 ++++++++++----- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 94df626014059..2c6524be3a58a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ JULIAHOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) include $(JULIAHOME)/Make.inc +# import LLVM_SHARED_LIB_NAME +include $(JULIAHOME)/deps/llvm-ver.make VERSDIR := v`cut -d. -f1-2 < $(JULIAHOME)/VERSION` @@ -190,7 +192,7 @@ else JL_PRIVATE_LIBS-$(USE_SYSTEM_ZLIB) += libz endif ifeq ($(USE_LLVM_SHLIB),1) -JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-13jl +JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM $(LLVM_SHARED_LIB_NAME) endif JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind diff --git a/deps/Versions.make b/deps/Versions.make index f507b3c9fba32..d24450cd01336 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -44,7 +44,6 @@ LIBUV_VER := 2 LIBUV_JLL_NAME := LibUV # LLVM -LLVM_VER := 13.0.1 LLVM_ASSERT_JLL_VER := 13.0.1+3 LLVM_JLL_NAME := libLLVM diff --git a/deps/llvm-ver.make b/deps/llvm-ver.make index c2c7f2bc56da7..3c498be6c2363 100644 --- a/deps/llvm-ver.make +++ b/deps/llvm-ver.make @@ -1,3 +1,5 @@ +include $(JULIAHOME)/deps/llvm.version + LLVM_VER_MAJ:=$(word 1, $(subst ., ,$(LLVM_VER))) LLVM_VER_MIN:=$(word 2, $(subst ., ,$(LLVM_VER))) # define a "short" LLVM version for easy comparisons @@ -10,3 +12,8 @@ LLVM_VER_PATCH:=$(word 3, $(subst ., ,$(LLVM_VER))) ifeq ($(LLVM_VER_PATCH),) LLVM_VER_PATCH := 0 endif + +LLVM_SHARED_LIB_VER_SUFFIX := $(LLVM_VER_MAJ)jl +# e.g.: "libLLVM-14jl" +LLVM_SHARED_LIB_NAME := libLLVM-$(LLVM_SHARED_LIB_VER_SUFFIX) +LLVM_SHARED_LINK_FLAG := -lLLVM-$(LLVM_SHARED_LIB_VER_SUFFIX) diff --git a/deps/llvm.mk b/deps/llvm.mk index 7c4c2d60dfd9a..61210728e6ffb 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -198,7 +198,7 @@ LLVM_CMAKE += -DCMAKE_EXE_LINKER_FLAGS="$(LLVM_LDFLAGS)" \ -DCMAKE_SHARED_LINKER_FLAGS="$(LLVM_LDFLAGS)" # change the SONAME of Julia's private LLVM -# i.e. libLLVM-6.0jl.so +# i.e. libLLVM-14jl.so # see #32462 LLVM_CMAKE += -DLLVM_VERSION_SUFFIX:STRING="jl" LLVM_CMAKE += -DLLVM_SHLIB_SYMBOL_VERSION:STRING="JL_LLVM_$(LLVM_VER_SHORT)" @@ -255,10 +255,10 @@ endif LLVM_INSTALL = \ cd $1 && mkdir -p $2$$(build_depsbindir) && \ - cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \ - $$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake + cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \ + $$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake ifeq ($(OS), WINNT) -LLVM_INSTALL += && cp $2$$(build_shlibdir)/libLLVM.dll $2$$(build_depsbindir) +LLVM_INSTALL += && cp $2$$(build_shlibdir)/$(LLVM_SHARED_LIB_NAME).dll $2$$(build_depsbindir) endif ifeq ($(OS),Darwin) # https://github.com/JuliaLang/julia/issues/29981 diff --git a/deps/llvm.version b/deps/llvm.version index e55705dc61da4..c196e6f6028b6 100644 --- a/deps/llvm.version +++ b/deps/llvm.version @@ -1,2 +1,4 @@ +## source build +LLVM_VER := 13.0.1 LLVM_BRANCH=julia-13.0.1-3 LLVM_SHA1=julia-13.0.1-3 diff --git a/src/Makefile b/src/Makefile index 8ef266c8e42d3..424d4a9941ed8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -122,24 +122,29 @@ endif ifeq ($(JULIACODEGEN),LLVM) ifneq ($(USE_SYSTEM_LLVM),0) +# USE_SYSTEM_LLVM != 0 CG_LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs --system-libs) # HACK: llvm-config doesn't correctly point to shared libs on all platforms # https://github.com/JuliaLang/julia/issues/29981 else +# USE_SYSTEM_LLVM == 0 ifneq ($(USE_LLVM_SHLIB),1) +# USE_LLVM_SHLIB != 1 CG_LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs $(CG_LLVM_LIBS) --link-static) $($(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null) else +# USE_LLVM_SHLIB == 1 ifeq ($(OS), Darwin) CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM else -CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-13jl -endif -endif -endif +CG_LLVMLINK += $(LLVM_LDFLAGS) $(LLVM_SHARED_LINK_FLAG) +endif # OS +endif # USE_LLVM_SHLIB +endif # USE_SYSTEM_LLVM + ifeq ($(USE_LLVM_SHLIB),1) FLAGS += -DLLVM_SHLIB endif # USE_LLVM_SHLIB == 1 -endif +endif # JULIACODEGEN == LLVM RT_LLVM_LINK_ARGS := $(shell $(LLVM_CONFIG_HOST) --libs $(RT_LLVM_LIBS) --system-libs --link-static) RT_LLVMLINK += $(LLVM_LDFLAGS) $(RT_LLVM_LINK_ARGS)