diff --git a/0001-make-don-t-rebuild-files-on-make-install.patch b/0001-make-don-t-rebuild-files-on-make-install.patch new file mode 100644 index 0000000..0514171 --- /dev/null +++ b/0001-make-don-t-rebuild-files-on-make-install.patch @@ -0,0 +1,71 @@ +From ff153ab204af3a48479ed25d90ad9cc34ad4af49 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= +Date: Mon, 29 Aug 2022 15:07:34 +0200 +Subject: [PATCH] make: don't rebuild files on `make install` +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The original Makefile does not allow for clean separation of build and +install steps, and re-compiles the library on `make install`. + +Using [empty target files][], the re-compilation is skipped on install. +Adapted from [Debian patch][]. + +[empty target files]: https://www.gnu.org/software/make/manual/make.html#Empty-Targets +[Debian patch]: https://salsa.debian.org/rust-team/wasi-libc/-/blob/master/debian/patches/dont-rebuild-install.patch + +Signed-off-by: Jan Staněk +Signed-off-by: rpm-build +--- + Makefile | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 26bdcfa..919fc54 100644 +--- a/Makefile ++++ b/Makefile +@@ -835,6 +835,7 @@ endif + endif + + libc_so: $(INCLUDE_DIRS) $(LIBC_SO) ++ touch $@ + + STATIC_LIBS = \ + $(SYSROOT_LIB)/libc.a \ +@@ -851,6 +852,7 @@ STATIC_LIBS += \ + endif + + libc: $(INCLUDE_DIRS) $(STATIC_LIBS) ++ touch $@ + + DUMMY := m rt pthread crypt util xnet resolv + DUMMY_LIBS := $(patsubst %,$(SYSROOT_LIB)/lib%.a,$(DUMMY)) +@@ -867,6 +869,7 @@ no-check-symbols: $(STARTUP_FILES) libc $(DUMMY_LIBS) + # + # The build succeeded! The generated sysroot is in $(SYSROOT). + # ++ touch $@ + + finish: no-check-symbols + +@@ -1014,6 +1017,8 @@ check-symbols: $(STARTUP_FILES) libc + # This ignores whitespace because on Windows the output has CRLF line endings. + diff -wur "$(EXPECTED_TARGET_DIR)" "$(SYSROOT_SHARE)" + ++ touch $@ ++ + + ##### BINDINGS ################################################################# + # The `bindings` target retrieves the necessary WIT files for the wasi-cli world +@@ -1089,5 +1094,6 @@ clean: + $(RM) -r "$(BINDING_WORK_DIR)" + $(RM) -r "$(OBJDIR)" + $(RM) -r "$(SYSROOT)" ++ $(RM) check-symbols no-check-symbols libc_so libc + +-.PHONY: default libc libc_so finish install clean check-symbols no-check-symbols bindings ++.PHONY: default finish install clean bindings +-- +2.50.1 + diff --git a/0002-Adjust-Makefile-for-LLVM-trunk-20-as-of-2025-01-26-5.patch b/0002-Adjust-Makefile-for-LLVM-trunk-20-as-of-2025-01-26-5.patch new file mode 100644 index 0000000..7bb37f4 --- /dev/null +++ b/0002-Adjust-Makefile-for-LLVM-trunk-20-as-of-2025-01-26-5.patch @@ -0,0 +1,34 @@ +From 293ea3296973c85a02cf7db6a1fe8b9c6d28e941 Mon Sep 17 00:00:00 2001 +From: Mike Hommey +Date: Wed, 29 Jan 2025 08:26:30 +0900 +Subject: [PATCH] Adjust Makefile for LLVM trunk (20) as of 2025-01-26 (#564) + +https://github.com/llvm/llvm-project/commit/33ad474c45e6d7a0de7bc75e15e27cf6cb9ff895 +Signed-off-by: rpm-build +--- + Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Makefile b/Makefile +index c340da4..b14f6cf 100644 +--- a/Makefile ++++ b/Makefile +@@ -893,6 +893,7 @@ check-symbols: $(STARTUP_FILES) libc + @# TODO: Filter out __GCC_(CON|DE)STRUCTIVE_SIZE that are new to clang 19. + @# TODO: Filter out __STDC_EMBED_* that are new to clang 19. + @# TODO: Filter out __*_NORM_MAX__ that are new to clang 19. ++ @# TODO: Filter out __INT*_C() that are new to clang 20. + @# TODO: clang defined __FLT_EVAL_METHOD__ until clang 15, so we force-undefine it + @# for older versions. + @# TODO: Undefine __wasm_mutable_globals__ and __wasm_sign_ext__, that are new to +@@ -943,6 +944,7 @@ check-symbols: $(STARTUP_FILES) libc + | grep -v '^#define __OPTIMIZE__' \ + | grep -v '^#define assert' \ + | grep -v '^#define __NO_INLINE__' \ ++ | grep -v '^#define __U\?INT.*_C(' \ + > "$(SYSROOT_SHARE)/predefined-macros.txt" + + # Check that the computed metadata matches the expected metadata. +-- +2.50.0 + diff --git a/sources b/sources index 04d9551..67250bc 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (wasi-libc-wasi-sdk-33.tar.gz) = 7b07509db0ce6817a9616988b8b4ea9c7a87a2318e68ed350a2d0a8f7e839bb97e1cb766a568b008654149835b430a5a090f767ed9db0ca30503c4efe864a49c +SHA512 (wasi-libc-wasi-sdk-27.tar.gz) = dfc2c36fabf32f465fc833ed0b10efffc9a35c68162ecc3e8d656d1d684d170b734d55e790614d12d925d17f49d60f0d2d01c46cecac941cf62d68eda84df13e diff --git a/wasi-libc.rpmlintrc b/wasi-libc.rpmlintrc deleted file mode 100644 index 70329d5..0000000 --- a/wasi-libc.rpmlintrc +++ /dev/null @@ -1,4 +0,0 @@ -# cross-compilation files are expected -addFilter(r"\barch-independent-package-contains-binary-or-object /usr/wasm32-wasi/.*") -# some header files are empty, and that's expected -addFilter(r"\bzero-length /usr/wasm32-wasi/include/wasm32-wasi/bits/.*\.h") diff --git a/wasi-libc.spec b/wasi-libc.spec index ff2f0a8..db90ea3 100644 --- a/wasi-libc.spec +++ b/wasi-libc.spec @@ -1,6 +1,6 @@ Name: wasi-libc Summary: C library implementation for WebAssembly System Interface -Version: 33 +Version: 27 Release: %autorelease License: Apache-2.0 WITH LLVM-exception AND Apache-2.0 AND MIT AND BSD-2-Clause @@ -8,6 +8,8 @@ URL: https://github.com/WebAssembly/wasi-libc/ Source: %{url}/archive/refs/tags/wasi-sdk-%{version}.tar.gz#/%{name}-wasi-sdk-%{version}.tar.gz Source1: smoke-test.c +# Allow using artifacts from %%build in %%install instead of recompiling +Patch: 0001-make-don-t-rebuild-files-on-make-install.patch # Compatibility patches from upstream main # This contains parts of the musl C library; specify as bundled so we get notified about potential vulnerabilities @@ -21,9 +23,9 @@ Source1: smoke-test.c BuildArch: noarch BuildRequires: clang >= 10 -BuildRequires: cmake >= 3.26 BuildRequires: git-core BuildRequires: llvm >= 10 +BuildRequires: make %global toolchain clang # Re-packaging the static library tends to overwrite files @@ -36,12 +38,13 @@ BuildRequires: llvm >= 10 %global __brp_strip_lto %{nil} # WASI is a specific architecture; host (build machine) arch flags should not apply by default -%global build_cflags -O2 --target=wasm32-wasi -fstack-protector +%global build_cflags --target=wasm32-wasi -fstack-protector # Define cross-compiling prefix %global wasi_prefix %{_prefix}/wasm32-wasi %global wasi_datadir %{wasi_prefix}/share %global wasi_includedir %{wasi_prefix}/include %global wasi_libdir %{wasi_prefix}/lib +%global wasi_make_flags MALLOC_IMPL=emmalloc INSTALL_DIR='%{buildroot}%{wasi_prefix}' SYSROOT='%{_builddir}/sysroot' %global _description %{expand: WASI Libc is a libc for WebAssembly programs built on top of WASI system calls. @@ -71,18 +74,11 @@ Summary: C library for WASI - headers and development files cp -p libc-bottom-half/cloudlibc/LICENSE LICENSE-cloudlibc %build -%cmake \ - -DCMAKE_INSTALL_PREFIX='%{wasi_prefix}' \ - -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ - -DBUILD_SHARED=OFF \ - -DCHECK_SYMBOLS=ON \ - -DMALLOC=emmalloc \ - -DTARGET_TRIPLE=wasm32-wasi -%cmake_build +%make_build %{wasi_make_flags} +make %{?_smp_mflags} %{wasi_make_flags} check-symbols %install -%cmake_install -cp -av -t '%{buildroot}%{wasi_prefix}' '%{__cmake_builddir}/sysroot/share' +%make_install %{wasi_make_flags} %check # Bundled version checks