Closed martijneken closed 12 months ago
This might also be an issue with rules_foreign_cc
(see: https://github.com/bazelbuild/rules_foreign_cc/issues/869).
@martijneken Let me know if you can easily verify that #1274 fixes your issues. If it does I'll go ahead and merge. If you need me to merge in order to test let me know and I'm happy to do that as well.
Yes this helps! I see emcc and emcc_link being used by envoy_cmake now. Next there is a set of real-looking zlib build errors (some pasted below). I had noticed this zlib build issue already, and it's fixed in a newer zlib version (see https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/pull/157#issuecomment-1656823140). My short term workaround is setting -Wno-deprecated-non-prototype
in ProxyWasm. I haven't verified that this fixes everything yet. I need to go afk now, but I'll try to get an e2e working build Envoy pushed tonight or tomorrow.
...
/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/net_zlib/deflate.c:815:13: error: a fu
nction definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
815 | int ZEXPORT deflate(strm, flush)
| ^
/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/net_zlib/deflate.c:1130:13: error: a f
unction definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
1130 | int ZEXPORT deflateEnd(strm)
| ^
/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/net_zlib/deflate.c:1156:13: error: a f
unction definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
1156 | int ZEXPORT deflateCopy(dest, source)
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
emcc: error: '/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/emscripten_bin_linux/bin
/clang -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm
-disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/external/ems
cripten_bin_linux/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -D_LARGEFILE64_SOURCE=1 -I/usr/local/google/home/mstevenson/.cache/
bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/bazel-out/wasm-fastbuild-ST-158e2d9e5dd0/bin/external/envoy/bazel/foreign_cc/zlib.build_
tmpdir -I/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/net_zlib --sysroot=/usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/emscripten_bin_linux/emscripten/cache/sysroot -fdiagnostics-color -fno-strict-aliasing -funsigned-char -no-canonical-prefixes -fomit-frame-pointer -O0 -Wall -iwithsysroot/include/c++/v1 -iwithsysroot/include/compat -iwithsysroot/include -isystem /usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/emscripten_bin_linux/lib/clang/17/include -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -Werror -O3 -fexceptions -MD -MT CMakeFiles/zlib.dir/deflate.o -MF CMakeFiles/zlib.dir/deflate.o.d -c /usr/local/google/home/mstevenson/.cache/bazel/_bazel_mstevenson/a70324d31864af234fcb5ca19cc454c8/sandbox/linux-sandbox/23/execroot/envoy/external/net_zlib/deflate.c -o CMakeFiles/zlib.dir/deflate.o' failed (returned 1)
ninja: build stopped: subcommand failed.
There are at least two issues upgrading Envoy to v3.1.44 (seen in https://github.com/envoyproxy/envoy/pull/29118), and I suspect both are related to Bazel toolchain resolution since https://github.com/emscripten-core/emsdk/pull/1036.
Inability to build cmake targets, such as zlib. The error is
CMAKE_C_COMPILER not set
(details).When I try to add an emcmake toolchain (draft), I run into toolchain resolution issues (details). The issue is that the regular cmake toolchain uses
exec_compatible_with
qualifiers, rather thantarget_compatible_with
which would skip this choice for wasm targets.I suspect there are 2 possible roads to fix cmake support:
Improper cpp toolchain resolution. Envoy uses Rust to build Wasm plugins, and Rust registers a dummy cc toolchain. For reasons I don't understand, the Rust dummy toolchain is selected ahead of the real emcc toolchain, causing compilation failures like
DUMMY_GCC_TOOL failed
(it's not intended to actually build anything). It seems like emsdk needs a way to force its toolchain after the emscripten transition.P.S. The above issues pop up when setting
incompatible_use_toolchain_transition
(or flags like--incompatible_enable_cc_toolchain_resolution
), which many projects and targets already rely on.