Skip to content

Commit eb04979

Browse files
firefox/wasi-sdk: upgrade wasi-sdk 21->29
This update is an optional build-time requirement for Firefox 144+ to be able to build some sandboxed libraries. Since the build system was overhauled by upstream, the original recipe was split into two also: one recipe builds the toolchain (which is essentially a WebAssembly-only clang), and the second recipe populates the actual sysroot. Though they use the same main CMakeLists.txt file, the environment is quite different for the two steps, hence the split. One notable change is that building this recipe requires at least Clang 18, which is a bump from the previous Clang 14. Though Kirkstone can still build it, it requires switching to a new meta-clang branch. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
1 parent 8b2696d commit eb04979

12 files changed

+194
-113
lines changed

meta-firefox/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ the kas folder - that contains all the branch/revision information used for test
5555
install it, in case it is missing (e.g. on Debian based systems install `libstdc++-dev` or
5656
on Fedora install `libstdc++-devel`)
5757

58-
By default `disable-sandboxed-libraries` PACKAGECONFIG is *disabled*. This makes the build
59-
somewhat more secure, but it also brings in the wasi-sdk as a build-time dependency, which
60-
does increase the build time. Testing is performed using this dependency, but if you
61-
enable this knob, it can cut off the build time of dependencies quite a bit (for the
62-
price of some security, which you need to decide if it's acceptable for you).
58+
By default `disable-sandboxed-libraries` PACKAGECONFIG is *disabled*. Which means that wasi-sdk
59+
is a build dependency. Starting Firefox 145, wasi-sdk requires at least Clang 18 to be built:
60+
make sure to use kirkstone-clang18 branch of meta-clang. Without wasi-sdk (when `disable-sanboxed-libraries`
61+
PACKAGECONFIG is enabled), Firefox should still build with Clang 14. With ther branches
62+
this restriction is meaningless, since they all use at least Clang 18.
6363

64-
Note: Firefox at least Rust 1.82 from version 137.
64+
Firefox requires at least Rust 1.82 from version 137.
6565

6666
When using meta-rust, make sure to add the following to a bbappend or local.conf:
6767

meta-firefox/conf/post-whinlatter-s-config.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ CORRECT_S = '${@bb.utils.contains_any("LAYERSERIES_CORENAMES", "whinlatter", d.g
1111

1212
S:pn-cbindgen = "${CORRECT_S}"
1313
S:pn-cbindgen-native = "${CORRECT_S}"
14-
S:pn-wasi-sdk-native = "${CORRECT_S}"
14+
S:pn-wasi-sdk-sysroot-native = "${CORRECT_S}"
15+
S:pn-wasi-sdk-toolchain-native = "${CORRECT_S}"
16+
S:pn-wasm-component-ld = "${CORRECT_S}"
17+
S:pn-wasm-component-ld-native = "${CORRECT_S}"

meta-firefox/recipes-browser/firefox/firefox.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ PACKAGECONFIG[system-pipewire] = "--with-system-pipewire,,pipewire,pipewire"
130130
PACKAGECONFIG[system-gbm] = "--with-system-gbm,,virtual/libgbm,libgbm"
131131
PACKAGECONFIG[system-libdrm] = "--with-system-libdrm,,libdrm,libdrm"
132132

133-
DEPENDS:append = '${@bb.utils.contains("PACKAGECONFIG", "disable-sandboxed-libraries", "", " wasi-sdk-native ", d)}'
133+
DEPENDS:append = '${@bb.utils.contains("PACKAGECONFIG", "disable-sandboxed-libraries", "", " wasi-sdk-sysroot-native ", d)}'
134134

135135
LDFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'system-av1', ' -Wl,--undefined-version ', '', d)}"
136136

meta-firefox/recipes-devtools/wasi-sdk/files/0001-allow-compiling-with-cmake-4.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

