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

No such file or directory error with bazel 7 #273

Closed
derekperkins opened this issue Feb 15, 2024 · 3 comments
Closed

No such file or directory error with bazel 7 #273

derekperkins opened this issue Feb 15, 2024 · 3 comments

Comments

@derekperkins
Copy link

When upgrading to Bazel 7.0.2 from 6.5.0, with no other changes (bzlmod explicitly disabled), my llvm build fails in CI (Google Cloud Build) saying that a file can't be found. I'm not quite sure what would cause that change.

external/go_sdk/pkg/tool/linux_amd64/link: running external/llvm_toolchain/bin/cc_wrapper.sh failed: exit status 1
external/llvm_toolchain_llvm/bin/ld.lld: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

Possibly related issue:

Error logs

[56 / 59] GoCompilePkg external/bazel_gazelle/language/go/go.a [for tool]; 0s linux-sandbox
ERROR: /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/bazel_gazelle/cmd/gazelle/BUILD.bazel:4:15: GoLink external/bazel_gazelle/cmd/gazelle/gazelle_/gazelle [for tool] failed: (Exit 1): builder failed: error executing GoLink command (from target @@bazel_gazelle//cmd/gazelle:gazelle) bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/go_sdk/builder_reset/builder link -sdk external/go_sdk -installsuffix linux_amd64 -arc ... (remaining 67 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/go_sdk/pkg/tool/linux_amd64/link: running external/llvm_toolchain/bin/cc_wrapper.sh failed: exit status 1
external/llvm_toolchain_llvm/bin/ld.lld: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
clang: error: unable to execute command: No such file or directory
clang: error: linker command failed due to signal (use -v to see invocation)

link: error running subcommand GOOS=linux \
GOPATH= \
GOROOT_FINAL=GOROOT \
GOROOT=bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/io_bazel_rules_go/stdlib_ \
PATH=external/llvm_toolchain/bin:/bin:/usr/bin \
GOEXPERIMENT=nocoverageredesign \
GOTOOLCHAIN=local \
TMPDIR=/tmp \
GOARCH=amd64 \
ZERO_AR_DATE=1 \
CGO_ENABLED=1 \
external/go_sdk/pkg/tool/linux_amd64/link -importcfg /tmp/bazel-working-directory/__main__/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/bazel_gazelle/cmd/gazelle/gazelle_/importcfg111940917 -o /tmp/bazel-working-directory/__main__/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/bazel_gazelle/cmd/gazelle/gazelle_/gazelle -extld external/llvm_toolchain/bin/cc_wrapper.sh -buildid=redacted -s -w -extldflags "--target=x86_64-unknown-linux-gnu -lm -no-canonical-prefixes -fuse-ld=lld -Wl,--build-id=md5 -Wl,--hash-style=gnu -Wl,-z,relro,-z,now -l:libc++.a -l:libc++abi.a -l:libunwind.a -rtlib=compiler-rt -lpthread -ldl" /tmp/bazel-working-directory/__main__/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/bazel_gazelle/cmd/gazelle/gazelle.a: exit status 2
INFO: Found 1 target...
Target //:gazelle-update-repos failed to build

not full files, just seemingly relevant pieces

.bazelrc

common --noenable_bzlmod

build --incompatible_disallow_empty_glob=false

WORKSPACE

http_archive(
    name = "bazel_gazelle",
    sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
    ],
)

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_register_toolchains(version = "1.22.0")

load("//:deps.bzl", "go_dependencies")

go_dependencies()

go_rules_dependencies()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

http_archive(
    name = "toolchains_llvm",
    canonical_id = "0.10.3",
    sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01",
    strip_prefix = "toolchains_llvm-0.10.3",
    url = "https://github.com/grailbio/bazel-toolchain/releases/download/0.10.3/toolchains_llvm-0.10.3.tar.gz",
)

load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")

bazel_toolchain_dependencies()

load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
    name = "llvm_toolchain",
    llvm_versions = {
        "": "16.0.4",
        "darwin-aarch64": "16.0.5",
    },
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()

Dockerfile

FROM debian:bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install curl gnupg ca-certificates git -y --no-install-recommends && \
    curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg && \
    mv bazel.gpg /etc/apt/trusted.gpg.d/ && \
    echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
    apt update && \
    apt-get install bazel-7.0.2 gnupg2 curl -y && \
    apt-get purge gnupg2 -y --no-install-recommends && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN mv /usr/bin/bazel-7.0.2 /usr/bin/bazel
@derekperkins
Copy link
Author

I tried with all combinations of these two flags as suggested in the linked issue, and it still didn't successfully build.

common --noincompatible_sandbox_hermetic_tmp
common --sandbox_add_mount_pair=/tmp

@siddharthab
Copy link
Contributor

Sorry, the missing dep you are referencing is a system dependency from the released LLVM distribution. It is out of scope for this project.

You can reference what we install in a base Debian image to make the toolchain (and our tests) work --

apt-get -qq -y install curl libtinfo5 zlib1g-dev >/dev/null

For the slim Debian image, you might need a few more deps. You can use the script above to iterate locally and test.

Please reopen if it does not work for you.

@derekperkins
Copy link
Author

That was it, thanks, sorry for the noise. I was under the assumption that this toolchain was completely self-contained.

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