diff --git a/0001-Use-system-compatible-include-path-for-xxhash.h.patch b/0001-Use-system-compatible-include-path-for-xxhash.h.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7ad93f8c618968941714663d028627d20c4bf5f --- /dev/null +++ b/0001-Use-system-compatible-include-path-for-xxhash.h.patch @@ -0,0 +1,44 @@ +From ad248de144dd4369b785531a758c5aefab13dca4 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Christoph Erhardt +Date: Sat, 6 Aug 2022 09:18:54 +0200 +Subject: [PATCH 1/2] Use system-compatible include path for `xxhash.h` + +Distributors that build mold against the system-provided xxHash package +expect its header file `xxhash.h` in the top-level include directory, +not in an `xxhash` subdirectory. Adjust the include path and the +`#include` directive accordingly. +--- + CMakeLists.txt | 2 ++ + common/common.h | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 54c4c86c..635c535b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -197,6 +197,8 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.md") + set(MOLD_IS_SOLD ON) + endif() + ++target_include_directories(mold PRIVATE third-party/xxhash) ++ + # We always use Clang to build mold on Windows. MSVC can't compile mold. + if(WIN32) + if(MSVC AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +diff --git a/common/common.h b/common/common.h +index 5d2f9e20..a5e5ea45 100644 +--- a/common/common.h ++++ b/common/common.h +@@ -32,7 +32,7 @@ + #endif + + #define XXH_INLINE_ALL 1 +-#include "../third-party/xxhash/xxhash.h" ++#include + + #ifdef NDEBUG + # define unreachable() __builtin_unreachable() +-- +2.39.0 + diff --git a/mold-2.4.0.tar.gz b/mold-2.4.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ad64b3b9d4b261fdb845966d24a5d1abc73c1120 Binary files /dev/null and b/mold-2.4.0.tar.gz differ diff --git a/mold.spec b/mold.spec new file mode 100644 index 0000000000000000000000000000000000000000..b20319c5fdc482ff820a1facbbbd5dcb15b3e647 --- /dev/null +++ b/mold.spec @@ -0,0 +1,86 @@ +%bcond_with ctest + +Name: mold +Version: 2.4.0 +Release: 1 +Summary: A Modern Linker (mold) +License: MIT +URL: https://github.com/rui314/mold +Source: https://github.com/rui314/mold/archive/v%{version}/mold-%{version}.tar.gz + +ExclusiveArch: x86_64 aarch64 riscv64 +BuildRequires: cmake +BuildRequires: gcc +BuildRequires: gcc-c++ >= 10 +BuildRequires: openssl-devel +BuildRequires: grep +BuildRequires: python3 +BuildRequires: xxhash-devel +BuildRequires: zlib-devel +BuildRequires: libzstd +BuildRequires: libzstd-devel + +# Required by bundled oneTBB +BuildRequires: hwloc-devel + + +# following pkgs are only required for the test +BuildRequires: clang +BuildRequires: gdb +BuildRequires: glibc-devel +BuildRequires: libstdc++-static +BuildRequires: libdwarf-tools +BuildRequires: llvm +BuildRequires: perl +# API-incompatible with older tbb 2020.3 currently shipped by openEuler +Provides: bundled(tbb) = 2021.10 + +Patch0: tbb-strip-werror.patch + +# Allow building against the system-provided `xxhash.h` +Patch1: 0001-Use-system-compatible-include-path-for-xxhash.h.patch + +%define build_args -DMOLD_USE_MIMALLOC=OFF + +%description +mold is a faster drop-in replacement for existing Unix linkers. +It is several times faster than the LLVM lld linker. +mold is designed to increase developer productivity by reducing +build time, especially in rapid debug-edit-rebuild cycles. + +%prep +%autosetup -p1 +# Prefer system xxhash/zlib/zstd instead of bundled one +rm -r third-party/{xxhash,zlib,zstd} + +%build +%set_build_flags +mkdir "%{_vpath_builddir}" +%cmake -B "%{_vpath_builddir}" %{build_args} +/usr/bin/cmake --build "%{_vpath_builddir}" "%{?_smp_mflags}" --verbose + +%check +%if %{with ctest} +pushd "%{_vpath_builddir}" +/usr/bin/ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} || true +popd +%endif + +%install +DESTDIR="%{buildroot}" /usr/bin/cmake --install "%{_vpath_builddir}" +chmod +x %{buildroot}%{_libdir}/mold/mold-wrapper.so + +%files +%license %{_docdir}/mold/LICENSE +%license %{_docdir}/mold/LICENSE.third-party +%{_bindir}/mold +%{_bindir}/ld.mold +%{_libdir}/mold/mold-wrapper.so +%{_libexecdir}/mold +%{_libexecdir}/mold/ld +%{_mandir}/man1/ld.mold.1* +%{_mandir}/man1/mold.1* + +%changelog +* Sun Feb 04 2024 jchzhou - 2.4.0-1 +- Init package \ No newline at end of file diff --git a/tbb-strip-werror.patch b/tbb-strip-werror.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3aeee33c46a576d4fff93fe26433c3b43f1a519 --- /dev/null +++ b/tbb-strip-werror.patch @@ -0,0 +1,28 @@ +From bf1642f5e36b006a476805bfa98b735dbbdbb568 Mon Sep 17 00:00:00 2001 +From: jchzhou +Date: Tue, 27 Sep 2022 19:36:44 +0800 +Subject: [PATCH] tbb-strip-werror + +--- + third-party/tbb/cmake/compilers/GNU.cmake | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/third-party/tbb/cmake/compilers/GNU.cmake b/third-party/tbb/cmake/compilers/GNU.cmake +index 733843e..aef6b67 100644 +--- a/third-party/tbb/cmake/compilers/GNU.cmake ++++ b/third-party/tbb/cmake/compilers/GNU.cmake +@@ -44,11 +44,6 @@ if (NOT MINGW) + set(TBB_COMMON_LINK_LIBS dl) + endif() + +-# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled. +-if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag) +- tbb_remove_compile_flag(-Werror) +-endif() +- + if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel) + # gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime + set(TBB_DSE_FLAG $<$>:-flifetime-dse=1>) +-- +2.37.3 +