From dffb85bee28efe409b5c52fb090e1b49a29a6575 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Thu, 7 Jan 2016 19:23:11 +0100 Subject: [PATCH] llvm: update to 3.8.0. Use cmake to build. This is the favored method of building by upstream. Consequences: - Build lld again - Build LLVMgold - Enable sanitizers on non-musl platforms - Remove llvm-doc (not built by cmake, quite useless) - Use versioned binary names - Could use ninja with make_cmd=ninja and configure -Gninja, but we stick to make for now. Also cleaned up and fixed remaining patches. --- common/shlibs | 1 + srcpkgs/{libllvm3.7 => libllvm3.8} | 0 srcpkgs/lld | 1 + srcpkgs/lld-devel | 1 + .../cfe-005-fix-dynamic-linker-paths.patch | 46 +----- .../cfe/cfe-006-no-use-cxa-atexit.patch | 26 ---- .../cfe/cfe-007-musl-use-init-array.patch | 32 +--- ...8-remove-lgcc-when-using-compiler-rt.patch | 25 --- .../compiler-rt-002-musl-no-dlvsym.patch | 16 +- ...piler-rt_musl_001-disable-sanitizers.patch | 31 ---- .../llvm/files/patches/lldb/fix-musl.patch | 39 ----- .../patches/llvm/llvm-002-musl-triple.patch | 44 +++--- .../files/patches/llvm/llvm-003-musl.patch | 31 ---- srcpkgs/llvm/template | 146 +++++++++++------- 14 files changed, 128 insertions(+), 311 deletions(-) rename srcpkgs/{libllvm3.7 => libllvm3.8} (100%) create mode 120000 srcpkgs/lld create mode 120000 srcpkgs/lld-devel delete mode 100644 srcpkgs/llvm/files/patches/cfe/cfe-006-no-use-cxa-atexit.patch delete mode 100644 srcpkgs/llvm/files/patches/cfe/cfe-008-remove-lgcc-when-using-compiler-rt.patch delete mode 100644 srcpkgs/llvm/files/patches/compiler-rt/compiler-rt_musl_001-disable-sanitizers.patch diff --git a/common/shlibs b/common/shlibs index 202d105713a..ebfb7888556 100644 --- a/common/shlibs +++ b/common/shlibs @@ -948,6 +948,7 @@ libLLVM-3.5.so libllvm-3.5.0_1 libLLVM-3.6.so libllvm3.6-3.6.0_1 libLLVM-3.7.so libllvm3.7-3.7.0_1 libLLVM-3.7.1.so libllvm3.7-3.7.1_1 +libLLVM-3.8.so libllvm3.8-3.8.0_1 libisofs.so.6 libisofs-0.6.24_1 libbfd-2.22.so binutils-2.22_1<2.23_1 libopcodes-2.22.so binutils-2.22_1<2.23_1 diff --git a/srcpkgs/libllvm3.7 b/srcpkgs/libllvm3.8 similarity index 100% rename from srcpkgs/libllvm3.7 rename to srcpkgs/libllvm3.8 diff --git a/srcpkgs/lld b/srcpkgs/lld new file mode 120000 index 00000000000..0d68131b9b3 --- /dev/null +++ b/srcpkgs/lld @@ -0,0 +1 @@ +llvm \ No newline at end of file diff --git a/srcpkgs/lld-devel b/srcpkgs/lld-devel new file mode 120000 index 00000000000..0d68131b9b3 --- /dev/null +++ b/srcpkgs/lld-devel @@ -0,0 +1 @@ +llvm \ No newline at end of file diff --git a/srcpkgs/llvm/files/patches/cfe/cfe-005-fix-dynamic-linker-paths.patch b/srcpkgs/llvm/files/patches/cfe/cfe-005-fix-dynamic-linker-paths.patch index 559cdde62ed..df2848917b2 100644 --- a/srcpkgs/llvm/files/patches/cfe/cfe-005-fix-dynamic-linker-paths.patch +++ b/srcpkgs/llvm/files/patches/cfe/cfe-005-fix-dynamic-linker-paths.patch @@ -1,17 +1,6 @@ -From edd1fc14b3c3e05b14c3ab1917515a11bc477aca Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:33:28 +0200 -Subject: [PATCH 4/7] fix dynamic linker paths - ---- - lib/Driver/Tools.cpp | 43 ++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 38 insertions(+), 5 deletions(-) - -diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp -index 19ebbb9..4384829 100644 ---- a/lib/Driver/Tools.cpp -+++ b/lib/Driver/Tools.cpp -@@ -7958,7 +7958,14 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, +--- cfe-3.8.0.src/lib/Driver/Tools.cpp.orig ++++ cfe-3.8.0.src/lib/Driver/Tools.cpp +@@ -8632,7 +8632,14 @@ return "/system/bin/linker64"; else return "/system/bin/linker"; @@ -27,26 +16,8 @@ index 19ebbb9..4384829 100644 Arch == llvm::Triple::sparcel) return "/lib/ld-linux.so.2"; else if (Arch == llvm::Triple::aarch64) -@@ -7970,14 +7977,34 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, - tools::arm::getARMFloatABI(ToolChain.getDriver(), Args, ToolChain.getTriple()) == "hard") - return "/lib/ld-linux-armhf.so.3"; - else -- return "/lib/ld-linux.so.3"; -+ switch (ToolChain.getTriple().getEnvironment()) { -+ case llvm::Triple::Musl: -+ case llvm::Triple::MuslEABI: -+ return "/lib/ld-musl-arm.so.1"; -+ case llvm::Triple::MuslEABIHF: -+ return "/lib/ld-musl-armhf.so.1"; -+ case llvm::Triple::GNUEABIHF: -+ return "/lib/ld-linux-armhf.so.1"; -+ default: -+ return "/lib/ld-linux.so.3"; -+ } - } else if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) { - // TODO: check which dynamic linker name. - if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF || - tools::arm::getARMFloatABI(ToolChain.getDriver(), Args, ToolChain.getTriple()) == "hard") +@@ -8651,7 +8658,17 @@ + arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard) return "/lib/ld-linux-armhf.so.3"; else - return "/lib/ld-linux.so.3"; @@ -63,8 +34,8 @@ index 19ebbb9..4384829 100644 + } } else if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel || Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el) { - StringRef CPUName; -@@ -8014,8 +8041,14 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, + std::string LibDir = +@@ -8685,8 +8702,14 @@ else if (Arch == llvm::Triple::x86_64 && ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUX32) return "/libx32/ld-linux-x32.so.2"; @@ -81,6 +52,3 @@ index 19ebbb9..4384829 100644 } static void AddRunTimeLibs(const ToolChain &TC, const Driver &D, --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/cfe/cfe-006-no-use-cxa-atexit.patch b/srcpkgs/llvm/files/patches/cfe/cfe-006-no-use-cxa-atexit.patch deleted file mode 100644 index f48f8e6a016..00000000000 --- a/srcpkgs/llvm/files/patches/cfe/cfe-006-no-use-cxa-atexit.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 7024157ee8c63e3d892e3bcac8bbe73b4dd92bbd Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:35:39 +0200 -Subject: [PATCH 5/7] no use cxa atexit - ---- - lib/Driver/Tools.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp -index 4384829..b6bf7fc 100644 ---- a/lib/Driver/Tools.cpp -+++ b/lib/Driver/Tools.cpp -@@ -4435,7 +4435,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - options::OPT_fno_use_cxa_atexit, - !IsWindowsCygnus && !IsWindowsGNU && - getToolChain().getArch() != llvm::Triple::hexagon && -- getToolChain().getArch() != llvm::Triple::xcore) || -+ getToolChain().getArch() != llvm::Triple::xcore && -+ getToolChain().getTriple().getEnvironment() != llvm::Triple::Musl) || - KernelOrKext) - CmdArgs.push_back("-fno-use-cxa-atexit"); - --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/cfe/cfe-007-musl-use-init-array.patch b/srcpkgs/llvm/files/patches/cfe/cfe-007-musl-use-init-array.patch index 6451146a346..bab9a293106 100644 --- a/srcpkgs/llvm/files/patches/cfe/cfe-007-musl-use-init-array.patch +++ b/srcpkgs/llvm/files/patches/cfe/cfe-007-musl-use-init-array.patch @@ -1,26 +1,10 @@ -From 886d662712b1cfb5cf7b84bfd96fb5f8b58069d5 Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:38:44 +0200 -Subject: [PATCH 6/7] musl use init array - ---- - lib/Driver/ToolChains.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index 3cd6dd1..ef77df8 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -2071,7 +2071,8 @@ void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs, +--- cfe-3.8.0.src/lib/Driver/ToolChains.cpp.orig ++++ cfe-3.8.0.src/lib/Driver/ToolChains.cpp +@@ -2428,6 +2428,7 @@ + ArgStringList &CC1Args) const { + const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion(); + bool UseInitArrayDefault = ++ getTriple().getEnvironment() == llvm::Triple::Musl || + getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be || (getTriple().getOS() == llvm::Triple::Linux && - (!V.isOlderThan(4, 7, 0) || -- getTriple().getEnvironment() == llvm::Triple::Android)) || -+ getTriple().getEnvironment() == llvm::Triple::Android || -+ getTriple().getEnvironment() == llvm::Triple::Musl)) || - getTriple().getOS() == llvm::Triple::NaCl; - - if (DriverArgs.hasFlag(options::OPT_fuse_init_array, --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/cfe/cfe-008-remove-lgcc-when-using-compiler-rt.patch b/srcpkgs/llvm/files/patches/cfe/cfe-008-remove-lgcc-when-using-compiler-rt.patch deleted file mode 100644 index e3c0e0679ff..00000000000 --- a/srcpkgs/llvm/files/patches/cfe/cfe-008-remove-lgcc-when-using-compiler-rt.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 75d91fe8d9219007069af02301565173bd5d0612 Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:39:20 +0200 -Subject: [PATCH 7/7] remove lgcc when using compiler rt - ---- - lib/Driver/Tools.cpp | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp -index b6bf7fc..665961a 100644 ---- a/lib/Driver/Tools.cpp -+++ b/lib/Driver/Tools.cpp -@@ -2389,8 +2389,6 @@ static void addClangRT(const ToolChain &TC, const ArgList &Args, - CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, "builtins"))); - - if (!TC.getTriple().isOSWindows()) { -- // FIXME: why do we link against gcc when we are using compiler-rt? -- CmdArgs.push_back("-lgcc_s"); - if (TC.getDriver().CCCIsCXX()) - CmdArgs.push_back("-lgcc_eh"); - } --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt-002-musl-no-dlvsym.patch b/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt-002-musl-no-dlvsym.patch index 420b60ac452..70908618b15 100644 --- a/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt-002-musl-no-dlvsym.patch +++ b/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt-002-musl-no-dlvsym.patch @@ -1,14 +1,3 @@ -From 7f278344034eab699a90fab3d313048d1de44012 Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:45:11 +0200 -Subject: [PATCH 2/2] musl no dlvsym - ---- - lib/interception/interception_linux.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc -index 6e908ac..7fcf2a6 100644 --- a/lib/interception/interception_linux.cc +++ b/lib/interception/interception_linux.cc @@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, @@ -16,10 +5,7 @@ index 6e908ac..7fcf2a6 100644 } -#if !defined(__ANDROID__) // android does not have dlvsym -+#if 0 // !defined(__ANDROID__) // android does not have dlvsym ++#if defined(__GLIBC__) // !defined(__ANDROID__) // android does not have dlvsym void *GetFuncAddrVer(const char *func_name, const char *ver) { return dlvsym(RTLD_NEXT, func_name, ver); } --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt_musl_001-disable-sanitizers.patch b/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt_musl_001-disable-sanitizers.patch deleted file mode 100644 index f8e2ff9d322..00000000000 --- a/srcpkgs/llvm/files/patches/compiler-rt/compiler-rt_musl_001-disable-sanitizers.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 146c027efdd839b7173a922a43c4ab7003bdc160 Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:44:22 +0200 -Subject: [PATCH 1/2] disable sanitizers - ---- - lib/Makefile.mk | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/lib/Makefile.mk b/lib/Makefile.mk -index 7eb6489..c0efac3 100644 ---- a/lib/Makefile.mk -+++ b/lib/Makefile.mk -@@ -10,10 +10,10 @@ - SubDirs := - - # Add submodules. --SubDirs += asan -+# SubDirs += asan - SubDirs += builtins - SubDirs += interception --SubDirs += lsan -+# SubDirs += lsan - SubDirs += profile --SubDirs += sanitizer_common --SubDirs += ubsan -+# SubDirs += sanitizer_common -+# SubDirs += ubsan --- -2.5.1 - diff --git a/srcpkgs/llvm/files/patches/lldb/fix-musl.patch b/srcpkgs/llvm/files/patches/lldb/fix-musl.patch index 80c22b7a8b0..67b8df07495 100644 --- a/srcpkgs/llvm/files/patches/lldb/fix-musl.patch +++ b/srcpkgs/llvm/files/patches/lldb/fix-musl.patch @@ -11,18 +11,6 @@ Subject: [PATCH] fix musl source/Plugins/Process/Linux/Procfs.h | 2 +- 5 files changed, 6 insertions(+), 2 deletions(-) -diff --git a/source/Core/ConnectionSharedMemory.cpp b/source/Core/ConnectionSharedMemory.cpp -index 77daeb1..36e9bc7 100644 ---- a/source/Core/ConnectionSharedMemory.cpp -+++ b/source/Core/ConnectionSharedMemory.cpp -@@ -16,6 +16,7 @@ - #ifdef _WIN32 - #include "lldb/Host/windows/windows.h" - #else -+#include /* O_RDRW */ - #include - #include - #include diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp index ceb094b..a48620d 100644 --- a/source/Host/common/FileSpec.cpp @@ -35,33 +23,6 @@ index ceb094b..a48620d 100644 #ifndef _MSC_VER #include #endif -diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp -index 6217b1d..edcfa4a 100644 ---- a/source/Host/linux/Host.cpp -+++ b/source/Host/linux/Host.cpp -@@ -14,7 +14,7 @@ - #include - #include - #include --#ifndef __ANDROID__ -+#ifdef __GLIBC__ - #include - #endif - -diff --git a/source/Host/linux/HostThreadLinux.cpp b/source/Host/linux/HostThreadLinux.cpp -index 8151215..a849e51 100644 ---- a/source/Host/linux/HostThreadLinux.cpp -+++ b/source/Host/linux/HostThreadLinux.cpp -@@ -30,7 +30,9 @@ HostThreadLinux::HostThreadLinux(lldb::thread_t thread) - void - HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name) - { -+#if defined(__ANDROID__) || defined(__GLIBC__) - ::pthread_setname_np(thread, name.data()); -+#endif - } - - void diff --git a/source/Plugins/Process/Linux/Procfs.h b/source/Plugins/Process/Linux/Procfs.h index 1b383fb..4ebe390 100644 --- a/source/Plugins/Process/Linux/Procfs.h diff --git a/srcpkgs/llvm/files/patches/llvm/llvm-002-musl-triple.patch b/srcpkgs/llvm/files/patches/llvm/llvm-002-musl-triple.patch index 2f6fd59079a..b2e1af9fcce 100644 --- a/srcpkgs/llvm/files/patches/llvm/llvm-002-musl-triple.patch +++ b/srcpkgs/llvm/files/patches/llvm/llvm-002-musl-triple.patch @@ -49,29 +49,6 @@ index c6646fb..8d47ad9 100644 .StartsWith("msvc", Triple::MSVC) .StartsWith("itanium", Triple::Itanium) .StartsWith("cygnus", Triple::Cygnus) -diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h -index dd101df..c5bdcca 100644 ---- a/lib/Target/ARM/ARMSubtarget.h -+++ b/lib/Target/ARM/ARMSubtarget.h -@@ -381,8 +381,10 @@ public: - bool isTargetEHABICompatible() const { - return (TargetTriple.getEnvironment() == Triple::EABI || - TargetTriple.getEnvironment() == Triple::GNUEABI || -+ TargetTriple.getEnvironment() == Triple::MuslEABI || - TargetTriple.getEnvironment() == Triple::EABIHF || - TargetTriple.getEnvironment() == Triple::GNUEABIHF || -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF || - TargetTriple.getEnvironment() == Triple::Android) && - !isTargetDarwin() && !isTargetWindows(); - } -@@ -391,6 +393,7 @@ public: - // FIXME: this is invalid for WindowsCE - return TargetTriple.getEnvironment() == Triple::GNUEABIHF || - TargetTriple.getEnvironment() == Triple::EABIHF || -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF || - isTargetWindows(); - } - bool isTargetAndroid() const { diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 93495d6..56e6b7f 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp @@ -88,3 +65,24 @@ index 93495d6..56e6b7f 100644 -- 2.5.1 +--- llvm-3.8.0.src/lib/Target/ARM/ARMSubtarget.h.orig 2016-03-09 13:34:16.919107629 +0100 ++++ llvm-3.8.0.src/lib/Target/ARM/ARMSubtarget.h 2016-03-09 13:38:12.019342405 +0100 +@@ -405,8 +405,10 @@ + bool isTargetEHABICompatible() const { + return (TargetTriple.getEnvironment() == Triple::EABI || + TargetTriple.getEnvironment() == Triple::GNUEABI || ++ TargetTriple.getEnvironment() == Triple::MuslEABI || + TargetTriple.getEnvironment() == Triple::EABIHF || + TargetTriple.getEnvironment() == Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == Triple::MuslEABIHF || + isTargetAndroid()) && + !isTargetDarwin() && !isTargetWindows(); + } +@@ -415,6 +417,7 @@ + // FIXME: this is invalid for WindowsCE + return TargetTriple.getEnvironment() == Triple::GNUEABIHF || + TargetTriple.getEnvironment() == Triple::EABIHF || ++ TargetTriple.getEnvironment() == Triple::MuslEABIHF || + isTargetWindows() || isAAPCS16_ABI(); + } + bool isTargetAndroid() const { return TargetTriple.isAndroid(); } diff --git a/srcpkgs/llvm/files/patches/llvm/llvm-003-musl.patch b/srcpkgs/llvm/files/patches/llvm/llvm-003-musl.patch index d88b5fc925c..8fafa570037 100644 --- a/srcpkgs/llvm/files/patches/llvm/llvm-003-musl.patch +++ b/srcpkgs/llvm/files/patches/llvm/llvm-003-musl.patch @@ -66,37 +66,6 @@ index 9a7aeb5..e21750d 100644 // On linux we have a weird situation. The stderr/out/in symbols are both // macros and global variables because of standards requirements. So, we -diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc -index bfe2a3a..e8372d9 100644 ---- a/lib/Support/Unix/Signals.inc -+++ b/lib/Support/Unix/Signals.inc -@@ -117,7 +117,7 @@ static void RegisterHandlers() { - // during handling an actual signal because you can't safely call new in a - // signal handler. - *SignalsMutex; -- -+ - // If the handlers are already registered, we're done. - if (NumRegisteredSignals != 0) return; - -@@ -164,7 +164,7 @@ static void RemoveFilesToRemove() { - // super-user permissions. - if (!S_ISREG(buf.st_mode)) - continue; -- -+ - // Otherwise, remove the file. We ignore any errors here as there is nothing - // else we can do. - unlink(path); -@@ -430,7 +430,7 @@ static bool printSymbolizedStackTrace(void **StackTrace, int Depth, - // On glibc systems we have the 'backtrace' function, which works nicely, but - // doesn't demangle symbols. - void llvm::sys::PrintStackTrace(raw_ostream &OS) { --#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) -+#if defined(__GLIBC__) && defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) - static void* StackTrace[256]; - // Use backtrace() to output a backtrace on Linux systems with glibc. - int depth = backtrace(StackTrace, diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc index 5780764..1d548c1 100644 --- a/utils/unittest/googletest/src/gtest.cc diff --git a/srcpkgs/llvm/template b/srcpkgs/llvm/template index c28fc31889a..4fe677a39bd 100644 --- a/srcpkgs/llvm/template +++ b/srcpkgs/llvm/template @@ -1,13 +1,19 @@ # Template file for 'llvm' pkgname=llvm -version=3.7.1 -revision=2 +version=3.8.0 +revision=1 wrksrc="llvm-${version}.src" lib32disabled=yes -configure_args="--disable-expensive-checks --disable-debug-runtime - --enable-bindings=none --enable-optimized --enable-shared --enable-libffi - --enable-llvmc-dynamic --disable-assertions --enable-keep-symbols - --enable-experimental-targets=AMDGPU" +build_style=cmake +configure_args=" + -DCMAKE_BUILD_TYPE=Release + -DLLVM_BUILD_LLVM_DYLIB=ON + -DLLVM_LINK_LLVM_DYLIB=ON + -DLLVM_DYLIB_EXPORT_ALL=ON + -DLLVM_ENABLE_RTTI=ON + -DLLVM_ENABLE_FFI=ON + -DLLVM_BINUTILS_INCDIR=/usr/include + -DCMAKE_INSTALL_DO_STRIP=0" short_desc="Low Level Virtual Machine" maintainer="Juan RP " homepage="http://www.llvm.org" @@ -15,25 +21,28 @@ license="BSD" distfiles=" http://www.llvm.org/releases/${version}/llvm-${version}.src.tar.xz http://www.llvm.org/releases/${version}/lldb-${version}.src.tar.xz + http://www.llvm.org/releases/${version}/lld-${version}.src.tar.xz http://www.llvm.org/releases/${version}/cfe-${version}.src.tar.xz http://www.llvm.org/releases/${version}/clang-tools-extra-${version}.src.tar.xz http://www.llvm.org/releases/${version}/compiler-rt-${version}.src.tar.xz" -checksum=" - be7794ed0cec42d6c682ca8e3517535b54555a3defabec83554dbc74db545ad5 - 9a0bc315ef55f44c98cdf92d064df0847f453ed156dd0ef6a87e04f5fd6a0e01 - 56e2164c7c2a1772d5ed2a3e57485ff73ff06c97dff12edbeea1acc4412b0674 - 4a91edaccad1ce984c7c49a4a87db186b7f7b21267b2b03bcf4bd7820715bc6b - 9d4769e4a927d3824bcb7a9c82b01e307c68588e6de4e7f04ab82d82c5af8181" +checksum="555b028e9ee0f6445ff8f949ea10e9cd8be0d084840e21fbbe1d31d51fc06e46 + e3f68f44147df0433e7989bf6ed1c58ff28d7c68b9c47553cb9915f744785a35 + 94704dda228c9f75f4403051085001440b458501ec97192eee06e8e67f7f9f0c + 04149236de03cf05232d68eb7cb9c50f03062e339b68f4f8a03b650a11536cf9 + afbda810106a6e64444bc164b921be928af46829117c95b996f2678ce4cb1ec4 + c8d3387e55f229543dac1941769120f24dc50183150bf19d1b070d53d29d56b0" # XXX Investigate ocaml bindings. -hostmakedepends="groff perl python zlib-devel libffi-devel swig" -makedepends="python-devel zlib-devel libffi-devel libedit-devel" +hostmakedepends="groff perl python zlib-devel libffi-devel swig cmake" +makedepends="python-devel zlib-devel libffi-devel libedit-devel libxml2-devel binutils-devel" +depends="libllvm3.8" -subpackages="clang clang-analyzer libllvm3.7 llvm-doc" +subpackages="clang clang-analyzer libllvm3.8" if [ -z "$CROSS_BUILD" ]; then # XXX fails to cross compile due to python subpackages+=" lldb lldb-devel" fi +subpackages+=" lld lld-devel" post_extract() { # patches @@ -48,9 +57,6 @@ post_extract() { msg_normal "Applying $i to compiler-rt\n" patch -sNp1 -i ${i} done - case "$XBPS_TARGET_MACHINE" in - *-musl) patch -sNp1 -i "${FILESDIR}/patches/compiler-rt/compiler-rt_musl_001-disable-sanitizers.patch" ;; - esac # FIX BUG 22661 case "$XBPS_TARGET_MACHINE" in i686*) sed -ri "/ifeq.*CompilerTargetArch/s#i386#i686#g" make/platform/clang_linux.mk ;; @@ -79,6 +85,10 @@ post_extract() { if [ -d ${XBPS_BUILDDIR}/clang-tools-extra-${version}.src ]; then mv ${XBPS_BUILDDIR}/clang-tools-extra-${version}.src ${wrksrc}/tools/clang/extra fi + # Move lld files into the llvm source. + if [ -d ${XBPS_BUILDDIR}/lld-${version}.src ]; then + mv ${XBPS_BUILDDIR}/lld-${version}.src ${wrksrc}/tools/lld + fi # Move lldb files into the llvm source. if [ -z "$CROSS_BUILD" -a -d ${XBPS_BUILDDIR}/lldb-${version}.src ]; then mv ${XBPS_BUILDDIR}/lldb-${version}.src ${wrksrc}/tools/lldb @@ -87,32 +97,46 @@ post_extract() { if [ -d ${XBPS_BUILDDIR}/compiler-rt-${version}.src ]; then mv ${XBPS_BUILDDIR}/compiler-rt-${version}.src ${wrksrc}/projects/compiler-rt fi + case "$XBPS_TARGET_MACHINE" in + *-musl) + # Disable sanitizers + sed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' ${wrksrc}/projects/compiler-rt/cmake/config-ix.cmake + ;; + esac + } -do_configure() { - unset CC CXX CPP AR AS RANLIB CFLAGS CXXFLAGS CPPFLAGS LDFLAGS +pre_configure() { + if [ "$CROSS_BUILD" ]; then + msg_normal "Building host tblgen\n" + mkdir -p build/HOST + cd build/HOST + CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \ + CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \ + cmake ../.. -DCMAKE_BUILD_TYPE=Release + make ${makejobs} -C utils/TableGen + make ${makejobs} -C tools/clang/utils/TableGen + configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/build/HOST/bin/llvm-tblgen" + configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/build/HOST/bin/clang-tblgen" + cd ../.. + fi - # Fix installation directories, ./configure doesn't seem to set them right - sed -i -e 's:\$(PROJ_prefix)/etc/llvm:/etc/llvm:' \ - -e 's:\$(PROJ_prefix)/docs/llvm:$(PROJ_prefix)/share/doc/llvm:' \ - Makefile.config.in - - mkdir build - cd build - ../configure ${configure_args} -} - -do_build() { - unset CC CXX CPP AR AS RANLIB CFLAGS CXXFLAGS CPPFLAGS LDFLAGS - cd build - make REQUIRES_RTTI=1 ${makejobs} + case "$XBPS_TARGET_MACHINE" in + i686*) _arch="X86";; + x86_64*) _arch="X86";; + arm*) _arch="ARM";; + aarch64*) _arch="AArch64";; + mips*) _arch="Mips";; + esac + configure_args+=" -DLLVM_TARGET_ARCH=${_arch}" + configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}" } do_install() { vlicense LICENSE.TXT cd build - make DESTDIR=${DESTDIR} install + cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake # Fix permissions of static libs chmod -x ${DESTDIR}/usr/lib/*.a @@ -122,7 +146,7 @@ do_install() { # Required for multilib. if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then - for _header in config llvm-config; do + for _header in llvm-config; do mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \ usr/include/llvm/Config ${_header}.h @@ -139,21 +163,15 @@ do_install() { clang-analyzer_package() { noarch=yes - pycompile_dirs="usr/lib/clang-analyzer" + pycompile_dirs="usr/share/scan-view" depends="clang-${version}_${revision} python" short_desc+=" - A source code analysis framework" homepage="http://clang-analyzer.llvm.org/" pkg_install() { - vmkdir usr/bin - vmkdir usr/lib/clang-analyzer - - for f in build view; do - cp -r ${wrksrc}/tools/clang/tools/scan-${f} ${PKGDESTDIR}/usr/lib/clang-analyzer - cd ${PKGDESTDIR}/usr/bin - ln -s ../lib/${pkgname}/scan-${f}/scan-${f} scan-${f} - done - - ln -sf /usr/bin/clang ${PKGDESTDIR}/usr/lib/${pkgname}/scan-build + vmove usr/share/man/man1/scan-build.1 + vmove "/usr/bin/scan-*" + vmove "/usr/share/scan-*" + vmove "/usr/libexec/*analyzer" } } clang_package() { @@ -171,6 +189,25 @@ clang_package() { vmove usr/bin/c-index-test vmove usr/lib/clang vmove "usr/lib/libclang*" + vmove "usr/share/clang" + } +} +lld_package() { + lib32disabled=yes + short_desc+=" - linker" + homepage="http://lld.llvm.org" + pkg_install() { + vmove usr/bin/lld* + vmove usr/bin/ld.lld* + } +} +lld-devel_package() { + lib32disabled=yes + short_desc+=" - linker - development files" + homepage="http://lld.llvm.org" + pkg_install() { + vmove usr/include/lld + vmove "usr/lib/liblld*a" } } lldb_package() { @@ -179,7 +216,7 @@ lldb_package() { homepage="http://lldb.llvm.org/" pkg_install() { vmove "usr/bin/*lldb*" - vmove "usr/lib/liblldb*so" + vmove "usr/lib/liblldb*so.*" vman tools/lldb/docs/lldb.1 vmove "/usr/lib/python*" } @@ -190,19 +227,12 @@ lldb-devel_package() { pkg_install() { vmove usr/include/lldb vmove "usr/lib/liblldb*.a" + vmove "usr/lib/liblldb*.so" } } -llvm-doc_package() { - noarch=yes - short_desc+=" - documentation files" - pkg_install() { - vmove usr/share/doc - } -} -libllvm3.7_package() { +libllvm3.8_package() { short_desc+=" - runtime library" pkg_install() { - vmove usr/lib/libLLVM-${version%.*}.so - vmove usr/lib/libLLVM-${version}.so + vmove "usr/lib/libLLVM-*.so*" } }