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..dd228c5a87606a4ad061e5e51bc6f8a51feee329 --- /dev/null +++ b/0001-Use-system-compatible-include-path-for-xxhash.h.patch @@ -0,0 +1,44 @@ +From 2f95fc3b3c85a078c04fd65c2d16c96310f45daf Mon Sep 17 00:00:00 2001 +Message-ID: <2f95fc3b3c85a078c04fd65c2d16c96310f45daf.1709318446.git.github@sicherha.de> +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 c6d00990..82f338f9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -212,6 +212,8 @@ else() + mold_add_tbb() + 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 b7e002a6..5ddc9213 100644 +--- a/common/common.h ++++ b/common/common.h +@@ -34,7 +34,7 @@ + #endif + + #define XXH_INLINE_ALL 1 +-#include "../third-party/xxhash/xxhash.h" ++#include + + #ifdef NDEBUG + # define unreachable() __builtin_unreachable() +-- +2.44.0 + diff --git a/0002-build-blake3-as-static.patch b/0002-build-blake3-as-static.patch new file mode 100644 index 0000000000000000000000000000000000000000..0fb75892f927d6cd3502f07589f64dc58fb40a35 --- /dev/null +++ b/0002-build-blake3-as-static.patch @@ -0,0 +1,29 @@ +Src: https://build.opensuse.org/request/show/1118582 +By Martin Liška + +From 3b14fbc71c42b312f77ac4612b28b3e20462e02b Mon Sep 17 00:00:00 2001 +From: jchzhou +Date: Tue, 19 Mar 2024 17:14:37 +0800 +Subject: [PATCH] build blake3 as static + +Signed-off-by: jchzhou +--- + third-party/blake3/c/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/third-party/blake3/c/CMakeLists.txt b/third-party/blake3/c/CMakeLists.txt +index 3190eff..3e8c763 100644 +--- a/third-party/blake3/c/CMakeLists.txt ++++ b/third-party/blake3/c/CMakeLists.txt +@@ -32,7 +32,7 @@ set(BLAKE3_X86_NAMES i686 x86 X86) + set(BLAKE3_ARMv8_NAMES aarch64 AArch64 arm64 ARM64 armv8 armv8a) + + # library target +-add_library(blake3 ++add_library(blake3 STATIC + blake3.c + blake3_dispatch.c + blake3_portable.c +-- +2.44.0 + diff --git a/mold-2.30.0.tar.gz b/mold-2.30.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..23631863546050b159afd02fcdff6881af0f0e44 Binary files /dev/null and b/mold-2.30.0.tar.gz differ diff --git a/mold.spec b/mold.spec new file mode 100644 index 0000000000000000000000000000000000000000..1be13e2ea836d7ffc8cfc4926fbf1f1e2765ec02 --- /dev/null +++ b/mold.spec @@ -0,0 +1,86 @@ +%bcond_with ctest + +Name: mold +Version: 2.30.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}/%{name}-%{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.11 + +# Allow building against the system-provided `xxhash.h` +Patch0: 0001-Use-system-compatible-include-path-for-xxhash.h.patch + +# Build blake3 as static +Patch1: 0002-build-blake3-as-static.patch + +%define build_args -DMOLD_USE_MIMALLOC=OFF -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 +* Tue Mar 19 2024 jchzhou - 2.30.0-1 +- Init package \ No newline at end of file