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

🐛 Bug Report: Fails to build on WolfiOS with clang-17 (failed: error executing CppLink command) #3247

Closed
willswire opened this issue Dec 15, 2024 · 3 comments

Comments

@willswire
Copy link

I am trying to contribute workerd as a package to WolfiOS here. I've included the necessary build dependencies:

environment:
  contents:
    packages:
      - bash
      - bazelisk
      - bazelisk-default
      - binutils
      - build-base
      - busybox
      - clang-17
      - clang-17-dev
      - gnutar
      - libtool
      - llvm-libunwind-17
      - llvm-libcxx-17
      - llvm-libcxx-17-dev
      - llvm-libcxxabi-17
      - llvm-lld-17
      - llvm17
      - llvm17-dev
      - posix-libc-utils
      - python3-dev
      - tcl

However I am getting the following error:

ERROR: /home/build/.cache/bazel/_bazel_root/79a1bfc8c8b5b6a6d226b38d072f165b/external/capnp-cpp/src/capnp/BUILD.bazel:139:10: Linking external/capnp-cpp/src/capnp/capnpc-c++ [for tool] failed: (Exit 1): clang-17 failed: error executing CppLink command (from target @@capnp-cpp//src/capnp:capnpc-c++)

Potentially related issues:

@willswire willswire changed the title clang-17 failed: error executing CppLink command 🐛 Bug Report: Fails to build on WolfiOS with clang-17 (failed: error executing CppLink command) Dec 15, 2024
@fhanau
Copy link
Collaborator

fhanau commented Dec 16, 2024

Can you provide the full error output for this? The actual error message from the linker/clang driver should be listed below the ERROR line you included here.
In terms of dependencies, I'm not familiar with your package manager but for Debian/Ubuntu installing a libc++abi-<version>-dev package is required, I'm not sure if that will be installed as a dependency of the packages you have listed. Looking at the CI build scripts, there's also libc++abi1-16 and libc++1-16 packages being installed. If the link error message is libc++-related, that or something similar should be responsible here.

@willswire
Copy link
Author

I figured it out! I just had to add libstdc++-6 and libstdc++-6-dev along with the following build flags:

bazel build \
 --config=thin-lto \
 --linkopt='-lc++' --linkopt='-lm' \
 --host_linkopt='-lc++' --host_linkopt='-lm' \
 //src/workerd/server:workerd

@fhanau
Copy link
Collaborator

fhanau commented Dec 16, 2024

Note that the workerd build tries to statically link its binaries with libc++ and libgcc by passing --linkopt='-l:libc++.a' --linkopt='-lm' --linkopt='-static-libgcc' in .bazelrc. With that passing -lm manually should not be needed. I assume with your changes libc++ is being linked dynamically instead, which might work around static libc++ not being installed? Either way, glad it's working for you now.

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