pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: firefox using llvm/clang 22.1.6



On Friday, May 29th, 2026 at 12:29 PM, Tobias Nygren <tnn%NetBSD.org@localhost> wrote:

> On Fri, 29 May 2026 07:58:34 +0000
> pin <voidpin%protonmail.com@localhost> wrote:
> 
> > DEBUG: Executing: `/usr/pkg/bin/clang --target=wasm32-wasip1 /tmp/conftest6vwsc_0w.c --sysroot=/usr/pkg/wasi -c`
> > DEBUG: The command returned non-zero exit status 1.
> > DEBUG: Its error output was:
> > DEBUG: | /tmp/conftest6vwsc_0w.c:1:10: fatal error: 'string.h' file not found
> > DEBUG: |     1 | #include <string.h>
> > DEBUG: |       |          ^~~~~~~~~~
> > DEBUG: | 1 error generated.
> > ERROR: Cannot find wasi headers or problem with the wasm compiler. Please fix the problem. Or build with --without-wasm-sandboxed-libraries.
> 
> I think you need to update lang/wasi-libc, lang/wasi-libcxx and
> wasi-compiler-rt to match the clang version.
> was-libc installs it's headers to:
> /usr/pkg/wasi/include/wasm32-wasi
> which is a directory with target name different from the supplied target option.
> Perhaps easier for now to just disable the WASM sandbox feature in firefox/mozilla-common.mk.


Thanks!
I was on it already :)

Thing is, I'm already using the wip packages for wasi-libc, wasi-libcxx and wasi-compiler-rt.

But, llvm22 changed the name of wasm32-wasi to wasm32-wasip1 and wasi-libc/Makefile is still using the old name.

I've rebuilt the wasi packages using this mod on wasi-libc/Makefile and a new PLIST

--- /usr/pkgsrc/wip/wasi-libc/Makefile	2026-05-29 12:52:18.681893451 +0200
+++ Makefile	2026-05-29 12:52:06.855098157 +0200
@@ -44,6 +44,7 @@
 MAKE_FLAGS+=	AR=${PREFIX}/bin/llvm-ar
 MAKE_FLAGS+=	NM=${PREFIX}/bin/llvm-nm
 MAKE_FLAGS+=	INSTALL_DIR=${DESTDIR}${PREFIX}/wasi
+MAKE_FLAGS+=	TARGET_TRIPLE=wasm32-wasip1
 #BUILD_TARGET=	finish
 BUILD_TARGET=	no-check-symbols
 
@@ -51,9 +52,9 @@
 # It conflicts with musl libc so must be removed.
 pre-configure:
 	rm -f ${BUILDLINK_DIR}/include/iconv.h
-	${MKDIR} ${WRKSRC}/build/wasm32-wasi/resource-dir/lib/wasi
+	${MKDIR} ${WRKSRC}/build/wasm32-wasip1/resource-dir/lib/wasi
 	${MV} ${WRKDIR}/libclang_rt.builtins-wasm32-wasi-25.0/*.a \
-		${WRKSRC}/build/wasm32-wasi/resource-dir/lib/wasi
+		${WRKSRC}/build/wasm32-wasip1/resource-dir/lib/wasi
 
 ABI=			# 32
 CFLAGS+=		-O2

Don't know if we will also need:

+post-install:
+               cd ${DESTDIR}${PREFIX}/wasi/include && \
+                                 ${LN} -sf wasm32-wasip1 wasm32-wasi
+               cd ${DESTDIR}${PREFIX}/wasi/lib && \
+                                 ${LN} -sf wasm32-wasip1 wasm32-wasi

for backwards compatibility.

I've also modified wasi-libcxx/Makefile as bellow and generated a new PLIST

--- /usr/pkgsrc/wip/wasi-libcxx/Makefile	2026-05-29 13:21:57.939605385 +0200
+++ Makefile	2026-05-29 13:21:51.056127267 +0200
@@ -41,9 +41,9 @@
 CMAKE_CONFIGURE_ARGS+=	-DLLVM_COMPILER_CHECKED=ON
 CMAKE_CONFIGURE_ARGS+=	-DUNIX:BOOL=ON
 CMAKE_CONFIGURE_ARGS+=	-DCMAKE_SYSROOT=${BUILDLINK_DIR}/wasi
-CMAKE_CONFIGURE_ARGS+=	-DCMAKE_CXX_COMPILER_TARGET=wasm32-wasi
+CMAKE_CONFIGURE_ARGS+=	-DCMAKE_CXX_COMPILER_TARGET=wasm32-wasip1
 CMAKE_CONFIGURE_ARGS+=	-DLLVM_CONFIG_PATH=${PREFIX}/bin/llvm-config
-CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi
+CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasip1
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_INCLUDE_BENCHMARKS:BOOL=FALSE
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_INCLUDE_TESTS:BOOL=FALSE
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_ENABLE_THREADS:BOOL=OFF
@@ -58,7 +58,7 @@
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_CXX_ABI=libcxxabi
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_HAS_MUSL_LIBC:BOOL=ON
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXX_ABI_VERSION=2
-CMAKE_CONFIGURE_ARGS+=	-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi
+CMAKE_CONFIGURE_ARGS+=	-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasip1
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXXABI_ENABLE_SHARED:BOOL=OFF
 CMAKE_CONFIGURE_ARGS+=	-DLIBCXXABI_SILENT_TERMINATE:BOOL=ON
@@ -157,9 +157,9 @@
 # problem in this package?
 post-install:
 	${PREFIX}/bin/llvm-ranlib \
-	  ${DESTDIR}${PREFIX}/wasi/lib/wasm32-wasi/libc++.a
+	  ${DESTDIR}${PREFIX}/wasi/lib/wasm32-wasip1/libc++.a
 	${PREFIX}/bin/llvm-ranlib \
-	  ${DESTDIR}${PREFIX}/wasi/lib/wasm32-wasi/libc++abi.a
+	  ${DESTDIR}${PREFIX}/wasi/lib/wasm32-wasip1/libc++abi.a
 
 .include "../../lang/python/tool.mk"
 .include "../../wip/llvm/buildlink3.mk"

Also here, I don't know if we should look to keep backwards compatibility.

With these changes rebuilding firefox fails with:

DEBUG: Creating `/tmp/conftestl4_2_7qr.c` with content:
DEBUG: | int
DEBUG: | main(void)
DEBUG: | {
DEBUG: |
DEBUG: |   ;
DEBUG: |   return 0;
DEBUG: | }
DEBUG: Executing: `/usr/pkg/bin/clang --target=wasm32-wasip1 /tmp/conftestl4_2_7qr.c --sysroot=/usr/pkg/wasi`
DEBUG: The command returned non-zero exit status 1.
DEBUG: Its error output was:
DEBUG: | wasm-ld: error: cannot open /usr/pkg/lib/clang/22/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a: No such file or directory
DEBUG: | clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: Cannot find wasi libraries or problem with the wasm linker. Please fix the problem. Or build with --without-wasm-sandboxed-libraries.

Because the actual path to libclang_rt.builtins.a is /usr/pkg/lib/clang/22/lib/wasi and not /usr/pkg/lib/clang/22/lib/wasm32-unknown-wasip1

:(





Home | Main Index | Thread Index | Old Index