Closed goussepi closed 1 month ago
This is a known problem of trying to mix non-LLVM and LLVM toolchains and libraries; we try to support it for recent versions of all dependencies, but older versions may not work (such as the versions that Ubuntu still uses). The easiest way to fix that, in the README we have this bit: ... if you run into problems, try with the LLVM C++ Library (libc++) by additionally passing --config=libc++ to the Bazel command.
Our CI uses Ubuntu, and uses this command line to build: https://github.com/google/gwpsan/blob/cae177120ede167779f056ff69bf5746ad554cf9/.github/workflows/tests.yml#L77
Try to use that command (after installing the necessary dependencies if they are missing).
Thank you @melver , using --config=libc++ and the NM issue is gone. But I get a 'cstddef' file not found error now, I tried to force passing "/usr/lib/llvm-10/include/c++/v1" as a include path using
ln -s /usr/lib/llvm-10/include/c++/v1 ./external/clang_headers
bazel ... --cxxopt="-isystem ./external/clang_headers/v1"...
but it does seem to apply to bazel? Would it be simpler if I use a different version of Linux? Which version/distribution of Linux do you recommend?
pierre@pierre-qemu:~/gwpsan$ bazel build --config=libc++ -c opt $( [[ $(uname -m) == "x86_64" ]] && echo --config=x86_64 ) //gwpsan/unified:libgwpsan.so //gwpsan/unified:gwpsan_archive --sandbox_debug
Starting local Bazel server and connecting to it...
WARNING: For repository 'googletest', the root module requires module version googletest@1.14.0, but got googletest@1.14.0.bcr.1 in the resolved dependency graph.
INFO: Analyzed 2 targets (113 packages loaded, 11179 targets configured).
DEBUG: Sandbox debug output for CppCompile //gwpsan/import:builtins:
1726835236.721352931: src/main/tools/linux-sandbox.cc:156: calling pipe(2)...
1726835236.721370063: src/main/tools/linux-sandbox.cc:165: Netns is 0
1726835236.721371716: src/main/tools/linux-sandbox.cc:176: calling clone(2)...
1726835236.721533102: src/main/tools/linux-sandbox.cc:185: linux-sandbox-pid1 has PID 41337
1726835236.728103840: src/main/tools/linux-sandbox-pid1.cc:700: Pid1Main started
1726835236.728202607: src/main/tools/linux-sandbox.cc:202: done manipulating pipes
1726835236.728245848: src/main/tools/linux-sandbox-pid1.cc:293: bind mount: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/_hermetic_tmp -> /tmp
1726835236.728261247: src/main/tools/linux-sandbox-pid1.cc:311: writable: /dev/shm
1726835236.728266748: src/main/tools/linux-sandbox-pid1.cc:311: writable: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/execroot/_main
1726835236.728271757: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp
1726835236.728276066: src/main/tools/linux-sandbox-pid1.cc:327: working dir: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/execroot/_main
1726835236.728474451: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /
1726835236.728480292: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev
1726835236.728483689: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/pts
1726835236.728486855: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726835236.728490301: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/hugepages
1726835236.728493397: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/mqueue
1726835236.728496483: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run
1726835236.728500070: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/lock
1726835236.728503426: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/snapd/ns
1726835236.728506922: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000
1726835236.728510470: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000/gvfs
1726835236.728514026: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys
1726835236.728516792: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/security
1726835236.728543933: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup
1726835236.728547459: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/unified
1726835236.728551076: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/systemd
1726835236.728555154: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/net_cls,net_prio
1726835236.728558610: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/memory
1726835236.728561706: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/hugetlb
1726835236.728564873: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpu,cpuacct
1726835236.728568159: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/perf_event
1726835236.728571365: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/rdma
1726835236.728574671: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpuset
1726835236.728578208: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/pids
1726835236.728581354: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/misc
1726835236.728584630: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/devices
1726835236.728605759: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/freezer
1726835236.728609587: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/blkio
1726835236.728612943: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/pstore
1726835236.728616581: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/bpf
1726835236.728619997: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/debug
1726835236.728630006: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/tracing
1726835236.728633463: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/fuse/connections
1726835236.728637240: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/config
1726835236.728641027: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc
1726835236.728644283: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726835236.728650114: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /proc/sys/fs/binfmt_misc, nullptr, 2101281, nullptr) failure (Operation not permitted) ignored
1726835236.728657508: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726835236.728661084: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2318
1726835236.728664421: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2379
1726835236.728675222: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/29619
1726835236.728678478: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/24061
1726835236.728681303: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/21759
1726835236.728684179: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/18357
1726835236.728687285: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726835236.728690180: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726835236.728693055: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/execroot/_main
1726835236.728696141: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726835236.728698656: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/execroot/_main
1726835236.728723133: src/main/tools/linux-sandbox-pid1.cc:496: calling fork...
1726835236.728856775: src/main/tools/linux-sandbox-pid1.cc:533: child started with PID 2
1726835236.778885417: src/main/tools/linux-sandbox-pid1.cc:550: wait returned pid=2, status=0x00
1726835236.778895096: src/main/tools/linux-sandbox-pid1.cc:568: child exited normally with code 0
1726835236.779170176: src/main/tools/linux-sandbox.cc:243: child exited normally with code 0
Run this command to start an interactive shell in an identical sandboxed environment:
(exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/2/debug.out -- /bin/sh -i)
DEBUG: Sandbox debug output for CppCompile //gwpsan/base:base:
1726835236.803711656: src/main/tools/linux-sandbox.cc:156: calling pipe(2)...
1726835236.803740241: src/main/tools/linux-sandbox.cc:165: Netns is 0
1726835236.803741974: src/main/tools/linux-sandbox.cc:176: calling clone(2)...
1726835236.803946121: src/main/tools/linux-sandbox.cc:185: linux-sandbox-pid1 has PID 41343
1726835236.803973372: src/main/tools/linux-sandbox-pid1.cc:700: Pid1Main started
1726835236.804005323: src/main/tools/linux-sandbox.cc:202: done manipulating pipes
1726835236.804128686: src/main/tools/linux-sandbox-pid1.cc:293: bind mount: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/_hermetic_tmp -> /tmp
1726835236.804139326: src/main/tools/linux-sandbox-pid1.cc:311: writable: /dev/shm
1726835236.804145157: src/main/tools/linux-sandbox-pid1.cc:311: writable: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main
1726835236.804149796: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp
1726835236.804153163: src/main/tools/linux-sandbox-pid1.cc:327: working dir: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main
1726835236.804206454: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /
1726835236.804211413: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev
1726835236.804214740: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/pts
1726835236.804218036: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726835236.804221542: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/hugepages
1726835236.804224668: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/mqueue
1726835236.804227874: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run
1726835236.804230750: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/lock
1726835236.804234046: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/snapd/ns
1726835236.804237472: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000
1726835236.804240748: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000/gvfs
1726835236.804243934: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys
1726835236.804246789: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/security
1726835236.804273210: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup
1726835236.804277158: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/unified
1726835236.804280744: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/systemd
1726835236.804284191: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/net_cls,net_prio
1726835236.804287477: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/memory
1726835236.804290633: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/hugetlb
1726835236.804293779: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpu,cpuacct
1726835236.804296955: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/perf_event
1726835236.804300070: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/rdma
1726835236.804303166: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpuset
1726835236.804306654: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/pids
1726835236.804309830: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/misc
1726835236.804313026: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/devices
1726835236.804335849: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/freezer
1726835236.804339936: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/blkio
1726835236.804344044: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/pstore
1726835236.804348823: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/bpf
1726835236.804352340: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/debug
1726835236.804361177: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/tracing
1726835236.804364604: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/fuse/connections
1726835236.804368461: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/config
1726835236.804372218: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc
1726835236.804375574: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726835236.804380984: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /proc/sys/fs/binfmt_misc, nullptr, 2101281, nullptr) failure (Operation not permitted) ignored
1726835236.804386595: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726835236.804390061: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2318
1726835236.804393427: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2379
1726835236.804403316: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/29619
1726835236.804406532: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/24061
1726835236.804409268: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/21759
1726835236.804412063: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/18357
1726835236.804414839: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726835236.804417714: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726835236.804420519: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main
1726835236.804423575: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726835236.804426260: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main
1726835236.804447981: src/main/tools/linux-sandbox-pid1.cc:496: calling fork...
1726835236.804546047: src/main/tools/linux-sandbox-pid1.cc:533: child started with PID 2
1726835236.857103599: src/main/tools/linux-sandbox-pid1.cc:550: wait returned pid=2, status=0x100
1726835236.857122986: src/main/tools/linux-sandbox-pid1.cc:568: child exited normally with code 1
1726835236.857522953: src/main/tools/linux-sandbox.cc:243: child exited normally with code 1
Run this command to start an interactive shell in an identical sandboxed environment:
(exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/debug.out -- /bin/sh -i)
ERROR: /home/pierre/gwpsan/gwpsan/base/BUILD:25:15: Compiling gwpsan/base/unwind.cpp failed: (Exit 1): linux-sandbox failed: error executing CppCompile command
(cd /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main && \
exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/3/debug.out -- /usr/lib/llvm-18/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-stdlib=libc++' -MD -MF bazel-out/k8-opt/bin/gwpsan/base/_objs/base/unwind.d '-frandom-seed=bazel-out/k8-opt/bin/gwpsan/base/_objs/base/unwind.o' -iquote . -iquote bazel-out/k8-opt/bin -iquote external/abseil-cpp~ -iquote bazel-out/k8-opt/bin/external/abseil-cpp~ '--system-header-prefix=external/' -mcx16 -mcrc32 '-std=c++20' -Wno-mismatched-tags -fno-exceptions -Wno-c99-designator '-DGWPSAN_OPTIMIZE=2' -fPIC '-fno-experimental-sanitize-metadata=all' -Wglobal-constructors -Wexit-time-destructors -fno-unwind-tables -fno-asynchronous-unwind-tables -Os '-Wframe-larger-than=512' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c gwpsan/base/unwind.cpp -o bazel-out/k8-opt/bin/gwpsan/base/_objs/base/unwind.o)
In file included from gwpsan/base/unwind.cpp:21:
In file included from ./gwpsan/base/weak_imports.h:18:
external/abseil-cpp~/absl/base/config.h:56:10: fatal error: 'cstddef' file not found
56 | #include <cstddef>
| ^~~~~~~~~
1 error generated.
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 9.171s, Critical Path: 0.84s
INFO: 31 processes: 30 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully
Did you install these dependencies: https://github.com/google/gwpsan/blob/cae177120ede167779f056ff69bf5746ad554cf9/.github/workflows/tests.yml#L51
I recommend trying to reproduce the build as done by the CI, which also uses Ubuntu.
A yes sorry @melver I missed that bit, I have installed those now, headers are found. Now I run into issues with absolute paths not being allowed by the build which seems to be a bazel configuration issue rather than an environment issue? I have seen some suggestions online but I would appreciate if you had a recommended way to fix it as I am unfamiliar with bazel.
pierre@pierre-qemu:~/gwpsan$ bazel build --config=libc++ --config=dev -c opt --config=x86_64 //gwpsan/unified:libgwpsan.so //gwpsan/unified:gwpsan_archive --sandbox_debugbazel build --config=libc++ --config=dev -c opt --config=x86_64 //gwpsan/unified:libgwpsan.so //gwpsan/unified:gwpsan_archive
Run this command to start an interactive shell in an identical sandboxed environment:
(exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/19/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/19/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/19/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/19/debug.out -- /bin/sh -i)
ERROR: /home/pierre/gwpsan/gwpsan/base/BUILD:25:15: Compiling gwpsan/base/allocator.cpp failed: absolute path inclusion(s) found in rule '//gwpsan/base:base':
the source file 'gwpsan/base/allocator.cpp' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
'/usr/lib/llvm-18/include/c++/v1/stddef.h'
'/usr/lib/llvm-18/include/c++/v1/__config'
'/usr/lib/llvm-18/include/c++/v1/__config_site'
'/usr/lib/llvm-18/include/c++/v1/stdint.h'
'/usr/lib/llvm-18/include/c++/v1/errno.h'
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.979s, Critical Path: 0.58s
INFO: 4 processes: 4 internal.
ERROR: Build did NOT complete successfully
There maybe some leftover state, try bazel clean --expunge
and build again.
Thanks @melver , just tried and it is back to "/usr/bin/nm -j error", very confused... I might try to see if I can hardcode 'llvm-nm' instead of $(NM) , I tried setting the NM environment variable but it does not seem to affect the bazel environment...
pierre@pierre-qemu:~/gwpsan$ bazel build --config=libc++ --config=dev -c opt --config=x86_64 //gwpsan/unified:libgwpsan.so //gwpsan/unified:gwpsan_archive --sandbox_debug
INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
DEBUG: Sandbox debug output for Genrule //gwpsan/unified:unified_list_syms:
1726847271.350375573: src/main/tools/linux-sandbox.cc:156: calling pipe(2)...
1726847271.350405911: src/main/tools/linux-sandbox.cc:165: Netns is 0
1726847271.350407634: src/main/tools/linux-sandbox.cc:176: calling clone(2)...
1726847271.350579680: src/main/tools/linux-sandbox.cc:185: linux-sandbox-pid1 has PID 60692
1726847271.350597284: src/main/tools/linux-sandbox-pid1.cc:700: Pid1Main started
1726847271.350627370: src/main/tools/linux-sandbox.cc:202: done manipulating pipes
1726847271.350723713: src/main/tools/linux-sandbox-pid1.cc:293: bind mount: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/_hermetic_tmp -> /tmp
1726847271.350733792: src/main/tools/linux-sandbox-pid1.cc:311: writable: /dev/shm
1726847271.350737880: src/main/tools/linux-sandbox-pid1.cc:311: writable: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main
1726847271.350742619: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp
1726847271.350745995: src/main/tools/linux-sandbox-pid1.cc:327: working dir: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main
1726847271.350792944: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /
1726847271.350797753: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev
1726847271.350801019: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/pts
1726847271.350804116: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726847271.350806961: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/hugepages
1726847271.350809947: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/mqueue
1726847271.350812882: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run
1726847271.350815718: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/lock
1726847271.350818723: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/snapd/ns
1726847271.350822140: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000
1726847271.350825296: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run/user/1000/gvfs
1726847271.350828502: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys
1726847271.350831387: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/security
1726847271.350859821: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup
1726847271.350863538: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/unified
1726847271.350867145: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/systemd
1726847271.350870511: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/net_cls,net_prio
1726847271.350873737: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/memory
1726847271.350876863: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/hugetlb
1726847271.350879999: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpu,cpuacct
1726847271.350883135: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/perf_event
1726847271.350886231: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/rdma
1726847271.350889297: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/cpuset
1726847271.350892463: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/pids
1726847271.350895538: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/misc
1726847271.350898604: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/devices
1726847271.350918693: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/freezer
1726847271.350921949: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/cgroup/blkio
1726847271.350925095: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/pstore
1726847271.350929022: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/bpf
1726847271.350932358: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/debug
1726847271.350940514: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/tracing
1726847271.350944381: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/fs/fuse/connections
1726847271.350948208: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys/kernel/config
1726847271.350951955: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc
1726847271.350955051: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726847271.350960192: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /proc/sys/fs/binfmt_misc, nullptr, 2101281, nullptr) failure (Operation not permitted) ignored
1726847271.350965421: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc/sys/fs/binfmt_misc
1726847271.350968968: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2318
1726847271.350972004: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/core20/2379
1726847271.350981642: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/29619
1726847271.350984447: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/lxd/24061
1726847271.350987082: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/21759
1726847271.350989927: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /snap/snapd/18357
1726847271.350992502: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726847271.350995247: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm
1726847271.350998063: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main
1726847271.351001148: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp
1726847271.351003673: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main
1726847271.351023692: src/main/tools/linux-sandbox-pid1.cc:496: calling fork...
1726847271.351184797: src/main/tools/linux-sandbox-pid1.cc:533: child started with PID 2
1726847271.363637914: src/main/tools/linux-sandbox-pid1.cc:550: wait returned pid=2, status=0x100
1726847271.363647123: src/main/tools/linux-sandbox-pid1.cc:568: child exited normally with code 1
1726847271.363911994: src/main/tools/linux-sandbox.cc:243: child exited normally with code 1
Run this command to start an interactive shell in an identical sandboxed environment:
(exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/debug.out -- /bin/sh -i)
ERROR: /home/pierre/gwpsan/gwpsan/unified/BUILD:105:8: Executing genrule //gwpsan/unified:unified_list_syms failed: (Exit 1): linux-sandbox failed: error executing Genrule command
(cd /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main && \
exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/debug.out -- /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; /usr/bin/nm -j --defined-only bazel-out/k8-opt/bin/gwpsan/unified/unified_linked.o | egrep -v '\''gwpsan|__sanitizer_metadata_|__interceptor|fork|pthread_create|sigaction|signal'\'' | egrep -v '\''\.|^___'\'' | while read sym; do echo "${sym} gwpsan.${sym}" >> bazel-out/k8-opt/bin/gwpsan/unified/unified_redefine.syms; echo "gwpsan.${sym}" >> bazel-out/k8-opt/bin/gwpsan/unified/unified_localize.syms; done')
/usr/bin/nm: invalid option -- 'j'
Usage: /usr/bin/nm [option(s)] [file(s)]
List symbols in [file(s)] (a.out by default).
The options are:
-a, --debug-syms Display debugger-only symbols
-A, --print-file-name Print name of the input file before every symbol
-B Same as --format=bsd
-C, --demangle[=STYLE] Decode low-level symbol names into user-level names
The STYLE, if specified, can be `auto' (the default),
`gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'
or `gnat'
--no-demangle Do not demangle low-level symbol names
--recurse-limit Enable a demangling recursion limit. This is the default.
--no-recurse-limit Disable a demangling recursion limit.
-D, --dynamic Display dynamic symbols instead of normal symbols
--defined-only Display only defined symbols
-e (ignored)
-f, --format=FORMAT Use the output format FORMAT. FORMAT can be `bsd',
`sysv' or `posix'. The default is `bsd'
-g, --extern-only Display only external symbols
-l, --line-numbers Use debugging information to find a filename and
line number for each symbol
-n, --numeric-sort Sort symbols numerically by address
-o Same as -A
-p, --no-sort Do not sort the symbols
-P, --portability Same as --format=posix
-r, --reverse-sort Reverse the sense of the sort
--plugin NAME Load the specified plugin
-S, --print-size Print size of defined symbols
-s, --print-armap Include index for symbols from archive members
--size-sort Sort symbols by size
--special-syms Include special symbols in the output
--synthetic Display synthetic symbols as well
-t, --radix=RADIX Use RADIX for printing symbol values
--target=BFDNAME Specify the target object format as BFDNAME
-u, --undefined-only Display only undefined symbols
--with-symbol-versions Display version strings after symbol names
-X 32_64 (ignored)
@FILE Read options from FILE
-h, --help Display this information
-V, --version Display this program's version number
/usr/bin/nm: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 srec symbolsrec verilog tekhex binary ihex plugin
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/pierre/gwpsan/gwpsan/unified/BUILD:132:8 Executing genrule //gwpsan/unified:unified_private failed: (Exit 1): linux-sandbox failed: error executing Genrule command
(cd /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main && \
exec env - \
BAZEL_COMPILER=clang \
BAZEL_CXXOPTS='-stdlib=libc++' \
BAZEL_LINKOPTS=-lc++:-lm \
CC=clang \
CXX=clang++ \
CXXFLAGS='-stdlib=libc++' \
LDFLAGS='-stdlib=libc++' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pierre/bazeldir \
TMPDIR=/tmp \
/home/pierre/.cache/bazel/_bazel_pierre/install/ec66cb4ed623de0db7a7f89408b9b468/linux-sandbox -t 15 -w /dev/shm -w /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/execroot/_main -w /tmp -M /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/_hermetic_tmp -m /tmp -S /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/stats.out -D /home/pierre/.cache/bazel/_bazel_pierre/8d5019327e12f9b81bd870492dc983d8/sandbox/linux-sandbox/59/debug.out -- /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; /usr/bin/nm -j --defined-only bazel-out/k8-opt/bin/gwpsan/unified/unified_linked.o | egrep -v '\''gwpsan|__sanitizer_metadata_|__interceptor|fork|pthread_create|sigaction|signal'\'' | egrep -v '\''\.|^___'\'' | while read sym; do echo "${sym} gwpsan.${sym}" >> bazel-out/k8-opt/bin/gwpsan/unified/unified_redefine.syms; echo "gwpsan.${sym}" >> bazel-out/k8-opt/bin/gwpsan/unified/unified_localize.syms; done')
INFO: Elapsed time: 0.335s, Critical Path: 0.02s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully
pierre@pierre-qemu:~/gwpsan$ clang --version
Ubuntu clang version 18.1.8 (++20240731025011+3b5b5c1ec4a3-1~exp1~20240731145104.143)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
I havent had time to figure it out but in the meantime I have worked around it by hardcoding the path to the llvm tools in BUILD file.
Hi there,
I am attempting to follow the instructions to build this. I have run the command below and get an error from nm, could you help pointing what I am doing wrong?
Many thanks!
Pierre
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.21.0/bazelisk-linux-amd64
chmod +x bazelisk-linux-amd64
bazelisk-linux-amd64
export PATH=$PATH:~/bazeldir
CC=clang-18
CXX=clang++-18
bazel build --action_env=CC="$CC" --action_env=CXX="$CXX" -c opt $( [[ $(uname -m) == "x86_64" ]] && echo --config=x86_64 ) //gwpsan/unified:libgwpsan.so //gwpsan/unified:gwpsan_archive --sandbox_debug