Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten upgrade breaks Envoy #1273

Closed
martijneken opened this issue Aug 27, 2023 · 3 comments · Fixed by #1274
Closed

Emscripten upgrade breaks Envoy #1273

martijneken opened this issue Aug 27, 2023 · 3 comments · Fixed by #1274
Assignees
Labels
bazel Issues related to Bazel toolchain

Comments

@martijneken
Copy link
Contributor

martijneken commented Aug 27, 2023

There are at least two issues upgrading Envoy to v3.1.44 (seen in envoyproxy/envoy#29118), and I suspect both are related to Bazel toolchain resolution since #1036.

  1. 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 than target_compatible_with which would skip this choice for wasm targets.

    I suspect there are 2 possible roads to fix cmake support:

    • use regular cmake, but configure it properly to use the emcc compiler
    • use a custom toolchain to invoke emcmake, fix above toolchain resolution issues
  2. 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.

@sbc100 sbc100 added the bazel Issues related to Bazel toolchain label Aug 27, 2023
@walkingeyerobot walkingeyerobot self-assigned this Aug 28, 2023
@PiotrSikora
Copy link
Contributor

This might also be an issue with rules_foreign_cc (see: bazel-contrib/rules_foreign_cc#869).

walkingeyerobot added a commit to walkingeyerobot/emsdk that referenced this issue Aug 28, 2023
Fixes emscripten-core#1273. This was broken by emscripten-core#1045 with the comment "* all_files not needed?" They were needed.
@walkingeyerobot
Copy link
Collaborator

@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.

@martijneken
Copy link
Contributor Author

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 proxy-wasm/proxy-wasm-cpp-sdk#157 (comment)). 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.                                                                                                                                                 

walkingeyerobot added a commit that referenced this issue Aug 29, 2023
Fixes #1273. This was broken by #1045 with the comment "* all_files not needed?" They were needed.
shlomif pushed a commit to shlomif/emsdk that referenced this issue Sep 29, 2023
Fixes emscripten-core#1273. This was broken by emscripten-core#1045 with the comment "* all_files not needed?" They were needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel Issues related to Bazel toolchain
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants