Skip to content

Commit

Permalink
Misc LLVM cleanup (JuliaLang#22412)
Browse files Browse the repository at this point in the history
* Misc LLVM cleanup

Some additional typos
Add pass pass options for running julia -O0 and -O2
Delete LLVM patches from older versions

* More cleanup

* Fix one more instance of LLVM_USE_CMAKE

* Remove another few LLVM_USE_CMAKE mentions
  • Loading branch information
Keno authored and tkelman committed Jun 18, 2017
1 parent 560bc84 commit e9f2072
Show file tree
Hide file tree
Showing 42 changed files with 21 additions and 4,850 deletions.
1 change: 0 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ INSTALL_M := $(JULIAHOME)/contrib/install.sh 755
LLVMROOT := $(build_prefix)
LLVM_ASSERTIONS := 0
LLVM_DEBUG := 0
#LLVM_USE_CMAKE: defined in deps/llvm-ver.mk as it depends on LLVM_VER_SHORT
# set to 1 to get clang and compiler-rt
BUILD_LLVM_CLANG := 0
# set to 1 to get lldb (often does not work, no chance with llvm3.2 and earlier)
Expand Down
6 changes: 0 additions & 6 deletions deps/llvm-ver.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ LLVM_VER_PATCH:=$(word 3, $(subst ., ,$(LLVM_VER)))
ifeq ($(LLVM_VER_PATCH),)
LLVM_VER_PATCH := 0
endif

ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
LLVM_USE_CMAKE := 0
else
LLVM_USE_CMAKE := 1
endif
126 changes: 2 additions & 124 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ endif
include $(SRCDIR)/llvm-options.mk
LLVM_LIB_FILE := libLLVMCodeGen.a

ifeq ($(LLVM_VER), 3.3)
LLVM_TAR_EXT:=$(LLVM_VER).src.tar.gz
else
LLVM_TAR_EXT:=$(LLVM_VER).src.tar.xz
endif # LLVM_VER == 3.3

ifneq ($(LLVM_VER),svn)
LLVM_TAR:=$(SRCDIR)/srccache/llvm-$(LLVM_TAR_EXT)
Expand All @@ -54,11 +50,7 @@ endif
endif # LLVM_VER != svn

# Figure out which targets to build
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7 3.8))
LLVM_TARGETS := host
else
LLVM_TARGETS := host;NVPTX
endif

LLVM_CFLAGS :=
LLVM_CXXFLAGS :=
Expand Down Expand Up @@ -115,10 +107,6 @@ ifeq ($(USE_LLVM_SHLIB),1)
# against libLLVM) but there doesn't seem to be a CMake counterpart option
LLVM_FLAGS += --enable-shared
LLVM_CMAKE += -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON -DLLVM_LINK_LLVM_DYLIB:BOOL=ON
# NOTE: starting with LLVM 3.8, all symbols are exported
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
LLVM_CMAKE += -DLLVM_DYLIB_EXPORT_ALL:BOOL=ON
endif
endif
ifeq ($(USE_INTEL_JITEVENTS), 1)
LLVM_FLAGS += --with-intel-jitevents
Expand Down Expand Up @@ -156,22 +144,7 @@ ifneq (,$(filter $(ARCH), powerpc64le ppc64le))
LLVM_CXXFLAGS += -mminimal-toc
endif

# LLVM bug #24157
ifeq ($(USE_LLVM_SHLIB),1)
ifeq ($(LLVM_USE_CMAKE),1)
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
$(error USE_LLVM_SHLIB=1 with LLVM_USE_CMAKE=1 requires LLVM > 3.7.x)
endif
endif
endif

ifeq ($(LLVM_SANITIZE),1)
# autotools doesn't provide a sanitation build mode (linking libLLVM will fail)
ifeq ($(USE_LLVM_SHLIB),1)
ifeq ($(LLVM_USE_CMAKE),0)
$(error LLVM_SANITIZE=1 with USE_LLVM_SHLIB=1 requires LLVM_USE_CMAKE=1)
endif
endif
ifeq ($(SANITIZE_MEMORY),1)
LLVM_CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins
LLVM_LDFLAGS += -fsanitize=memory -fsanitize-memory-track-origins
Expand Down Expand Up @@ -230,25 +203,16 @@ LLVM_MFLAGS += OPTIONAL_PARALLEL_DIRS=clang
else
# block default building of Clang
LLVM_MFLAGS += OPTIONAL_PARALLEL_DIRS=
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
LLVM_CMAKE += -DLLVM_EXTERNAL_CLANG_BUILD=OFF
LLVM_CMAKE += -DLLVM_EXTERNAL_COMPILER_RT_BUILD=OFF
else
LLVM_CMAKE += -DLLVM_TOOL_CLANG_BUILD=OFF
LLVM_CMAKE += -DLLVM_TOOL_COMPILER_RT_BUILD=OFF
endif
endif
ifeq ($(BUILD_LLDB),1)
LLVM_MFLAGS += OPTIONAL_DIRS=lldb
else
# block default building of lldb
LLVM_MFLAGS += OPTIONAL_DIRS=
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
LLVM_CMAKE += -DLLVM_EXTERNAL_LLDB_BUILD=OFF
else
LLVM_CMAKE += -DLLVM_TOOL_LLDB_BUILD=OFF
endif
endif

LLVM_SRC_URL := https://releases.llvm.org/$(LLVM_VER)

Expand Down Expand Up @@ -472,59 +436,7 @@ $$(LLVM_SRC_DIR)/$1.patch-applied: $$(LLVM_SRC_DIR)/source-extracted | $$(SRCDIR
LLVM_PATCH_PREV := $$(LLVM_SRC_DIR)/$1.patch-applied
endef

ifeq ($(LLVM_VER),3.3)
$(eval $(call LLVM_PATCH,llvm-3.3))
$(eval $(call LLVM_PATCH,instcombine-llvm-3.3))
$(eval $(call LLVM_PATCH,int128-vector.llvm-3.3))
$(eval $(call LLVM_PATCH,osx-10.10.llvm-3.3))
$(eval $(call LLVM_PATCH,win64-int128.llvm-3.3))
else ifeq ($(LLVM_VER_SHORT),3.7)
ifeq ($(LLVM_VER),3.7.0)
$(eval $(call LLVM_PATCH,llvm-3.7.0))
endif
$(eval $(call LLVM_PATCH,llvm-3.7.1))
$(eval $(call LLVM_PATCH,llvm-3.7.1_2))
$(eval $(call LLVM_PATCH,llvm-3.7.1_3))
$(eval $(call LLVM_PATCH,llvm-3.7.1_symlinks))
$(eval $(call LLVM_PATCH,llvm-3.8.0_bindir))
$(eval $(call LLVM_PATCH,llvm-D14260))
$(eval $(call LLVM_PATCH,llvm-nodllalias))
$(eval $(call LLVM_PATCH,llvm-D21271-instcombine-tbaa-3.7))
$(eval $(call LLVM_PATCH,llvm-win64-reloc-dwarf))
$(eval $(call LLVM_PATCH,llvm-3.7.1_destsharedlibdir))
$(eval $(call LLVM_PATCH,llvm-arm-fix-prel31))
else ifeq ($(LLVM_VER_SHORT),3.8)
ifeq ($(LLVM_VER),3.8.0)
$(eval $(call LLVM_PATCH,llvm-D17326_unpack_load))
endif
ifeq ($(LLVM_VER),3.8.1)
$(eval $(call LLVM_PATCH,llvm-3.8.1-version))
endif
$(eval $(call LLVM_PATCH,llvm-3.7.1_3)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-D14260))
$(eval $(call LLVM_PATCH,llvm-3.8.0_bindir)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-3.8.0_winshlib)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-D25865-cmakeshlib))
$(eval $(call LLVM_PATCH,llvm-nodllalias)) # Remove for 3.9
# Cygwin and openSUSE still use win32-threads mingw, https://llvm.org/bugs/show_bug.cgi?id=26365
$(eval $(call LLVM_PATCH,llvm-3.8.0_threads))
# fix replutil test on unix
$(eval $(call LLVM_PATCH,llvm-D17165-D18583)) # Remove for 3.9
# Segfault for aggregate load
$(eval $(call LLVM_PATCH,llvm-D17712)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-PR26180)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-PR27046)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-3.8.0_ppc64_SUBFC8)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-D21271-instcombine-tbaa-3.8)) # Remove for 3.9
$(eval $(call LLVM_PATCH,llvm-win64-reloc-dwarf))
$(eval $(call LLVM_PATCH,llvm-arm-fix-prel31))
else ifeq ($(LLVM_VER_SHORT),3.9)
ifeq ($(LLVM_VER),3.9.0)
# fix lowering for atomics on ppc
$(eval $(call LLVM_PATCH,llvm-rL279933-ppc-atomicrmw-lowering)) # Remove for 4.0
$(eval $(call LLVM_PATCH,llvm-r282182)) # Remove for 4.0
$(eval $(call LLVM_PATCH,llvm-3.9.0_cygwin)) # R283427, Remove for 4.0
endif
ifeq ($(LLVM_VER_SHORT),3.9)
$(eval $(call LLVM_PATCH,llvm-PR22923)) # Remove for 4.0
$(eval $(call LLVM_PATCH,llvm-arm-fix-prel31)) # Remove for 4.0
$(eval $(call LLVM_PATCH,llvm-D25865-cmakeshlib)) # Remove for 4.0
Expand Down Expand Up @@ -556,18 +468,8 @@ $(eval $(call LLVM_PATCH,llvm-D33179))
$(eval $(call LLVM_PATCH,llvm-PR29010-i386-xmm)) # Remove for 4.0
endif # LLVM_VER

ifeq ($(LLVM_VER),3.7.1)
ifeq ($(BUILD_LLDB),1)
$(eval $(call LLVM_PATCH,lldb-3.7.1))
endif
ifeq ($(BUILD_LLVM_CLANG),1)
$(eval $(call LLVM_PATCH,compiler-rt-3.7.1))
endif
endif
$(LLVM_BUILDDIR_withtype)/build-configured: $(LLVM_PATCH_PREV)

ifeq ($(LLVM_USE_CMAKE),1)

$(LLVM_BUILDDIR_withtype)/build-configured: $(LLVM_SRC_DIR)/source-extracted | $(llvm_python_workaround) $(LIBCXX_DEPENDENCY)
mkdir -p $(dir $@)
cd $(dir $@) && \
Expand All @@ -584,45 +486,21 @@ $(LLVM_BUILDDIR_withtype)/build-compiled: $(LLVM_BUILDDIR_withtype)/build-config
$(CMAKE) --build .)
echo 1 > $@

else

$(LLVM_BUILDDIR_withtype)/build-configured: $(LLVM_SRC_DIR)/source-extracted | $(llvm_python_workaround) $(LIBCXX_DEPENDENCY)
mkdir -p $(dir $@)
cd $(dir $@) && \
export PATH=$(llvm_python_workaround):$$PATH && \
$(LLVM_SRC_DIR)/configure $(CONFIGURE_COMMON) $(LLVM_FLAGS)
echo 1 > $@

$(LLVM_BUILDDIR_withtype)/build-compiled: $(LLVM_BUILDDIR_withtype)/build-configured | $(llvm_python_workaround)
cd $(LLVM_BUILDDIR_withtype) && \
export PATH=$(llvm_python_workaround):$$PATH && \
$(MAKE) $(LLVM_MFLAGS) $(MAKE_COMMON)
echo 1 > $@

endif # LLVM_USE_CMAKE

$(LLVM_BUILDDIR_withtype)/build-checked: $(LLVM_BUILDDIR_withtype)/build-compiled | $(llvm_python_workaround)
ifeq ($(OS),$(BUILD_OS))
cd $(LLVM_BUILDDIR_withtype) && \
export PATH=$(llvm_python_workaround):$$PATH && \
$(if $(filter $(LLVM_USE_CMAKE),1), \
$(CMAKE) --build . --target check, \
$(MAKE) $(LLVM_MFLAGS) check)
$(CMAKE) --build . --target check
endif
echo 1 > $@

$(build_prefix)/manifest/llvm: | $(llvm_python_workaround)

ifeq ($(LLVM_USE_CMAKE),1)
LLVM_INSTALL = \
cd $1 && $$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake
ifeq ($(OS), WINNT)
LLVM_INSTALL += && cp $2$$(build_shlibdir)/LLVM.dll $2$$(build_depsbindir)
endif
else
LLVM_INSTALL = \
$(call MAKE_INSTALL,$1,$2,$3 $$(LLVM_MFLAGS) PATH="$$(llvm_python_workaround):$$$$PATH" DestSharedLibDir="$2$$(build_shlibdir)")
endif # LLVM_USE_CMAKE

$(eval $(call staged-install,llvm,llvm-$$(LLVM_VER)/build_$$(LLVM_BUILDTYPE), \
LLVM_INSTALL,,,))
Expand Down
12 changes: 0 additions & 12 deletions deps/patches/instcombine-llvm-3.3.patch

This file was deleted.

86 changes: 0 additions & 86 deletions deps/patches/int128-vector.llvm-3.3.patch

This file was deleted.

Loading

0 comments on commit e9f2072

Please sign in to comment.