meta-firefox/recipes-devtools/wasi-sdk/files/0001-disable-exceptions-and-bulk-memory.patch

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 1fdbaaa58d6b816f4280db5de418112b9ff50c48 Mon Sep 17 00:00:00 2001
2+
From: Gyorgy Sarvari <skandigraun@gmail.com>
3+
Date: Wed, 26 Nov 2025 13:15:30 +0100
4+
Subject: [PATCH] don't build wasm-component-ld
5+
6+
wasm-component-ld is fetched from the internet. For OE, it is built
7+
with a separate recipe, no need to build it here also.
8+
9+
Upstream-Status: Inappropriate [oe-specific]
10+
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
11+
---
12+
cmake/wasi-sdk-toolchain.cmake | 20 --------------------
13+
1 file changed, 20 deletions(-)
14+
15+
diff --git a/cmake/wasi-sdk-toolchain.cmake b/cmake/wasi-sdk-toolchain.cmake
16+
index 61481e3..f68d288 100644
17+
--- a/cmake/wasi-sdk-toolchain.cmake
18+
+++ b/cmake/wasi-sdk-toolchain.cmake
19+
@@ -116,26 +116,6 @@ install(DIRECTORY ${wasi_tmp_install}/bin ${wasi_tmp_install}/lib ${wasi_tmp_ins
20+
USE_SOURCE_PERMISSIONS
21+
DESTINATION ${CMAKE_INSTALL_PREFIX})
22+
23+
-# Build logic for `wasm-component-ld` installed from Rust code.
24+
-set(wasm_component_ld_root ${CMAKE_CURRENT_BINARY_DIR}/wasm-component-ld)
25+
-set(wasm_component_ld ${wasm_component_ld_root}/bin/wasm-component-ld${CMAKE_EXECUTABLE_SUFFIX})
26+
-set(wasm_component_ld_version 0.5.19)
27+
-if(RUST_TARGET)
28+
- set(rust_target_flag --target=${RUST_TARGET})
29+
-endif()
30+
-add_custom_command(
31+
- OUTPUT ${wasm_component_ld}
32+
- COMMAND
33+
- cargo install --root ${wasm_component_ld_root} ${rust_target_flag}
34+
- wasm-component-ld@${wasm_component_ld_version}
35+
- COMMAND
36+
- cmake -E make_directory ${wasi_tmp_install}/bin
37+
- COMMAND
38+
- cmake -E copy ${wasm_component_ld} ${wasi_tmp_install}/bin
39+
- COMMENT "Building `wasm-component-ld` ...")
40+
-add_custom_target(wasm-component-ld DEPENDS ${wasm_component_ld})
41+
-add_dependencies(build wasm-component-ld)
42+
-
43+
# Setup installation logic for CMake support files.
44+
add_custom_target(misc-files)
45+
add_dependencies(build misc-files)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From a4ef37515d280b0000de3f3b9a16a58aec91ab95 Mon Sep 17 00:00:00 2001
2+
From: Gyorgy Sarvari <skandigraun@gmail.com>
3+
Date: Wed, 26 Nov 2025 16:04:11 +0100
4+
Subject: [PATCH] don't strip symbols from binaries
5+
6+
By default the project is trying to shrink their footprint by
7+
stripping the debug symbols from the binaries, which however
8+
makes the relevant QA check complain.
9+
10+
This patch removes the stripping.
11+
12+
Upstream-Status: Inappropriate [oe-specific]
13+
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
14+
---
15+
cmake/wasi-sdk-toolchain.cmake | 23 -----------------------
16+
1 file changed, 23 deletions(-)
17+
18+
diff --git a/cmake/wasi-sdk-toolchain.cmake b/cmake/wasi-sdk-toolchain.cmake
19+
index 61481e3..5f04af4 100644
20+
--- a/cmake/wasi-sdk-toolchain.cmake
21+
+++ b/cmake/wasi-sdk-toolchain.cmake
22+
@@ -90,9 +90,6 @@ ExternalProject_Add(llvm-build
23+
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi
24+
-DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE
25+
-DLLVM_ENABLE_LIBXML2=OFF
26+
- # Pass `-s` to strip symbols by default and shrink the size of the
27+
- # distribution
28+
- -DCMAKE_EXE_LINKER_FLAGS=-s
29+
${llvm_cmake_flags_list}
30+
# See https://www.scivision.dev/cmake-externalproject-list-arguments/ for
31+
# why this is in `CMAKE_CACHE_ARGS` instead of above
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 6c777445050d715512acd2ac0d419992bc224da7 Mon Sep 17 00:00:00 2001
2+
From: Gyorgy Sarvari <skandigraun@gmail.com>
3+
Date: Wed, 26 Nov 2025 13:06:22 +0100
4+
Subject: [PATCH] lower cmake requirement
5+
6+
Kirkstone has CMake 3.22, but the minimum is specified as 3.26.
7+
8+
Lower it, so it can be built on Kirkstone - the cmake files are
9+
fairly straightforward and simple, without very arcane options.
10+
11+
Upstream-Status: Inappropriate [oe-specific]
12+
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
13+
---
14+
CMakeLists.txt | 2 +-
15+
1 file changed, 1 insertion(+), 1 deletion(-)
16+
17+
diff --git a/CMakeLists.txt b/CMakeLists.txt
18+
index a0d3fca..22ef298 100644
19+
--- a/CMakeLists.txt
20+
+++ b/CMakeLists.txt
21+
@@ -6,7 +6,7 @@
22+
# WASI sysroot build requires this previous compiler and must be runnable on
23+
# the host.
24+
25+
-cmake_minimum_required(VERSION 3.26)
26+
+cmake_minimum_required(VERSION 3.22)
27+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
28+
project(wasi-sdk)
29+
include(ExternalProject)

meta-firefox/recipes-devtools/wasi-sdk/wasi-sdk-native_git.bb

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require wasi-sdk.inc
2+
3+
DEPENDS += "wasi-sdk-toolchain-native wasm-component-ld-native"
4+
RDEPENDS:${PN} = "wasi-sdk-toolchain-native wasm-component-ld-native"
5+
6+
# The first 3 options come from the project's readme, about the compiling
7+
# intructions. The WASI_SDK_CPU_FLAGS' mcpu argument is the default, from
8+
# the main CMakeLists.txt file. The DEBUG_PREFIX_MAP is required, otherwise
9+
# it embeds some host-paths into libcxx, which later leak into the final binaries.
10+
EXTRA_OECMAKE += " \
11+
-DCMAKE_TOOLCHAIN_FILE=${STAGING_DATADIR_NATIVE}/wasi-sysroot/share/cmake/wasi-sdk.cmake \
12+
-DCMAKE_C_COMPILER_WORKS=ON \
13+
-DCMAKE_CXX_COMPILER_WORKS=ON \
14+
-DWASI_SDK_CPU_CFLAGS='-mcpu=lime1 ${DEBUG_PREFIX_MAP}' \
15+
"
16+
17+
BUILD_LD = "wasm-ld"
18+
19+
# wasi-sysroot is built for wasi target, not for host/target.
20+
# The wasi toolchain file for cmake contains wasi-specific
21+
# attributes. To avoid overshadowing, unset the build-target
22+
# specific attributes.
23+
CFLAGS = ""
24+
CXXFLAGS = ""
25+
LDFLAGS = ""
26+
CMAKE_C_LINK_FLAGS = ""
27+
CMAKE_CXX_LINK_FLAGS = ""
28+
OECMAKE_C_LINK_FLAGS = ""
29+
OECMAKE_CXX_LINK_FLAGS = ""
30+
BUILD_CC = ""
31+
COMPILER_RT:remove = "-rtlib=libgcc"
32+
33+
do_install:append(){
34+
install -d ${D}${datadir}/wasi-sysroot/lib/clang/${WASI_CLANG_VERSION}
35+
mv ${D}${prefix}/clang-resource-dir/lib ${D}${datadir}/wasi-sysroot/lib/clang/${WASI_CLANG_VERSION}/
36+
}

0 commit comments

Comments
 (0)