From 84ae0c2812e904c1e3f9373edae8a641945827cf649fd492fe38f49d8e4d9be2 Mon Sep 17 00:00:00 2001 From: Martin Sirringhaus Date: Wed, 25 Sep 2024 13:17:49 +0000 Subject: [PATCH] - Update to version (wasi-sdk-)22. * Add support for some network APIs. - Rebase workaround-broken-makefile.patch. - Backport upstream patches to fix build with Clang 19: * ignore-gcc-con-destructive-size-macros.patch * ignore-norm-max-macros.patch * ignore-stdc-embed-macros.patch * ignore-wasm-macros-indirect-function-table.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:rust/wasi-libc?expand=0&rev=17 --- .gitattributes | 23 +++++++ .gitignore | 1 + ignore-gcc-con-destructive-size-macros.patch | 31 +++++++++ ignore-norm-max-macros.patch | 30 +++++++++ ignore-stdc-embed-macros.patch | 30 +++++++++ ...-wasm-macros-indirect-function-table.patch | 44 ++++++++++++ wasi-libc-21.tar.gz | 3 + wasi-libc-22.tar.gz | 3 + wasi-libc-rpmlintrc | 12 ++++ wasi-libc.changes | 67 +++++++++++++++++++ wasi-libc.spec | 64 ++++++++++++++++++ workaround-broken-makefile.patch | 14 ++++ 12 files changed, 322 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 ignore-gcc-con-destructive-size-macros.patch create mode 100644 ignore-norm-max-macros.patch create mode 100644 ignore-stdc-embed-macros.patch create mode 100644 ignore-wasm-macros-indirect-function-table.patch create mode 100644 wasi-libc-21.tar.gz create mode 100644 wasi-libc-22.tar.gz create mode 100644 wasi-libc-rpmlintrc create mode 100644 wasi-libc.changes create mode 100644 wasi-libc.spec create mode 100644 workaround-broken-makefile.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/ignore-gcc-con-destructive-size-macros.patch b/ignore-gcc-con-destructive-size-macros.patch new file mode 100644 index 0000000..ea33aef --- /dev/null +++ b/ignore-gcc-con-destructive-size-macros.patch @@ -0,0 +1,31 @@ +From 13ed98026d1e6f96fa4c0efce3ff849e3040fca3 Mon Sep 17 00:00:00 2001 +From: Mike Hommey +Date: Tue, 30 Apr 2024 06:46:03 +0900 +Subject: [PATCH] Adjust Makefile for LLVM trunk (19) as of 2024-04-26 (#492) + +https://github.com/llvm/llvm-project/commit/72c373bfdc9860b3d75e72c219b2c81c90bc4364 +dded __GCC_(CON|DE)STRUCTIVE_SIZE macros. +--- + Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Makefile b/Makefile +index 2f9e9fde..f9fd3030 100644 +--- a/Makefile ++++ b/Makefile +@@ -873,6 +873,7 @@ check-symbols: startup_files libc + @# TODO: Filter out __FPCLASS_* that are new to clang 17. + @# TODO: Filter out __FLT128_* that are new to clang 18. + @# TODO: Filter out __MEMORY_SCOPE_* that are new to clang 18. ++ @# TODO: Filter out __GCC_(CON|DE)STRUCTIVE_SIZE that are new to clang 19. + @# 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 +@@ -907,6 +908,7 @@ check-symbols: startup_files libc + | grep -v '^#define __FPCLASS_' \ + | grep -v '^#define __FLT128_' \ + | grep -v '^#define __MEMORY_SCOPE_' \ ++ | grep -v '^#define __GCC_\(CON\|DE\)STRUCTIVE_SIZE' \ + | grep -v '^#define NDEBUG' \ + | grep -v '^#define __OPTIMIZE__' \ + | grep -v '^#define assert' \ diff --git a/ignore-norm-max-macros.patch b/ignore-norm-max-macros.patch new file mode 100644 index 0000000..aec908b --- /dev/null +++ b/ignore-norm-max-macros.patch @@ -0,0 +1,30 @@ +From d43dcc63d26013264bb58241e53bde9318349443 Mon Sep 17 00:00:00 2001 +From: Mike Hommey +Date: Fri, 12 Jul 2024 08:11:35 +0900 +Subject: [PATCH] Adjust Makefile for LLVM trunk (19) as of 2024-07-10 (#512) + +https://github.com/llvm/llvm-project/commit/0e7590a25cd2e49c5849cc7d2facd5810f8900ce +--- + Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Makefile b/Makefile +index 0d2a3144..5e6e7734 100644 +--- a/Makefile ++++ b/Makefile +@@ -872,6 +872,7 @@ check-symbols: startup_files libc + @# TODO: Filter out __MEMORY_SCOPE_* that are new to clang 18. + @# 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: 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 +@@ -912,6 +913,7 @@ check-symbols: startup_files libc + | grep -v '^#define __MEMORY_SCOPE_' \ + | grep -v '^#define __GCC_\(CON\|DE\)STRUCTIVE_SIZE' \ + | grep -v '^#define __STDC_EMBED_' \ ++ | grep -v '^#define __\(DBL\|FLT\|LDBL\)_NORM_MAX__' \ + | grep -v '^#define NDEBUG' \ + | grep -v '^#define __OPTIMIZE__' \ + | grep -v '^#define assert' \ diff --git a/ignore-stdc-embed-macros.patch b/ignore-stdc-embed-macros.patch new file mode 100644 index 0000000..943f13a --- /dev/null +++ b/ignore-stdc-embed-macros.patch @@ -0,0 +1,30 @@ +From 320bbbcced68ce8e564b0dc4c8f80a5a5ad21a9c Mon Sep 17 00:00:00 2001 +From: Mike Hommey +Date: Sat, 22 Jun 2024 01:49:33 +0900 +Subject: [PATCH] Adjust Makefile for LLVM trunk (19) as of 2024-06-20 (#509) + +https://github.com/llvm/llvm-project/commit/41c6e4379204ffc00948edd33d59ba5ebbceaba2 +--- + Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Makefile b/Makefile +index 4192ecbb..0d2a3144 100644 +--- a/Makefile ++++ b/Makefile +@@ -871,6 +871,7 @@ check-symbols: startup_files libc + @# TODO: Filter out __FLT128_* that are new to clang 18. + @# TODO: Filter out __MEMORY_SCOPE_* that are new to clang 18. + @# 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: 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 +@@ -910,6 +911,7 @@ check-symbols: startup_files libc + | grep -v '^#define __FLT128_' \ + | grep -v '^#define __MEMORY_SCOPE_' \ + | grep -v '^#define __GCC_\(CON\|DE\)STRUCTIVE_SIZE' \ ++ | grep -v '^#define __STDC_EMBED_' \ + | grep -v '^#define NDEBUG' \ + | grep -v '^#define __OPTIMIZE__' \ + | grep -v '^#define assert' \ diff --git a/ignore-wasm-macros-indirect-function-table.patch b/ignore-wasm-macros-indirect-function-table.patch new file mode 100644 index 0000000..cb6bf46 --- /dev/null +++ b/ignore-wasm-macros-indirect-function-table.patch @@ -0,0 +1,44 @@ +From 129ee9b64be8724745c4ebd45c21dcdc5fd23e22 Mon Sep 17 00:00:00 2001 +From: Mike Hommey +Date: Wed, 1 May 2024 23:30:33 +0900 +Subject: [PATCH] Adjust Makefile for LLVM trunk (19) as of 2024-04-30 (#493) + +https://github.com/llvm/llvm-project/commit/5bbf1ea8f18d1f99637b7b8bf6b985c186c808f6 +added __wasm_multivalue__ and __wasm_reference_types__, and the latter +also makes libraries reference the undefined __indirect_function_table +symbol, which is provided by the linker. +--- + Makefile | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index f9fd3030..b0407968 100644 +--- a/Makefile ++++ b/Makefile +@@ -836,7 +836,7 @@ check-symbols: startup_files libc + for undef_sym in $$("$(NM)" --undefined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/libc-*.a "$(SYSROOT_LIB)"/*.o \ + |grep ' U ' |sed 's/.* U //' |LC_ALL=C sort |uniq); do \ + grep -q '\<'$$undef_sym'\>' "$(DEFINED_SYMBOLS)" || echo $$undef_sym; \ +- done | grep -E -v "^__mul|__memory_base" > "$(UNDEFINED_SYMBOLS)" ++ done | grep -E -v "^__mul|__memory_base|__indirect_function_table" > "$(UNDEFINED_SYMBOLS)" + grep '^_*imported_wasi_' "$(UNDEFINED_SYMBOLS)" \ + > "$(SYSROOT_LIB)/libc.imports" + +@@ -878,6 +878,8 @@ check-symbols: startup_files libc + @# for older versions. + @# TODO: Undefine __wasm_mutable_globals__ and __wasm_sign_ext__, that are new to + @# clang 16 for -mcpu=generic. ++ @# TODO: Undefine __wasm_multivalue__ and __wasm_reference_types__, that are new to ++ @# clang 19 for -mcpu=generic. + @# TODO: As of clang 16, __GNUC_VA_LIST is #defined without a value. + $(CC) $(CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \ + -isystem $(SYSROOT_INC) \ +@@ -894,6 +896,8 @@ check-symbols: startup_files libc + -U__clang_wide_literal_encoding__ \ + -U__wasm_mutable_globals__ \ + -U__wasm_sign_ext__ \ ++ -U__wasm_multivalue__ \ ++ -U__wasm_reference_types__ \ + -U__GNUC__ \ + -U__GNUC_MINOR__ \ + -U__GNUC_PATCHLEVEL__ \ diff --git a/wasi-libc-21.tar.gz b/wasi-libc-21.tar.gz new file mode 100644 index 0000000..1f61d9b --- /dev/null +++ b/wasi-libc-21.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a2a3e3b120ba1163c57f34ac79c3de720a8355ee3a753d81f1f0c58c4cf6017 +size 1313865 diff --git a/wasi-libc-22.tar.gz b/wasi-libc-22.tar.gz new file mode 100644 index 0000000..fcd14ab --- /dev/null +++ b/wasi-libc-22.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7efede97bd490c336a6fff4252dffaef5247149d74e4208865cd5e59908d529d +size 1410600 diff --git a/wasi-libc-rpmlintrc b/wasi-libc-rpmlintrc new file mode 100644 index 0000000..8a7745d --- /dev/null +++ b/wasi-libc-rpmlintrc @@ -0,0 +1,12 @@ +# Those files ARE arch-independent, but named like they are not (*.a, etc.) so the script is wrong here +addFilter("files-duplicate .*") +addFilter("static-library-without-symtab .*") +addFilter("static-library-without-debuginfo .*") +addFilter("readelf-failed .*") +addFilter("zero-length .*") +addFilter("arch-dependent-file-in-usr-share .*") +addFilter("arch-independent-package-contains-binary-or-object .*") +# There are empty dummy-files in the sysroot +addFilter('lto-no-text-in-archive .*') +addFilter('devel-file-in-non-devel-package .*') + diff --git a/wasi-libc.changes b/wasi-libc.changes new file mode 100644 index 0000000..56b5958 --- /dev/null +++ b/wasi-libc.changes @@ -0,0 +1,67 @@ +------------------------------------------------------------------- +Sat Sep 21 21:39:37 UTC 2024 - Aaron Puchert + +- Update to version (wasi-sdk-)22. + * Add support for some network APIs. +- Rebase workaround-broken-makefile.patch. +- Backport upstream patches to fix build with Clang 19: + * ignore-gcc-con-destructive-size-macros.patch + * ignore-norm-max-macros.patch + * ignore-stdc-embed-macros.patch + * ignore-wasm-macros-indirect-function-table.patch + +------------------------------------------------------------------- +Thu Feb 22 21:05:54 UTC 2024 - Aaron Puchert + +- Update to version (wasi-sdk-)21. + * Compatibility with Clang 18. + * Add shared library support. +- Drop obsolete ignore-fpclass-macros.patch. + +------------------------------------------------------------------- +Tue Feb 20 15:16:08 UTC 2024 - Dominique Leuenberger + +- Use %autosetup macro. Allows to eliminate the usage of deprecated + %patchN + +------------------------------------------------------------------- +Fri Sep 22 17:06:06 UTC 2023 - Aaron Puchert + +- Update to version (wasi-sdk-)20. + * Compatibility with Clang 16. + * Rename triple wasm32-wasi-pthread to wasm32-wasi-threads. + * Implement support for spinlock. + * Improve performance in dlmalloc. +- Rebase workaround-broken-makefile.patch. +- Drop obsolete undefine-gcc-macros.patch. (Has been solved + upstream in gh#WebAssembly/wasi-libc#379.) +- Add ignore-fpclass-macros.patch to ignore __FPCLASS_* macros that + are new with Clang 17. + +------------------------------------------------------------------- +Wed Mar 22 22:23:36 UTC 2023 - Aaron Puchert + +- Update to version (wasi-sdk-)19. +- Rebase workaround-broken-makefile.patch. +- Add undefine-gcc-macros.patch: ignore new macros for now to fix + build with Clang 16. +- Declare the package as noarch: the binaries are for WebAssembly, + not the host architecture. + +------------------------------------------------------------------- +Fri Jul 29 00:34:36 UTC 2022 - William Brown + +- Update services to comply with OBS +- Fix rpmlintrc + +------------------------------------------------------------------- +Wed Apr 20 13:32:28 UTC 2022 - Martin Sirringhaus + +- Add rpmlintrc to suppress errors for now +- Add workaround-broken-makefile.patch for cleaner build/install + separation + +------------------------------------------------------------------- +Wed Apr 20 12:48:58 UTC 2022 - Martin Sirringhaus + +- Initial commit diff --git a/wasi-libc.spec b/wasi-libc.spec new file mode 100644 index 0000000..c259cee --- /dev/null +++ b/wasi-libc.spec @@ -0,0 +1,64 @@ +# +# spec file for package wasi-libc +# +# Copyright (c) 2024 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: wasi-libc +Version: 22 +Release: 0 +Summary: WASI libc implementation for WebAssembly +# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses +License: MIT +URL: https://github.com/WebAssembly/wasi-libc +Source: https://github.com/WebAssembly/wasi-libc/archive/refs/tags/wasi-sdk-%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1: wasi-libc-rpmlintrc +Patch1: workaround-broken-makefile.patch +Patch2: ignore-gcc-con-destructive-size-macros.patch +Patch3: ignore-wasm-macros-indirect-function-table.patch +Patch4: ignore-stdc-embed-macros.patch +Patch5: ignore-norm-max-macros.patch +BuildRequires: clang > 10 +BuildRequires: llvm > 10 +BuildArch: noarch + +%description +WASI libc allows cross platform binaries to be created and executed on a variety of platforms + +%prep +%autosetup -p1 -n wasi-libc-wasi-sdk-%{version} + +%build +export CC=clang +export AR=llvm-ar +export NM=llvm-nm +%make_build + +%install +export CC=clang +export AR=llvm-ar +export NM=llvm-nm +# The makefile is stupid and compiles everything again if we do `make install`, so we +# do it only once +%make_install INSTALL_DIR="%{buildroot}/%{_datadir}/wasi-sysroot" +# brp-15-strip-debug and -ar call system-strip and ar, which are not wasm-aware, so they will break wasm-files +export NO_BRP_AR=true +export NO_BRP_STRIP_DEBUG=true + +%files +%license LICENSE +%{_datadir}/wasi-sysroot/ + +%changelog diff --git a/workaround-broken-makefile.patch b/workaround-broken-makefile.patch new file mode 100644 index 0000000..a5d9915 --- /dev/null +++ b/workaround-broken-makefile.patch @@ -0,0 +1,14 @@ +# Workaround as per https://github.com/WebAssembly/wasi-libc/issues/156 +diff --git a/Makefile b/Makefile +index 2f9e9fd..8318748 100644 +--- a/Makefile ++++ b/Makefile +@@ -917,7 +917,7 @@ check-symbols: startup_files libc + # This ignores whitespace because on Windows the output has CRLF line endings. + diff -wur "$(EXPECTED_TARGET_DIR)" "$(SYSROOT_SHARE)" + +-install: finish ++install: + mkdir -p "$(INSTALL_DIR)" + cp -r "$(SYSROOT)/lib" "$(SYSROOT)/share" "$(SYSROOT)/include" "$(INSTALL_DIR)" +