Skip to content

Emscripten upgrade breaks Envoy #1273

Closed

Description

@martijneken

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.

Activity

  1. added
    bazel
    on Aug 27, 2023
  2. PiotrSikora commented on Aug 28, 2023

    @PiotrSikora
    Contributor

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

  3. added a commit that references this issue on Aug 28, 2023
    c35d809
  4. walkingeyerobot commented on Aug 28, 2023

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

  5. martijneken commented on Aug 29, 2023

    @martijneken
    ContributorAuthor

    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.                                                                                                                                                 
    
  6. added a commit that references this issue on Aug 29, 2023
    9b0db91
  7. added a commit that references this issue on Sep 29, 2023
    0b10952
  8. added a commit that references this issue on Feb 3, 2026
    9889206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bazel

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions