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

bazel compilation with emscripten failed #1081

Closed
wzheng21 opened this issue Mar 6, 2024 · 3 comments · Fixed by #1082
Closed

bazel compilation with emscripten failed #1081

wzheng21 opened this issue Mar 6, 2024 · 3 comments · Fixed by #1082
Assignees

Comments

@wzheng21
Copy link
Contributor

wzheng21 commented Mar 6, 2024

Hi we are recently trying to compile glog to wasm using bazel. The commit we are compiling is this. The crucial part of the error message is

Compiling src/raw_logging.cc failed: (Exit 1): emcc.sh failed: error executing command external/emsdk/emscripten_toolchain/emcc.sh '--sysroot=external/emscripten_bin_linux/emscripten/cache/sysroot' -fdiagnostics-color -fno-exceptions -fno-strict-aliasing -funsigned-char ... (remaining 53 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/com_googlesource_code_glog/src/raw_logging.cc:162:14: error: use of undeclared identifier 'STDERR_FILENO'
  safe_write(STDERR_FILENO, buffer, strlen(buffer));
             ^
1 error generated.

The root cause seems to be that wasm_copts misses -DHAVE_MODE_T and -DHAVE_UNISTD_H, both of which are defined in linux_or_darwin_copts, so when the platform is wasm, then compilation failed.

The quick fix I did is to move those two macro definitions to wasm_copts. Let me know if there's a more correct way of handling this or I missed anything.

@drigz
Copy link
Member

drigz commented Mar 6, 2024

Hey Victor! Let me know if you feel comfortable sending a PR to https://github.com/google/glog/blob/master/bazel/glog.bzl to fix this - also, if you depend on the wasm support maybe you could think about how to add CI for this in either https://github.com/google/glog/blob/master/.bazelci/presubmit.yml or https://github.com/google/glog/tree/master/.github/workflows, as I'm not sure how we can prevent future wasm breakage (it was added by a contributor but I haven't heard anything from them for some time).

@wzheng21
Copy link
Contributor Author

wzheng21 commented Mar 7, 2024

Hi @drigz I'm happy to send a PR. There's really not much to do. But it's a bit hard for me to do the CICD stuff with bazel + WASM.

@drigz
Copy link
Member

drigz commented Mar 8, 2024

But it's a bit hard for me to do the CICD stuff with bazel + WASM.

NP, don't block the fix on CI suggestion. Feel free to ignore that (and maybe revisit if you observe more breakage in future).

wzheng21 added a commit to wzheng21/glog that referenced this issue Mar 11, 2024
Currently, compiling glog to wasm would fail
as described in Issue google#1081

Root cause is the missing macros when compiling
glog to wasm
@sergiud sergiud linked a pull request Mar 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants