I setup a self defined cc_toolchain to use clang. even though not cross compiling, but I still set --sysroot to clang_toolchain directory, then add all search path manully. under this situation, rules_foreign_cc pass --sysroot to CC enviroment viarable, CFLAGS not take at configure stage, so cannot find sys/types.h at config stage, this lead configure add #define gid_t int to src/config.h, but at compiling stage, CFLAGS take works, so will got two #define of gid_t(one from src/config.h, another from sys/types.h), so compiling failed, does add --sysroot to CC vairable was right? if it's right, how to fix this problem?
ERROR: /root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/rules_foreign_cc/toolchains/private/BUILD.bazel:23:10: BootstrapGNUMake external/rules_foreign_cc/toolchains/private/make [for tool] failed: (Exit 1): bash failed: error executing BootstrapGNUMake command (from target @@rules_foreign_cc//toolchains/private:make_tool) /bin/bash -c bazel-out/k8-opt-exec-ST-47bf8d7f3fd8/bin/external/rules_foreign_cc/toolchains/private/make_tool_foreign_cc/wrapper_build_script.sh
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ ZERO_AR_DATE=1
+ AR=/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/bin/llvm-ar
+ ARFLAGS=
+ CC='/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/bin/clang --sysroot=/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/'
+ CFLAGS='-U_FORTIFY_SOURCE --target=x86_64-linux-gnu -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -Wall -v -stdlib=libc++ -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -isystem /usr/include -isystem /usr/include/x86_64-linux-gnu -isystem /root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib/clang/18/include -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -g'
+ LD='/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/bin/clang --sysroot=/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/'
+ LDFLAGS='-Wl,-S -v -B/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/bin -L/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib -Wl,--build-id=md5 -Wl,--hash-style=gnu -Wl,-z,relro,-z,now -Wl,-no-as-needed -lstdc++ -lc -lm -fuse-ld=lld -rtlib=compiler-rt -B/usr/lib/x86_64-linux-gnu -L/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib -Wl,-rpath,/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib -L/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib/x86_64-unknown-linux-gnu -Wl,-rpath,/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib/x86_64-unknown-linux-gnu -L/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib/clang/18/lib/x86_64-unknown-linux-gnu -Wl,-rpath,/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/external/cc_toolchain_repo_amd64_x86_64_clang/lib/clang/18/lib/x86_64-unknown-linux-gnu -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu -Wl,--gc-sections'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/root/.cache/bazel/_bazel_root/d7f4cad81e2b036f4c3382027c9d9c7a/sandbox/linux-sandbox/17134/execroot/bazel_template/bazel-out/k8-opt-exec-ST-47bf8d7f3fd8/bin/external/rules_foreign_cc/toolchains/private/make
checking for uid_t in sys/types.h... no
checking for pid_t... no
checking for off_t... no
checking for size_t... (cached) yes
checking for ssize_t... no
checking for unsigned long long int... yes
checking for long long int... yes
checking for intmax_t... no
checking for uintmax_t... no
checking for sig_atomic_t... no
checking for nanoseconds field of struct stat... no
checking whether to use high resolution file timestamps... no
/usr/include/x86_64-linux-gnu/sys/types.h:64:17: error: cannot combine with previous 'type-name' declaration specifier
64 | typedef __gid_t gid_t;
| ^
./src/config.h:1255:15: note: expanded from macro 'gid_t'
1255 | #define gid_t int
| ^
In file included from ./lib/concat-filename.c:22:
In file included from ./lib/concat-filename.h:20:
In file included from /usr/include/stdlib.h:395:
/usr/include/x86_64-linux-gnu/sys/types.h:79:17: error: cannot combine with previous 'type-name' declaration specifier
79 | typedef __uid_t uid_t;
| ^
./src/config.h:1304:15: note: expanded from macro 'uid_t'
1304 | #define uid_t int
| ^
I setup a self defined cc_toolchain to use clang. even though not cross compiling, but I still set --sysroot to clang_toolchain directory, then add all search path manully. under this situation, rules_foreign_cc pass --sysroot to CC enviroment viarable, CFLAGS not take at configure stage, so cannot find sys/types.h at config stage, this lead configure add #define gid_t int to src/config.h, but at compiling stage, CFLAGS take works, so will got two #define of gid_t(one from src/config.h, another from sys/types.h), so compiling failed, does add --sysroot to CC vairable was right? if it's right, how to fix this problem?