Commits:
-
76054058
by Pier Angelo Vendrame at 2023-03-03T18:42:49+01:00
Bug 40750: Solve rlbox reproducibility problems
The wasi-sandbox project was not reproducible, because libc.a was
filled in a non-deterministic order.
Its Makefile contains some wildcards, but adding a sort to them was not
enough to build libc.a deterministically.
After fixing this problem, Firefox build issue disappears, too.
Upstream issue: https://github.com/WebAssembly/wasi-libc/issues/398
4 changed files:
Changes:
projects/wasi-sysroot/0001-Sort-the-object-list-passed-to-ar-in-the-Makefile.patch
|
1
|
+From ef21e4f17e104a34e7db89215db567cddd48832d Mon Sep 17 00:00:00 2001
|
|
2
|
+From: Pier Angelo Vendrame <pierov@xxxxxxxxxxxxxx>
|
|
3
|
+Date: Wed, 1 Mar 2023 10:19:50 +0100
|
|
4
|
+Subject: [PATCH] Sort the object list passed to ar in the Makefile.
|
|
5
|
+
|
|
6
|
+This makes builds reproducible.
|
|
7
|
+---
|
|
8
|
+ Makefile | 10 +++++-----
|
|
9
|
+ 1 file changed, 5 insertions(+), 5 deletions(-)
|
|
10
|
+
|
|
11
|
+diff --git a/Makefile b/Makefile
|
|
12
|
+index c31e3d7..f350ecb 100644
|
|
13
|
+--- a/Makefile
|
|
14
|
++++ b/Makefile
|
|
15
|
+@@ -488,13 +488,13 @@ $(SYSROOT_LIB)/libwasi-emulated-signal.a: $(LIBWASI_EMULATED_SIGNAL_OBJS) $(LIBW
|
|
16
|
+ %.a:
|
|
17
|
+ @mkdir -p "$(@D)"
|
|
18
|
+ # On Windows, the commandline for the ar invocation got too long, so it needs to be split up.
|
|
19
|
+- $(AR) crs $@ $(wordlist 1, 199, $^)
|
|
20
|
+- $(AR) crs $@ $(wordlist 200, 399, $^)
|
|
21
|
+- $(AR) crs $@ $(wordlist 400, 599, $^)
|
|
22
|
+- $(AR) crs $@ $(wordlist 600, 799, $^)
|
|
23
|
++ $(AR) crs $@ $(wordlist 1, 199, $(sort $^))
|
|
24
|
++ $(AR) crs $@ $(wordlist 200, 399, $(sort $^))
|
|
25
|
++ $(AR) crs $@ $(wordlist 400, 599, $(sort $^))
|
|
26
|
++ $(AR) crs $@ $(wordlist 600, 799, $(sort $^))
|
|
27
|
+ # This might eventually overflow again, but at least it'll do so in a loud way instead of
|
|
28
|
+ # silently dropping the tail.
|
|
29
|
+- $(AR) crs $@ $(wordlist 800, 100000, $^)
|
|
30
|
++ $(AR) crs $@ $(wordlist 800, 100000, $(sort $^))
|
|
31
|
+
|
|
32
|
+ $(MUSL_PRINTSCAN_OBJS): CFLAGS += \
|
|
33
|
+ -D__wasilibc_printscan_no_long_double \
|
|
34
|
+--
|
|
35
|
+2.39.2
|
|
36
|
+ |
projects/wasi-sysroot/build
... |
... |
@@ -28,6 +28,9 @@ mv clang-source llvm-project |
28
|
28
|
export LLVM_HOME=$(pwd)/llvm-project
|
29
|
29
|
tar -xf $rootdir/[% c('input_files_by_name/wasi-libc') %]
|
30
|
30
|
mv wasi-libc-* wasi-libc
|
|
31
|
+pushd wasi-libc
|
|
32
|
+patch -p1 < "$rootdir/0001-Sort-the-object-list-passed-to-ar-in-the-Makefile.patch"
|
|
33
|
+popd
|
31
|
34
|
popd
|
32
|
35
|
|
33
|
36
|
# What follows has been copied from Firefox's
|
... |
... |
@@ -53,11 +56,14 @@ cat > 'version.sh' << EOF |
53
|
56
|
echo '[% c("abbrev") %]'
|
54
|
57
|
EOF
|
55
|
58
|
|
56
|
|
-# Build wasi-libc, libc++ and libc++abi.
|
|
59
|
+# Build wasi-libc, and re-pack it, to make sure we get a deterministic output.
|
|
60
|
+make PREFIX=/wasi build/wasi-libc.BUILT
|
|
61
|
+
|
|
62
|
+# We need to compile compiler-rt before building libc++ and libc++abi, because
|
|
63
|
+# we need to inject it to Clang.
|
57
|
64
|
make \
|
58
|
65
|
LLVM_PROJ_DIR=$LLVM_HOME \
|
59
|
66
|
PREFIX=/wasi \
|
60
|
|
- build/wasi-libc.BUILT \
|
61
|
67
|
build/compiler-rt.BUILT \
|
62
|
68
|
NINJA_FLAGS='-j[% c("num_procs") %]'
|
63
|
69
|
|
... |
... |
@@ -66,6 +72,7 @@ rtdir="build/llvm/lib/clang/$(ls build/llvm/lib/clang)/lib/wasi" |
66
|
72
|
mkdir -p "$rtdir"
|
67
|
73
|
cp build/compiler-rt/lib/wasi/libclang_rt.builtins-wasm32.a "$rtdir/"
|
68
|
74
|
|
|
75
|
+# Now we can finally build libc++ and libc++abi.
|
69
|
76
|
make \
|
70
|
77
|
LLVM_PROJ_DIR=$LLVM_HOME \
|
71
|
78
|
PREFIX=/wasi \
|
projects/wasi-sysroot/config
... |
... |
@@ -33,3 +33,4 @@ input_files: |
33
|
33
|
project: wasi-config
|
34
|
34
|
- name: wasi-libc
|
35
|
35
|
project: wasi-libc
|
|
36
|
+ - filename: '0001-Sort-the-object-list-passed-to-ar-in-the-Makefile.patch' |
rbm.conf
... |
... |
@@ -170,7 +170,7 @@ var: |
170
|
170
|
- zh-rCN
|
171
|
171
|
- zh-rTW
|
172
|
172
|
|
173
|
|
- rlbox: 0
|
|
173
|
+ rlbox: 1
|
174
|
174
|
|
175
|
175
|
sign_build: '[% ENV.RBM_SIGN_BUILD %]'
|
176
|
176
|
sign_build_gpg_opts: '[% ENV.RBM_GPG_OPTS %]'
|
|