changeset 5597:f367e764ca55

LLVM: Enable exception handling (bug #59599). * src/llvm.mk: Update download URL. Add build dependency. Enable exception handling. Minor clean-up. * src/llvm-1-llvm-config.patch: Fixes for cross-compiling. * src/mingw-llvm-1-config.patch: Remove patch. * dist-files.mk: Update list of files.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 05 Dec 2020 20:56:44 +0100
parents f62e01947a77
children 9722214b6722
files dist-files.mk src/llvm-1-llvm-config.patch src/llvm.mk src/mingw-llvm-1-config.patch
diffstat 4 files changed, 105 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/dist-files.mk	Wed Dec 02 21:28:46 2020 -0500
+++ b/dist-files.mk	Sat Dec 05 20:56:44 2020 +0100
@@ -319,6 +319,7 @@
   libxml2.mk \
   libxshmfence.mk \
   libxslt.mk \
+  llvm-1-llvm-config.patch \
   llvm.mk \
   log4cxx-1-gcc.4.4.patch \
   log4cxx-2-pkgconfig.patch \
@@ -344,7 +345,6 @@
   mingw-lapack-1-xerbla.patch \
   mingw-libgcrypt-1-fixes.patch \
   mingw-libmng-1-noundefines.patch \
-  mingw-llvm-1-config.patch \
   mingw-openblas-1-xerbla.patch \
   mingw-portaudio-1-pkgconfig.patch \
   mingw-s2tc-1-fixes.patch \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/llvm-1-llvm-config.patch	Sat Dec 05 20:56:44 2020 +0100
@@ -0,0 +1,79 @@
+If `llvm-config` is build as native version on the build system with a
+cross-compile target system (i.e. as a build-tool for other project that want
+to cross-compile), expose the settings for the target of the cross-compiler.
+Also use the file naming conventions for the target of the cross-compiler.
+
+diff --git "a/include/llvm/Config/llvm-config.h.cmake" "b/include/llvm/Config/llvm-config.h.cmake"
+index 872a315..9ad3055 100644
+--- "a/include/llvm/Config/llvm-config.h.cmake"	
++++ "b/include/llvm/Config/llvm-config.h.cmake"
+@@ -65,6 +65,9 @@
+ /* Define if we have the perf JIT-support library */
+ #cmakedefine01 LLVM_USE_PERF
+ 
++/* Define if this is a native build for a cross-compiler */
++#cmakedefine LLVM_TARGET_IS_CROSSCOMPILE_HOST ${LLVM_TARGET_IS_CROSSCOMPILE_HOST}
++
+ /* Major version of the LLVM API */
+ #define LLVM_VERSION_MAJOR ${LLVM_VERSION_MAJOR}
+ 
+diff --git "a/tools/llvm-config/llvm-config.cpp" "b/tools/llvm-config/llvm-config.cpp"
+index bec89fe..a1be375 100644
+--- "a/tools/llvm-config/llvm-config.cpp"	
++++ "b/tools/llvm-config/llvm-config.cpp"
+@@ -37,7 +37,12 @@ using namespace llvm;
+ 
+ // Include the build time variables we can report to the user. This is generated
+ // at build time from the BuildVariables.inc.in file by the build system.
+-#include "BuildVariables.inc"
++#if defined(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
++// include the .inc file with the settings for the cross-compiler
++#  include "../../../tools/llvm-config/BuildVariables.inc"
++#else
++#  include "BuildVariables.inc"
++#endif
+ 
+ // Include the component table. This creates an array of struct
+ // AvailableComponent entries, which record the component name, library name,
+@@ -352,14 +352,16 @@ int main(int argc, char **argv) {
+   StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
+       StaticPrefix, StaticDir = "lib", DirSep = "/";
+   const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
+-  if (HostTriple.isOSWindows()) {
++  const Triple TargetTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE));
++  if (TargetTriple.isOSWindows()) {
+     SharedExt = "dll";
+     SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
+-    if (HostTriple.isOSCygMing()) {
++    if (TargetTriple.isOSCygMing()) {
+       StaticExt = "a";
+       StaticPrefix = "lib";
+     } else {
+       StaticExt = "lib";
++      if (HostTriple.isOSWindows()) {
+       DirSep = "\\";
+       std::replace(ActiveObjRoot.begin(), ActiveObjRoot.end(), '/', '\\');
+       std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\');
+@@ -368,10 +370,11 @@ int main(int argc, char **argv) {
+       std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\');
+       std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/',
+                    '\\');
++      }
+     }
+     SharedDir = ActiveBinDir;
+     StaticDir = ActiveLibDir;
+-  } else if (HostTriple.isOSDarwin()) {
++  } else if (TargetTriple.isOSDarwin()) {
+     SharedExt = "dylib";
+     SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
+     StaticExt = "a";
+@@ -670,7 +673,7 @@ int main(int argc, char **argv) {
+         } else if (PrintLibs) {
+           // On Windows, output full path to library without parameters.
+           // Elsewhere, if this is a typical library name, include it using -l.
+-          if (HostTriple.isWindowsMSVCEnvironment()) {
++          if (TargetTriple.isWindowsMSVCEnvironment()) {
+             OS << GetComponentLibraryPath(Lib, Shared);
+           } else {
+             StringRef LibName;
+
--- a/src/llvm.mk	Wed Dec 02 21:28:46 2020 -0500
+++ b/src/llvm.mk	Sat Dec 05 20:56:44 2020 +0100
@@ -7,8 +7,8 @@
 $(PKG)_CHECKSUM := d43bfea58a35e058b93a6af36a728cfc64add33d
 $(PKG)_SUBDIR   := llvm-$($(PKG)_VERSION).src
 $(PKG)_FILE     := llvm-$($(PKG)_VERSION).src.tar.xz
-$(PKG)_URL      := https://releases.llvm.org/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     :=
+$(PKG)_URL      := https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := build-python
 
 define $(PKG)_UPDATE
     wget -q -O- 'http://releases.llvm.org/download.html?' | \
@@ -24,19 +24,21 @@
                 $($(PKG)_CMAKE_FLAGS) \
                 $(CMAKE_CCACHE_FLAGS) \
                 -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-                -DLLVM_BUILD_LLVM_DYLIB=On \
-                -DLLVM_LINK_LLVM_DYLIB=On \
+                -DLLVM_BUILD_LLVM_DYLIB=ON \
+                -DLLVM_LINK_LLVM_DYLIB=ON \
                 -DLLVM_VERSION_SUFFIX= \
                 -DLLVM_TARGETS_TO_BUILD='X86' \
-                -DLLVM_BUILD_EXAMPLES=Off \
-                -DLLVM_INCLUDE_EXAMPLES=Off \
-                -DLLVM_BUILD_TESTS=Off \
-                -DLLVM_INCLUDE_TESTS=Off \
+                -DLLVM_ENABLE_EH=ON \
+                -DLLVM_ENABLE_RTTI=ON \
+                -DLLVM_BUILD_EXAMPLES=OFF \
+                -DLLVM_INCLUDE_EXAMPLES=OFF \
+                -DLLVM_BUILD_TESTS=OFF \
+                -DLLVM_INCLUDE_TESTS=OFF \
                 -DLLVM_INCLUDE_GO_TESTS=OFF \
                 -DLLVM_INCLUDE_DOCS=OFF \
                 -DLLVM_BUILD_DOCS=OFF \
                 -DLLVM_ENABLE_DOXYGEN=OFF \
-                -DLLVM_ENABLE_BACKTRACES=Off
+                -DLLVM_ENABLE_BACKTRACES=OFF
 
             $(MAKE) -C '$(1)/.build' -j '$(JOBS)' install DESTDIR='$(3)'
         endef
@@ -48,18 +50,15 @@
     endif
 else
     ifeq ($(ENABLE_WINDOWS_64),yes)
-        ## WTF, setting LLVM_TARGETS_TO_BUILD to X64_64 doesn't work here?
         $(PKG)_SYSDEP_CMAKE_OPTIONS += \
-            -DLLVM_DEFAULT_TARGET_TRIPLE='x86_64-pc-win32' \
-            -DLLVM_TARGETS_TO_BUILD='X86'
+            -DLLVM_DEFAULT_TARGET_TRIPLE='x86_64-pc-win32'
     else
-      $(PKG)_SYSDEP_CMAKE_OPTIONS += \
-          -DLLVM_DEFAULT_TARGET_TRIPLE='x86-pc-win32' \
-          -DLLVM_TARGETS_TO_BUILD='X86'
+        $(PKG)_SYSDEP_CMAKE_OPTIONS += \
+            -DLLVM_DEFAULT_TARGET_TRIPLE='x86-pc-win32'
     endif
     ifeq ($(USE_CCACHE),yes)
         $(PKG)_CCACHE_OPTIONS += \
-            -DLLVM_CCACHE_BUILD=On
+            -DLLVM_CCACHE_BUILD=ON
     endif
 
     define $(PKG)_BUILD
@@ -69,17 +68,20 @@
             $(CMAKE_CCACHE_FLAGS) \
             -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
             -DLLVM_BUILD_TOOLS=OFF \
-            -DLLVM_BUILD_LLVM_DYLIB=On \
-            -DLLVM_LINK_LLVM_DYLIB=On \
+            -DLLVM_BUILD_LLVM_DYLIB=ON \
+            -DLLVM_LINK_LLVM_DYLIB=ON \
             -DLLVM_VERSION_SUFFIX= \
+            -DLLVM_TARGETS_TO_BUILD='X86' \
             $($(PKG)_SYSDEP_CMAKE_OPTIONS) \
             -DCROSS_TOOLCHAIN_FLAGS_NATIVE="-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_NATIVE_TOOLCHAIN_FILE)'" \
-            -DLLVM_BUILD_EXAMPLES=Off \
-            -DLLVM_INCLUDE_EXAMPLES=Off \
-            -DLLVM_BUILD_TESTS=Off \
-            -DLLVM_INCLUDE_TESTS=Off \
+            -DLLVM_ENABLE_EH=ON \
+            -DLLVM_ENABLE_RTTI=ON \
+            -DLLVM_BUILD_EXAMPLES=OFF \
+            -DLLVM_INCLUDE_EXAMPLES=OFF \
+            -DLLVM_BUILD_TESTS=OFF \
+            -DLLVM_INCLUDE_TESTS=OFF \
             -DLLVM_INCLUDE_GO_TESTS=OFF \
-            -DLLVM_ENABLE_BACKTRACES=Off \
+            -DLLVM_ENABLE_BACKTRACES=OFF \
             -DLLVM_INCLUDE_DOCS=OFF \
             -DLLVM_BUILD_DOCS=OFF \
             -DLLVM_ENABLE_DOXYGEN=OFF \
@@ -101,8 +103,6 @@
         cd '$(3)/$(HOST_BINDIR)' && ln -s LLVM.dll LLVM-$(word 1,$(subst ., ,$($(PKG)_VERSION))).$(word 2,$(subst ., ,$($(PKG)_VERSION))).dll
 
         # install native llvm-config in HOST_BINDIR because it won't find the libs otherwise
-        # FIXME: Some of the configuration flags are hard coded into llvm-config with a patch.
-        # If the configuration flags are changed, the patch might have to be adapted.
         $(INSTALL) -d '$(HOST_BINDIR)'
         $(INSTALL) -m755 '$(1)/.build/NATIVE/bin/llvm-config' '$(HOST_BINDIR)/$(MXE_TOOL_PREFIX)llvm-config'
     endef
--- a/src/mingw-llvm-1-config.patch	Wed Dec 02 21:28:46 2020 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-diff --git "a/tools/llvm-config/llvm-config.cpp" "b/tools/llvm-config/llvm-config.cpp"
-index 08b096a..a35422e 100644
---- "a/tools/llvm-config/llvm-config.cpp"	
-+++ "b/tools/llvm-config/llvm-config.cpp"
-@@ -352,14 +352,16 @@ int main(int argc, char **argv) {
-   StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
-       StaticPrefix, StaticDir = "lib", DirSep = "/";
-   const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
--  if (HostTriple.isOSWindows()) {
-+  const Triple TargetTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE));
-+  if (TargetTriple.isOSWindows()) {
-     SharedExt = "dll";
-     SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
--    if (HostTriple.isOSCygMing()) {
-+    if (TargetTriple.isOSCygMing()) {
-       StaticExt = "a";
-       StaticPrefix = "lib";
-     } else {
-       StaticExt = "lib";
-+      if (HostTriple.isOSWindows()) {
-       DirSep = "\\";
-       std::replace(ActiveObjRoot.begin(), ActiveObjRoot.end(), '/', '\\');
-       std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\');
-@@ -368,10 +370,11 @@ int main(int argc, char **argv) {
-       std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\');
-       std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/',
-                    '\\');
-+      }
-     }
-     SharedDir = ActiveBinDir;
-     StaticDir = ActiveLibDir;
--  } else if (HostTriple.isOSDarwin()) {
-+  } else if (TargetTriple.isOSDarwin()) {
-     SharedExt = "dylib";
-     SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
-     StaticExt = "a";
-@@ -386,7 +389,7 @@ int main(int argc, char **argv) {
-     StaticPrefix = SharedPrefix = "lib";
-   }
- 
--  const bool BuiltDyLib = !!LLVM_ENABLE_DYLIB;
-+  const bool BuiltDyLib = true;
- 
-   /// CMake style shared libs, ie each component is in a shared library.
-   const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED;
-@@ -398,7 +401,7 @@ int main(int argc, char **argv) {
-   // If LLVM_LINK_DYLIB is ON, the single shared library will be returned
-   // for "--libs", etc, if they exist. This behaviour can be overridden with
-   // --link-static or --link-shared.
--  bool LinkDyLib = !!LLVM_LINK_DYLIB;
-+  bool LinkDyLib = true;
- 
-   if (BuiltDyLib) {
-     std::string path((SharedDir + DirSep + DyLibName).str());
-@@ -670,7 +673,7 @@ int main(int argc, char **argv) {
-         } else if (PrintLibs) {
-           // On Windows, output full path to library without parameters.
-           // Elsewhere, if this is a typical library name, include it using -l.
--          if (HostTriple.isWindowsMSVCEnvironment()) {
-+          if (TargetTriple.isWindowsMSVCEnvironment()) {
-             OS << GetComponentLibraryPath(Lib, Shared);
-           } else {
-             StringRef LibName;
-