[Bug 260005] devel/wasi-libcxx: not built to spec and not really useable
Date: Tue, 23 Nov 2021 21:02:24 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260005 Bug ID: 260005 Summary: devel/wasi-libcxx: not built to spec and not really useable Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Keywords: patch Severity: Affects Only Me Priority: --- Component: Individual Port(s) Assignee: ports-bugs@FreeBSD.org Reporter: cmt@freebsd.org CC: greg@unrelenting.technology CC: greg@unrelenting.technology Flags: maintainer-feedback?(greg@unrelenting.technology) Created attachment 229684 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=229684&action=edit disable exceptions and fix more feature flags in wasi-libcxx platform is FreeBSD 13.0-RELEASE-p5, amd64, poudriere. Trying to use wasi-libcxx (e.g. when building firefox beta with web assembly sandbox) does not work: wasm-ld: error: /usr/local/share/wasi-sysroot/lib/wasm32-wasi/libc++.a(string.cpp.o): undefined symbol: __cxa_allocate_exception wasm-ld: error: /usr/local/share/wasi-sysroot/lib/wasm32-wasi/libc++.a(string.cpp.o): undefined symbol: __cxa_throw wasi-sdk doesn't support exception, so more diagnosis: wasi-libcxx was built with exceptions, there is no "-fno-exceptions" in the build log, even as the port's Makefile specifies "-DLIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF -DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF". Digging further, I find that wasi-libcxx's CMakeFiles report -- Performing Test LIBCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG -- Performing Test LIBCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG - Failed among others like that (e.g. "LIBCXX_SUPPORTS_WALL_FLAG - Failed"). More digging ensues. => First: CMakeFiles/CMakeErrors.log for libcxxabi reports Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/bin/c++ That's the wrong compiler - base clang (11.0 in 13) does not know about "--target=wasm32-wasi". The reason is that this cmake was run in post-configure under CONFIGURE_ENV, which does not contain CC/CXX/etc., that's only in MAKE_ENV by default (see any poudrier log, all the environments are listed right at the top). Anyways, that results in many of the compilier feature Tests failing, as the compiler does not know about the target. => Second: Even when using the correct compiler, many feature Tests still fail: wasm-ld: error: cannot open crt1.o: No such file or directory wasm-ld: error: unable to find library -lc++ wasm-ld: error: unable to find library -lc++abi wasm-ld: error: unable to find library -lc Well duh, we're getting into chicken-and-egg territory here. The very ugly workaround is to just pass the Test results as flags to cmake, which will then do the right thing (for at least some cases). Attached patch will: - bump PORTREVISION - put CC/CFLAGS/CXX/CXXFLAGS into CONFIGURE_ENV - pass the Test results into cmake (I'm being generous with the flags here, and I hope I got it all correct - but then "it works for me"). Another nitpick: poudriere complains about pkg-static: DEVELOPER_MODE: Error: arch "FreeBSD:13:*" -- package installs architecture specific files but I'm not touching that right now, between this and firefox beta (it builds!) I've enough for today. -- You are receiving this mail because: You are the assignee for the bug.