Skip to content

Commit 370886c

Browse files
maleadttkelman
authored andcommitted
LLVM 3.9+: enable the NVPTX LLVM back-end, and add patches fixing bugs. (#19323)
Use of the NVPTX back-end is only tested on LLVM 3.9, in combination with the CUDAnative.jl package.
1 parent 387e964 commit 370886c

File tree

4 files changed

+1412
-3
lines changed

4 files changed

+1412
-3
lines changed

deps/llvm.mk

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,22 @@ LLVM_LIBCXX_TAR:=$(SRCDIR)/srccache/libcxx-$(LLVM_TAR_EXT)
7373
endif
7474
endif # LLVM_VER != svn
7575

76+
# Figure out which targets to build
77+
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7 3.8))
78+
LLVM_TARGETS := host
79+
else
80+
LLVM_TARGETS := host;NVPTX
81+
endif
82+
7683
# Allow adding LLVM specific flags
7784
LLVM_CFLAGS += $(CFLAGS)
7885
LLVM_CXXFLAGS += $(CXXFLAGS)
7986
LLVM_CPPFLAGS += $(CPPFLAGS)
8087
LLVM_LDFLAGS += $(LDFLAGS)
81-
LLVM_TARGETS := host
82-
LLVM_TARGET_FLAGS := --enable-targets=$(LLVM_TARGETS)
8388
LLVM_CMAKE += -DLLVM_TARGETS_TO_BUILD:STRING="$(LLVM_TARGETS)" -DCMAKE_BUILD_TYPE="$(LLVM_CMAKE_BUILDTYPE)"
8489
LLVM_CMAKE += -DLLVM_TOOLS_INSTALL_DIR=$(shell $(JULIAHOME)/contrib/relative_path.sh $(build_prefix) $(build_depsbindir))
8590
LLVM_CMAKE += -DLLVM_BINDINGS_LIST="" -DLLVM_INCLUDE_DOCS=Off -DLLVM_ENABLE_TERMINFO=Off -DHAVE_HISTEDIT_H=Off -DHAVE_LIBEDIT=Off
86-
LLVM_FLAGS += --disable-profiling --enable-static $(LLVM_TARGET_FLAGS)
91+
LLVM_FLAGS += --disable-profiling --enable-static --enable-targets=$(LLVM_TARGETS)
8792
LLVM_FLAGS += --disable-bindings --disable-docs --disable-libedit --disable-terminfo
8893
# LLVM has weird install prefixes (see llvm-$(LLVM_VER)/build_$(LLVM_BUILDTYPE)/Makefile.config for the full list)
8994
# We map them here to the "normal" ones, which means just prefixing "PROJ_" to the variable name.
@@ -491,6 +496,10 @@ $(eval $(call LLVM_PATCH,llvm-3.9.0_win64-reloc-dwarf))
491496
$(eval $(call LLVM_PATCH,llvm-3.9.0_D27296-libssp))
492497
$(eval $(call LLVM_PATCH,llvm-D27609-AArch64-UABS_G3))
493498
$(eval $(call LLVM_PATCH,llvm-D27629-AArch64-large_model))
499+
# patches for NVPTX
500+
$(eval $(call LLVM_PATCH,llvm-D9168_argument_alignment)) # Remove for 4.0
501+
$(eval $(call LLVM_PATCH,llvm-D23597_sdag_names)) # Dep for D24300, remove for 4.0
502+
$(eval $(call LLVM_PATCH,llvm-D24300_ptx_intrinsics)) # Remove for 4.0
494503
endif # LLVM_VER
495504

496505
ifeq ($(LLVM_VER),3.7.1)

0 commit comments

Comments
 (0)