emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.98k stars 679 forks source link

emcc error #1241

Closed lgyhit closed 1 year ago

lgyhit commented 1 year ago

I tried build a c++ source file to a wasm module using proxy-wasm-cpp-sdk (https://github.com/proxy-wasm/proxy-wasm-cpp-sdk.git). I follows the README first , I download this project: git clone ttps://github.com/proxy-wasm/proxy-wasm-cpp-sdk.git & cd proxy-wasm-cpp-sdk secondly, docker build -t wasmsdk:v2 -f Dockerfile-sdk . then, the following picture shows what confused me.

image

I guess it was emsdk in container, when emcc doing something, errors occurred, maybe libstdc++.so.6 and glibc version is lower ? please help me ~ image

sbc100 commented 1 year ago

It looks like the base imagine the container you are using doesn't have a recent enough glibc to run the binaries you have.

Looking at the Dockerfile-sdk, it looks like it should be fine though since the imagine is based on Ubuntu/Bionic and we explicitly tests again bionic in emsdk testing: https://github.com/emscripten-core/emsdk/blob/c2260b4f28f53b411032de0955a6fe6b6bcf3edd/.circleci/config.yml#L6-L9

The second message is also a little confusing since the clang binaries in emsdk don't depend on any GLIBC_2.29 symbol versions, and statically link againt libc++.so. For example:

$ ldd upstream/bin/clang
    linux-vdso.so.1 (0x00007fff8c587000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fae2cb14000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fae2cb0f000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fae2cb0a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fae26701000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fae266e2000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fae266c0000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fae264df000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fae2cb1b000)

Note that there not libstdc++ or libc++ dependency listed there. I even tried installing 3.1.7 specifically I can see the same results.

So I'm confused about where you clang binaries are coming from .. they don't see to the emsdk binaries even though they seem to live in emsdk/upstream/bin. They also look like there were build a more recent version of ubuntu..

Maybe file a bug with the proxy-wasm-cpp-sdk repo?

lgyhit commented 1 year ago

It looks like the base imagine the container you are using doesn't have a recent enough glibc to run the binaries you have.

Looking at the Dockerfile-sdk, it looks like it should be fine though since the imagine is based on Ubuntu/Bionic and we explicitly tests again bionic in emsdk testing:

https://github.com/emscripten-core/emsdk/blob/c2260b4f28f53b411032de0955a6fe6b6bcf3edd/.circleci/config.yml#L6-L9

The second message is also a little confusing since the clang binaries in emsdk don't depend on any GLIBC_2.29 symbol versions, and statically link againt libc++.so. For example:

$ ldd upstream/bin/clang
  linux-vdso.so.1 (0x00007fff8c587000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fae2cb14000)
  librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fae2cb0f000)
  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fae2cb0a000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fae26701000)
  libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fae266e2000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fae266c0000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fae264df000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fae2cb1b000)

Note that there not libstdc++ or libc++ dependency listed there. I even tried installing 3.1.7 specifically I can see the same results.

So I'm confused about where you clang binaries are coming from .. they don't see to the emsdk binaries even though they seem to live in emsdk/upstream/bin. They also look like there were build a more recent version of ubuntu..

Maybe file a bug with the proxy-wasm-cpp-sdk repo?

Thanks for your answers! the README suggests using docker, namely build from Dockerfile-sdk, but failed. So I tried the second way: construct the env byhand. I download protobuf, emsdk and WAVM. When I execute 'git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk update-tags ./emsdk install 3.1.7 ./emsdk activate 3.1.7

source ./emsdk_env.sh' the clang binaries which make you confused may be downloaded after executing ./emsdk install 3.1.7. Maybe clang binaries which emsdk use are built in a high version ubantu os.

sbc100 commented 1 year ago

Oh.. I see the problem. You are running on arm64 linux and the binaries build for arm64 are not built by our official builders bit by an external contributor. I guess that they are not using an old/stable version of linux when they build their binaries and also they are not statically linking libc++ like our official binaries. See https://github.com/emscripten-core/emsdk/issues/547 for more info on our arm64 linux support.

Is there some reason you use using arm64 linux ?

A couple of solutions you might try:

  1. Update the base imagine the Dockerfile to a more recent version of ubuntu
  2. Build emsdk binaries from source youself (this can take a while).
  3. Switch using x86_64 (I get that this might not be feasible).
lgyhit commented 1 year ago

Oh.. I see the problem. You are running on arm64 linux and the binaries build for arm64 are not built by our official builders bit by an external contributor. I guess that they are not using an old/stable version of linux when they build their binaries and also they are not statically linking libc++ like our official binaries. See #547 for more info on our arm64 linux support.

Is there some reason you use using arm64 linux ?

A couple of solutions you might try:

  1. Update the base imagine the Dockerfile to a more recent version of ubuntu
  2. Build emsdk binaries from source youself (this can take a while).
  3. Switch using x86_64 (I get that this might not be feasible).

Oh.. I see the problem. You are running on arm64 linux and the binaries build for arm64 are not built by our official builders bit by an external contributor. I guess that they are not using an old/stable version of linux when they build their binaries and also they are not statically linking libc++ like our official binaries. See #547 for more info on our arm64 linux support.

Is there some reason you use using arm64 linux ?

A couple of solutions you might try:

  1. Update the base imagine the Dockerfile to a more recent version of ubuntu
  2. Build emsdk binaries from source youself (this can take a while).
  3. Switch using x86_64 (I get that this might not be feasible).

my group have 2 zones, x86 and aarch64 . istio-proxy is applied to these zones. Recently, I want to upgrade istio-proxy to 1.17.2,but extensions which were developped by us are directly modified from the source code. This made it hard to migrate to new version. I am now trying to use proxy-wasm to make it easier.

I tried dokken/ubuntu-20.04 as base image and it works. ps. image glibc is higher enough and it has a built-in gcc 9.5+ which libstdc++ is high enough too.

sbc100 commented 1 year ago

Great news. I guess we can close this now?