Skip to main content

Bazel FAQ

Central cache for external repositories

du -sh /private/var/tmp/_bazel_$USER/cache/repos/v1/content_addressable/sha256

git add

git add --ignore-errors '**/BUILD.bazel' WORKSPACE deps.bzl BUILD.bazel

Bazel4 on AlpineLinux

# ALpineLinux 3.15
apk add openjdk17-jdk bazel4 -X https://mirrors.sjtug.sjtu.edu.cn/alpine/edge/testing

# AlpineLinux Bazel 环境
apk add xz python3 coreutils tar patch diffutils gcc g++
ln -s /usr/bin/python3 /usr/bin/python

# ALpineLinux <= 3.15
apk upgrade g++ libstdc++ -X https://mirrors.sjtug.sjtu.edu.cn/alpine/edge/main

gcc: fatal error: cannot execute 'cc1plus': execvp: No such file or directory

apk add g++

/usr/bin/bazel-real: _ZSt28__throw_bad_array_new_lengthv: symbol not found

install bazel from edge testing

# sync libstdc++ version
apk upgrade libstdc++ -X https://mirrors.sjtug.sjtu.edu.cn/alpine/edge/main
ldd /usr/bin/bazel-real
	/lib/ld-musl-x86_64.so.1 (0x7f8198234000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f8197d6a000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f8197d50000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f8198234000)
Error relocating /usr/bin/bazel-real: _ZSt28__throw_bad_array_new_lengthv: symbol not found
# Missing
objdump -T /usr/lib/libstdc++.so.6 | grep throw_bad_array

glob: recursive wildcard must be its own segment

  • glob("src/**.c") -> glob("src/**/*.c")