The package rpms/nodejs-undici.git has added or updated architecture specific content in
its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/nodejs-undici.git/commit/?id=6042....
Change:
+ExclusiveArch: %{ix86} x86_64 aarch64 ppc64le riscv64 noarch
Thanks.
Full change:
============
commit 28b0a22f39d938325d30665b46d57860fdb96f4e
Author: Zephyr Lykos <git(a)mochaa.ws>
Date: Tue Jan 30 15:29:19 2024 +0100
Load WASM from .wasm files
This is an adjusted version of the PR listed below,
with the actual patch replaced by the version
merged into undici upstream:
https://github.com/nodejs/undici/pull/2643
Merges:
https://src.fedoraproject.org/rpms/nodejs-undici/pull-request/3
Related: rhbz#2259320
diff --git a/0002-Support-building-for-externally-shared-js-builtins-2.patch
b/0002-Support-building-for-externally-shared-js-builtins-2.patch
new file mode 100644
index 0000000..94608d0
--- /dev/null
+++ b/0002-Support-building-for-externally-shared-js-builtins-2.patch
@@ -0,0 +1,155 @@
+From 834aec2a4fba9d4b734862530f465dcf90a998bb Mon Sep 17 00:00:00 2001
+From: Zephyr Lykos <self(a)mochaa.ws>
+Date: Sun, 28 Jan 2024 18:50:22 +0800
+Subject: [PATCH] Support building for externally shared js builtins (#2643)
+
+Signed-off-by: rpm-build <rpm-build>
+---
+ CONTRIBUTING.md | 10 ++++++++++
+ build/wasm.js | 41 ++++++++++++++++++++++++++++++-----------
+ lib/client.js | 4 ++--
+ package.json | 1 +
+ 4 files changed, 43 insertions(+), 13 deletions(-)
+
+diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
+index 3a7f3ff..7a91026 100644
+--- a/CONTRIBUTING.md
++++ b/CONTRIBUTING.md
+@@ -6,6 +6,7 @@
+ * [Test](#test)
+ * [Coverage](#coverage)
+ * [Update `WPTs`](#update-wpts)
++ * [Building for externally shared node builtins](#external-builds)
+ * [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin)
+ * [Moderation Policy](#moderation-policy)
+
+@@ -165,6 +166,15 @@ npm run test
+ npm run coverage
+ ```
+
++<a id="external-builds"></a>
++### Building for externally shared node builtins
++
++If you are packaging `undici` for a distro, this might help if you would like to use
++an unbundled version instead of bundling one in `libnode.so`.
++
++To enable this, pass `EXTERNAL_PATH=/path/to/global/node_modules/undici` to
`build/wasm.js`.
++You shall also pass this path to `--shared-builtin-undici/undici-path` in Node.js's
`configure.py`.
++
+ <a id="developers-certificate-of-origin"></a>
+ ## Developer's Certificate of Origin 1.1
+
+diff --git a/build/wasm.js b/build/wasm.js
+index 2b63f3c..1104cfe 100644
+--- a/build/wasm.js
++++ b/build/wasm.js
+@@ -2,7 +2,7 @@
+
+ const { execSync } = require('child_process')
+ const { writeFileSync, readFileSync } = require('fs')
+-const { join, resolve } = require('path')
++const { join, resolve, basename } = require('path')
+
+ const ROOT = resolve(__dirname, '../')
+ const WASM_SRC = resolve(__dirname, '../deps/llhttp')
+@@ -15,6 +15,8 @@ let WASM_CFLAGS = process.env.WASM_CFLAGS ||
'--sysroot=/usr/share/wasi-sysroot
+ let WASM_LDFLAGS = process.env.WASM_LDFLAGS || ''
+ const WASM_LDLIBS = process.env.WASM_LDLIBS || ''
+
++const EXTERNAL_PATH = process.env.EXTERNAL_PATH
++
+ // These are relevant for undici and should not be overridden
+ WASM_CFLAGS += ' -Ofast -fno-exceptions -fvisibility=hidden
-mexec-model=reactor'
+ WASM_LDFLAGS += ' -Wl,-error-limit=0 -Wl,-O3 -Wl,--lto-O3 -Wl,--strip-all'
+@@ -60,6 +62,23 @@ if (hasApk) {
+ writeFileSync(join(WASM_OUT, 'wasm_build_env.txt'), buildInfo)
+ }
+
++const writeWasmChunk = EXTERNAL_PATH
++ ? (path, dest) => {
++ const base64 = readFileSync(join(WASM_OUT, path)).toString('base64')
++ writeFileSync(join(WASM_OUT, dest), `
++const { Buffer } = require('node:buffer')
++
++module.exports = Buffer.from('${base64}', 'base64')
++`)
++ }
++ : (path, dest) => {
++ writeFileSync(join(WASM_OUT, dest), `
++const { fs } = require('node:fs')
++
++module.exports = fs.readFileSync(require.resolve('./${basename(path)}'))
++`)
++ }
++
+ // Build wasm binary
+ execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \
+ ${join(WASM_SRC, 'src')}/*.c \
+@@ -67,11 +86,7 @@ execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \
+ -o ${join(WASM_OUT, 'llhttp.wasm')} \
+ ${WASM_LDLIBS}`, { stdio: 'inherit' })
+
+-const base64Wasm = readFileSync(join(WASM_OUT,
'llhttp.wasm')).toString('base64')
+-writeFileSync(
+- join(WASM_OUT, 'llhttp-wasm.js'),
+- `module.exports = '${base64Wasm}'\n`
+-)
++writeWasmChunk('llhttp.wasm', 'llhttp-wasm.js')
+
+ // Build wasm simd binary
+ execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \
+@@ -80,8 +95,12 @@ execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \
+ -o ${join(WASM_OUT, 'llhttp_simd.wasm')} \
+ ${WASM_LDLIBS}`, { stdio: 'inherit' })
+
+-const base64WasmSimd = readFileSync(join(WASM_OUT,
'llhttp_simd.wasm')).toString('base64')
+-writeFileSync(
+- join(WASM_OUT, 'llhttp_simd-wasm.js'),
+- `module.exports = '${base64WasmSimd}'\n`
+-)
++writeWasmChunk('llhttp_simd.wasm', 'llhttp_simd-wasm.js')
++
++if (EXTERNAL_PATH) {
++ writeFileSync(join(ROOT, 'loader.js'), `
++'use strict'
++
++module.exports =
require('node:module').createRequire('${EXTERNAL_PATH}/loader.js')('./index-fetch.js')
++`)
++}
+diff --git a/lib/client.js b/lib/client.js
+index 22cb390..12798ac 100644
+--- a/lib/client.js
++++ b/lib/client.js
+@@ -493,7 +493,7 @@ async function lazyllhttp () {
+
+ let mod
+ try {
+- mod = await
WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd-wasm.js'),
'base64'))
++ mod = await WebAssembly.compile(require('./llhttp/llhttp_simd-wasm.js'))
+ } catch (e) {
+ /* istanbul ignore next */
+
+@@ -501,7 +501,7 @@ async function lazyllhttp () {
+ // being enabled, but the occurring of this other error
+ // *
https://github.com/emscripten-core/emscripten/issues/11495
+ // got me to remove that check to avoid breaking Node 12.
+- mod = await WebAssembly.compile(Buffer.from(llhttpWasmData ||
require('./llhttp/llhttp-wasm.js'), 'base64'))
++ mod = await WebAssembly.compile(llhttpWasmData ||
require('./llhttp/llhttp-wasm.js'))
+ }
+
+ return await WebAssembly.instantiate(mod, {
+diff --git a/package.json b/package.json
+index 68ee4da..140e852 100644
+--- a/package.json
++++ b/package.json
+@@ -65,6 +65,7 @@
+ "*.d.ts",
+ "index.js",
+ "index-fetch.js",
++ "loader.js",
+ "lib",
+ "types",
+ "docs"
+--
+2.43.0
+
diff --git a/nodejs-undici.spec b/nodejs-undici.spec
index 74698dc..c85504a 100644
--- a/nodejs-undici.spec
+++ b/nodejs-undici.spec
@@ -20,6 +20,7 @@ Source4: %{npm_name}-sources.sh
# Upstream proposal:
https://github.com/nodejs/undici/pull/2403
Patch: 0001-feat-allow-customization-of-build-environment.patch
+Patch: 0002-Support-building-for-externally-shared-js-builtins-2.patch
# Binary artifacts in this package are aimed at the wasm32-wasi
"architecture".
%global _binaries_in_noarch_packages_terminate_build 0
@@ -63,7 +64,7 @@ export WASM_LDFLAGS='-nodefaultlibs'
export WASM_LDLIBS='-lc'
# `npm run build` uses docker; invoke the build script directly
-%{__nodejs} build/wasm.js
+env EXTERNAL_PATH='%{nodejs_sitelib}/%{npm_name}' %{__nodejs} build/wasm.js
npm --offline pack
%install
commit 8573fc267d13a919aa10d9ca209a8223f477d946
Author: Fedora Release Engineering <releng(a)fedoraproject.org>
Date: Thu Jan 25 09:10:56 2024 +0000
Rebuilt for
https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
commit 6042dd12a5756847dd4a08ae7000dd9960c7de00
Author: Yaakov Selkowitz <yselkowi(a)redhat.com>
Date: Mon Jan 15 13:52:46 2024 -0500
Do not attempt to build on s390x
lld is a build requirement of the WASI toolchain but is not yet
supported on s390x (although work is underway upstream). Therefore,
%nodejs_arches cannot be used here until that changes.
diff --git a/nodejs-undici.spec b/nodejs-undici.spec
index 42126cd..74698dc 100644
--- a/nodejs-undici.spec
+++ b/nodejs-undici.spec
@@ -24,7 +24,8 @@ Patch: 0001-feat-allow-customization-of-build-environment.patch
# Binary artifacts in this package are aimed at the wasm32-wasi
"architecture".
%global _binaries_in_noarch_packages_terminate_build 0
BuildArch: noarch
-ExclusiveArch: %{nodejs_arches} noarch
+# would be %%{nodejs_arches} noarch, but lld is not yet supported on s390x
+ExclusiveArch: %{ix86} x86_64 aarch64 ppc64le riscv64 noarch
BuildRequires: clang lld wasi-libc-devel
BuildRequires: nodejs-devel npm
commit 245453d25e1ca8357251c529edf147923e447aca
Author: Fedora Release Engineering <releng(a)fedoraproject.org>
Date: Sun Jan 21 09:49:03 2024 +0000
Rebuilt for
https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild