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][Ubuntu 22.04.3 LTS] Use of undeclared identifier 'SYS_write' #1011

Closed
prantoran opened this issue Dec 30, 2023 · 3 comments
Closed

Comments

@prantoran
Copy link

Hi everyone!

I am building glog with the latest release of emsdk for Bazel and I got the error that SYS_write is not defined. I searched previous issues. I think a similar occurred for OSX but not sure how related it is with my issue.

Here is the exact error from my terminal:

INFO: Found 1 target...
ERROR: /root/.cache/bazel/_bazel_root/1160c8434d4e1dfd4c379a5050d02ad4/external/com_github_glog_glog/BUILD:5:13: Compiling src/raw_logging.cc failed: (Exit 1): emcc.sh failed: error executing command (from target @com_github_glog_glog//:glog) external/emsdk/emscripten_toolchain/emcc.sh '--sysroot=external/emscripten_bin_linux/emscripten/cache/sysroot' -fdiagnostics-color -fno-exceptions -fno-strict-aliasing -funsigned-char ... (remaining 59 arguments skipped)
external/com_github_glog_glog/src/raw_logging.cc:139:3: error: use of undeclared identifier 'SYS_write'
  139 |   safe_write(STDERR_FILENO, buffer, strlen(buffer));
      |   ^
external/com_github_glog_glog/src/raw_logging.cc:63:42: note: expanded from macro 'safe_write'
   63 | # define safe_write(fd, s, len)  syscall(SYS_write, fd, s, len)
      |                                          ^
1 error generated.

The following is the glog setup in WORKSPACE. I used version 0.6.0.

# 23-12-30: copied from https://github.com/google/glog/#building-from-source
http_archive(
    name = "com_github_gflags_gflags",
    sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
    strip_prefix = "gflags-2.2.2",
    urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
)
http_archive(
    name = "com_github_google_glog",
    sha256 = "122fb6b712808ef43fbf80f75c52a21c9760683dae470154f02bddfc61135022",
    strip_prefix = "glog-0.6.0",
    urls = ["https://github.com/google/glog/archive/v0.6.0.zip"],
)

And the following is the emsdk setup in WORKSPACE. I used the version 3.1.51.

# 23-12-12 copied from https://github.com/emscripten-core/emsdk/blob/main/bazel/README.md
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "emsdk",
    sha256 = "6b206e135ccc3b0d6c02e948eb4b8b95521593b5b4d9788795269bbf6640fcb2",
    strip_prefix = "emsdk-4e2496141eda15040c44e9bbf237a1326368e34c/bazel",
    url = "https://github.com/emscripten-core/emsdk/archive/4e2496141eda15040c44e9bbf237a1326368e34c.tar.gz",
)

load("@emsdk//:deps.bzl", emsdk_deps = "deps")
emsdk_deps()

load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
emsdk_emscripten_deps(emscripten_version = "3.1.51")

load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains()
@prantoran prantoran changed the title [Emscripten][Ubuntu] Use of undeclared identifier 'SYS_write' [Emscripten][Ubuntu 22.04.3 LTS] Use of undeclared identifier 'SYS_write' Dec 30, 2023
@sergiud
Copy link
Collaborator

sergiud commented Dec 30, 2023

Proper Emscripten support was added in #846 shortly after the 0.6.0 release. However, glog is continuously built with Emscripten using CMake only. I believe none of the other maintainers use Bazel for this purpose. Such builds can therefore break anytime.

I therefore suggest testing glog at head first. If that does not work, please submit a PR with a corresponding fix.

@prantoran
Copy link
Author

Cool thanks for the context! I will try out and create a PR if applicable.

@sergiud
Copy link
Collaborator

sergiud commented Jan 3, 2024

Great! I'll close this issue then. If you encounter specific problems at head, just create a new issue.

@sergiud sergiud closed this as completed Jan 3, 2024
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

No branches or pull requests

2 participants