From 098c3526bf936beff2c87e6bf696d9a5b2cd8da1 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 13 Apr 2017 19:34:21 +0000 Subject: [PATCH] Initial import (#1432955) --- .gitignore | 1 + ...read-handling-for-out-of-tree-builds.patch | 78 ++++++++++++++++++ lld.spec | 82 +++++++++++++++++++ sources | 1 + 4 files changed, 162 insertions(+) create mode 100644 0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch create mode 100644 lld.spec diff --git a/.gitignore b/.gitignore index e69de29..7bc2df7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/lld-4.0.0.src.tar.xz diff --git a/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch b/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch new file mode 100644 index 0000000..093f3c0 --- /dev/null +++ b/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch @@ -0,0 +1,78 @@ +From 548cd5eb4f45de4ec71b3421a98c9462aed75c91 Mon Sep 17 00:00:00 2001 +From: Eric Fiselier +Date: Fri, 10 Feb 2017 01:59:20 +0000 +Subject: [PATCH] [CMake] Fix pthread handling for out-of-tree builds + +LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects +to correctly link the threading library when needed. Unfortunately +`PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed +and therefore can't be used when configuring out-of-tree builds. This causes +such builds to fail since `pthread` isn't being correctly linked. + +This patch attempts to fix that problem by renaming and exporting +`LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` +because It seemed likely to cause collisions with downstream users of +`LLVMConfig.cmake`. + + +git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@294690 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + COFF/CMakeLists.txt | 2 +- + ELF/CMakeLists.txt | 2 +- + lib/ReaderWriter/MachO/CMakeLists.txt | 2 +- + unittests/CoreTests/CMakeLists.txt | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/COFF/CMakeLists.txt b/COFF/CMakeLists.txt +index 0eebe93..8f24e36 100644 +--- a/COFF/CMakeLists.txt ++++ b/COFF/CMakeLists.txt +@@ -43,7 +43,7 @@ add_lld_library(lldCOFF + + LINK_LIBS + lldCore +- ${PTHREAD_LIB} ++ ${LLVM_PTHREAD_LIB} + + DEPENDS + COFFOptionsTableGen +diff --git a/ELF/CMakeLists.txt b/ELF/CMakeLists.txt +index 5652b93..0d1e5b2 100644 +--- a/ELF/CMakeLists.txt ++++ b/ELF/CMakeLists.txt +@@ -54,7 +54,7 @@ add_lld_library(lldELF + LINK_LIBS + lldConfig + lldCore +- ${PTHREAD_LIB} ++ ${LLVM_PTHREAD_LIB} + + DEPENDS + ELFOptionsTableGen +diff --git a/lib/ReaderWriter/MachO/CMakeLists.txt b/lib/ReaderWriter/MachO/CMakeLists.txt +index 3b06985..5a96d87 100644 +--- a/lib/ReaderWriter/MachO/CMakeLists.txt ++++ b/lib/ReaderWriter/MachO/CMakeLists.txt +@@ -28,7 +28,7 @@ add_lld_library(lldMachO + LINK_LIBS + lldCore + lldYAML +- ${PTHREAD_LIB} ++ ${LLVM_PTHREAD_LIB} + ) + + include_directories(.) +diff --git a/unittests/CoreTests/CMakeLists.txt b/unittests/CoreTests/CMakeLists.txt +index 98405d5..72e7c44 100644 +--- a/unittests/CoreTests/CMakeLists.txt ++++ b/unittests/CoreTests/CMakeLists.txt +@@ -3,5 +3,5 @@ add_lld_unittest(CoreTests + ) + + target_link_libraries(CoreTests +- ${PTHREAD_LIB} ++ ${LLVM_PTHREAD_LIB} + ) +-- +1.8.3.1 + diff --git a/lld.spec b/lld.spec new file mode 100644 index 0000000..dc343e1 --- /dev/null +++ b/lld.spec @@ -0,0 +1,82 @@ +Name: lld +Version: 4.0.0 +Release: 1%{?dist} +Summary: The LLVM Linker + +License: NCSA +URL: http://llvm.org +Source0: http://llvm.org/releases/%{version}/lld-%{version}.src.tar.xz + +Patch0: 0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch + +BuildRequires: cmake +BuildRequires: llvm-static = %{version} +BuildRequires: llvm-devel = %{version} +BuildRequires: ncurses-devel +BuildRequires: zlib-devel +BuildRequires: chrpath + +%description +The LLVM project linker. + +%package devel +Summary: Libraries and header files for LLD + +%description devel +This package contains library and header files needed to develop new native +programs that use the LLD infrastructure. + +%package libs +Summary: LLD shared libraries + +%description libs +Shared libraries for LLD. + +%prep +%autosetup -n %{name}-%{version}.src -p1 + +%build + +mkdir %{_target_platform} +cd %{_target_platform} + +%cmake .. \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 +%else + -DLLVM_LIBDIR_SUFFIX= +%endif + +%make_build + +%install +cd %{_target_platform} +%make_install + +# Remove rpath +chrpath --delete %{buildroot}%{_bindir}/* +chrpath --delete %{buildroot}%{_libdir}/*.so* + +%check +# Need to install llvm utils for check to pass +#cd _build +#make %{?_smp_mflags} check-lld + +%post libs -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig + +%files +%{_bindir}/lld* +%{_bindir}/ld.lld + +%files devel +%{_includedir}/lld +%{_libdir}/liblld*.so + +%files libs +%{_libdir}/liblld*.so.* + +%changelog +* Tue Mar 14 2017 Tom Stellard - 4.0.0-1 +- lld 4.0.0 Final Release diff --git a/sources b/sources index e69de29..123e17b 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +SHA512 (lld-4.0.0.src.tar.xz) = 66b2c9cc57f5e94ad7e7da1b1bcc08cbbaee1b55c6efa64b2424b9d8776c70b842c2a31c188a99b447be6a8621ad1b1e70573bbfcf5d6b1aa986b03b3b3350f3