Skip to content

Commit d1fab72

Browse files
committed
build: work correctly when linking to a system llvm which is not the default
It's erroneous to assume hardcoded -lLLVM works, when it will either not exist, or exist and be a symlink to -lLLVM-6.0, or exist and be a symlink to a completely invalid -lLLVM-7 Instead, use llvm-config for what it's meant to do, and acquire the linker --libs. In one case this means we can simplify on --libfiles rather than --libdir plus appending some hardcoded strings, and in another case we can simply drop a huge, confusingly repetitive invocation which was meant to work around very old llvm versions that are no longer supported.
1 parent ebfbe62 commit d1fab72

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

base/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ endif # WINNT
199199

200200
symlink_libLLVM: $(build_private_libdir)/libLLVM.dylib
201201
$(build_private_libdir)/libLLVM.dylib:
202-
REALPATH=`$(LLVM_CONFIG_HOST) --libdir`/libLLVM.$(SHLIB_EXT) && \
202+
REALPATH=`$(LLVM_CONFIG_HOST) --libfiles` && \
203203
$(call resolve_path,REALPATH) && \
204204
[ -e "$$REALPATH" ] && \
205205
([ ! -e "$@" ] || rm "$@") && \

src/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,8 @@ endif
8989
PUBLIC_HEADER_TARGETS := $(addprefix $(build_includedir)/julia/,$(notdir $(PUBLIC_HEADERS)) $(UV_HEADERS))
9090

9191
ifeq ($(JULIACODEGEN),LLVM)
92-
# In LLVM < 3.4, --ldflags includes both options and libraries, so use it both before and after --libs
93-
# In LLVM >= 3.4, --ldflags has only options, and --system-libs has the libraries.
94-
ifneq ($(USE_LLVM_SHLIB),1)
95-
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags) $(shell $(LLVM_CONFIG_HOST) --libs $(LLVM_LIBS)) $(shell $(LLVM_CONFIG_HOST) --ldflags) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null)
96-
else
97-
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags) -lLLVM
92+
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags --libs --system-libs)
93+
ifeq ($(USE_LLVM_SHLIB),1)
9894
FLAGS += -DLLVM_SHLIB
9995
endif # USE_LLVM_SHLIB == 1
10096
endif

0 commit comments

Comments
 (0)