Compare commits

..

No commits in common. "rawhide" and "f37" have entirely different histories.

9 changed files with 171 additions and 56 deletions

3
.gitignore vendored
View file

@ -1,2 +1 @@
/wasi-libc-wasi-sdk-*.tar.gz
/wasi-libc-*-build/
/wasi-libc-wasi-sdk-20.tar.gz

View file

@ -0,0 +1,76 @@
From 112b521d2f64f8e812e6f40d7cde46e47d704f3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= <jstanek@redhat.com>
Date: Mon, 29 Aug 2022 15:07:34 +0200
Subject: [PATCH 1/3] 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 <jstanek@redhat.com>
Signed-off-by: rpm-build <rpm-build>
---
Makefile | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index f350ecb..9ef000b 100644
--- a/Makefile
+++ b/Makefile
@@ -583,6 +583,9 @@ include_dirs:
# Remove selected header files.
$(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
+ # Mark this rule as done
+ touch $@
+
startup_files: include_dirs $(LIBC_BOTTOM_HALF_CRT_OBJS)
#
# Install the startup files (crt1.o etc).
@@ -590,6 +593,9 @@ startup_files: include_dirs $(LIBC_BOTTOM_HALF_CRT_OBJS)
mkdir -p "$(SYSROOT_LIB)" && \
cp $(LIBC_BOTTOM_HALF_CRT_OBJS) "$(SYSROOT_LIB)"
+ # Mark this rule finished
+ touch $@
+
libc: include_dirs \
$(SYSROOT_LIB)/libc.a \
$(SYSROOT_LIB)/libc-printscan-long-double.a \
@@ -599,6 +605,8 @@ libc: include_dirs \
$(SYSROOT_LIB)/libwasi-emulated-getpid.a \
$(SYSROOT_LIB)/libwasi-emulated-signal.a
+ touch $@
+
finish: startup_files libc
#
# Create empty placeholder libraries.
@@ -611,6 +619,8 @@ finish: startup_files libc
# The build succeeded! The generated sysroot is in $(SYSROOT).
#
+ touch $@
+
# The check for defined and undefined symbols expects there to be a heap
# alloctor (providing malloc, calloc, free, etc). Skip this step if the build
# is done without a malloc implementation.
@@ -715,5 +725,6 @@ install: finish
clean:
$(RM) -r "$(OBJDIR)"
$(RM) -r "$(SYSROOT)"
+ $(RM) include_dirs startup_files libc finish
-.PHONY: default startup_files libc finish install include_dirs clean
+.PHONY: default install clean
--
2.41.0

View file

@ -0,0 +1,29 @@
From bac6be2aaa57cb26daddaac241151f8d43555228 Mon Sep 17 00:00:00 2001
From: Josh Stone <cuviper@gmail.com>
Date: Fri, 23 Jun 2023 13:24:52 -0700
Subject: [PATCH 2/3] Use -fno-strict-aliasing for emmalloc (#424)
Signed-off-by: rpm-build <rpm-build>
---
Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Makefile b/Makefile
index 9ef000b..c42f68e 100644
--- a/Makefile
+++ b/Makefile
@@ -560,6 +560,11 @@ $(LIBC_TOP_HALF_ALL_OBJS) $(MUSL_PRINTSCAN_LONG_DOUBLE_OBJS) $(MUSL_PRINTSCAN_NO
$(LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS): CFLAGS += \
-I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
+# emmalloc uses a lot of pointer type-punning, which is UB under strict aliasing,
+# and this was found to have real miscompilations in wasi-libc#421.
+$(EMMALLOC_OBJS): CFLAGS += \
+ -fno-strict-aliasing
+
include_dirs:
#
# Install the include files.
--
2.41.0

View file

@ -0,0 +1,37 @@
From 8951be3fed5a9723db262e08aa1be708213ae9b5 Mon Sep 17 00:00:00 2001
From: Mike Hommey <mh@glandium.org>
Date: Wed, 21 Jun 2023 02:47:19 +0900
Subject: [PATCH 3/3] Adjust Makefile for LLVM trunk (17) as of 2023-06-18
(#422)
https://github.com/llvm/llvm-project/commit/7dd387d2971d7759cadfffeb2082439f6c7ddd49
added a bunch of __FPCLASS_* macros.
Signed-off-by: rpm-build <rpm-build>
---
Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile
index c42f68e..705ab89 100644
--- a/Makefile
+++ b/Makefile
@@ -686,6 +686,7 @@ check-symbols: startup_files libc
@#
@# TODO: Filter out __NO_MATH_ERRNO_ and a few __*WIDTH__ that are new to clang 14.
@# TODO: Filter out __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* that are new to clang 16.
+ @# TODO: Filter out __FPCLASS_* that are new to clang 17.
@# 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
@@ -717,6 +718,7 @@ check-symbols: startup_files libc
| sed -e 's/__GNUC_VA_LIST $$/__GNUC_VA_LIST 1/' \
| grep -v '^#define __\(BOOL\|INT_\(LEAST\|FAST\)\(8\|16\|32\|64\)\|INT\|LONG\|LLONG\|SHRT\)_WIDTH__' \
| grep -v '^#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_\(1\|2\|4\|8\)' \
+ | grep -v '^#define __FPCLASS_' \
> "$(SYSROOT_SHARE)/predefined-macros.txt"
# Check that the computed metadata matches the expected metadata.
--
2.41.0

View file

@ -2,15 +2,8 @@
Standard C library implementation for WebAssembly System Interface.
## Quick How-to
## Quick How-to use
```
$ clang --target=wasm32-wasi --sysroot=/usr/wasm32-wasi -nodefaultlibs -lc -o hello hello.c
$ clang --target=wasm32-wasi ...
```
Important flags:
* `--target=wasm32-wasi` specifies the compilation architecture (WASM System Interface).
* `--sysroot=/usr/wasm32-wasi` tells clang where the library files are.
* `-nodefaultlibs` disables linking of libc and libcompiler-rt (the latter is not available).
* `-lc` re-enables linking of libc.

View file

@ -1,6 +1,6 @@
--- !Policy # testing repository
product_versions:
- fedora-rawhide
- fedora-*
decision_contexts: [bodhi_update_push_testing]
subject_type: koji_build
rules:
@ -10,7 +10,7 @@ rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.installability.functional}
--- !Policy # stable repository
product_versions:
- fedora-rawhide
- fedora-*
decision_contexts: [bodhi_update_push_stable]
subject_type: koji_build
rules:
@ -19,22 +19,3 @@ rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.rpminspect.static-analysis}
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.installability.functional}
...
--- !Policy # testing repository
product_versions:
- fedora-*
decision_contexts: [bodhi_update_push_testing]
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.rpminspect.static-analysis}
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.installability.functional}
--- !Policy # stable repository
product_versions:
- fedora-*
decision_contexts: [bodhi_update_push_stable]
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.rpminspect.static-analysis}
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.installability.functional}
...

View file

@ -1 +1 @@
SHA512 (wasi-libc-wasi-sdk-33.tar.gz) = 7b07509db0ce6817a9616988b8b4ea9c7a87a2318e68ed350a2d0a8f7e839bb97e1cb766a568b008654149835b430a5a090f767ed9db0ca30503c4efe864a49c
SHA512 (wasi-libc-wasi-sdk-20.tar.gz) = e264240dc7dbcf6398c8ca09bc108298f4a8aa955af22de5a3015fbcde81cb09dd83cd48349090082d5de0e8a3dbcf746c7b14657c67657b3f2f1ab28bb9cf05

View file

@ -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")

View file

@ -1,6 +1,6 @@
Name: wasi-libc
Summary: C library implementation for WebAssembly System Interface
Version: 33
Version: 20
Release: %autorelease
License: Apache-2.0 WITH LLVM-exception AND Apache-2.0 AND MIT AND BSD-2-Clause
@ -8,10 +8,18 @@ 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
# Compatibility patches from upstream main
# Allow using artifacts from %%build in %%install instead of recompiling
Patch: 0001-make-don-t-rebuild-files-on-make-install.patch
# emmalloc uses a lot of pointer type-punning, which is UB under strict aliasing.
# https://github.com/WebAssembly/wasi-libc/pull/424
Patch: 0002-Use-fno-strict-aliasing-for-emmalloc-424.patch
# New constants in clang 17 that should not be checked
Patch: 0003-Adjust-Makefile-for-LLVM-trunk-17-as-of-2023-06-18-4.patch
# This contains parts of the musl C library; specify as bundled so we get notified about potential vulnerabilities
%global musl_version 1.2.5
%global musl_version 1.2.3
# Although these packages provide binary files, they are not targeted
# for the build platform, but for wasm32-wasi.
@ -21,9 +29,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
@ -31,17 +39,14 @@ BuildRequires: llvm >= 10
# See rhbz#2228297 for details.
%global __brp_llvm_compile_lto_elf %{nil}
# brp-strip-static-archive breaks the archive index for wasm
%global __brp_strip_static_archive %{nil}
%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 +76,17 @@ 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}
# brp-strip-static-archive breaks the archive index for wasm
%global __os_install_post %{expand:
%__os_install_post
find %{buildroot}%{wasi_libdir} -type f -regex '.*\\.\\(a\\|rlib\\)' -print -exec llvm-ranlib '{}' ';'
}
%check
# Bundled version checks