f0rmiga / gcc-toolchain

A fully-hermetic Bazel GCC toolchain for Linux.
Apache License 2.0
103 stars 24 forks source link

[Bug]: Build fails for .s assembly files #102

Closed ripatel-fd closed 1 year ago

ripatel-fd commented 1 year ago

What happened?

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 6.0.0-pre.20220909.2

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

Build rule

load("//bazel:fd_build_system.bzl", "fd_cc_library", "fd_cc_test")

package(default_visibility = ["//src/ballet:__subpackages__"])

fd_cc_library(
    name = "sha512",
    srcs = [
        "fd_sha512.c",
        "fd_sha512_core_avx2.s",
    ],
    hdrs = [
        "fd_sha512.h",
    ],
    deps = [
        "//src/ballet:base_lib",
    ],
)

When changing fd_sha512_core_avx2.s to fd_sha512_core_avx2.S, the build succeeds.

Any other information?

Build with `.s` file (fail)
Loading: 
Loading: 0 packages loaded
Analyzing: target //src/ballet/sha512:sha512 (0 packages loaded, 0 targets configured)
INFO: Analyzed target //src/ballet/sha512:sha512 (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
SUBCOMMAND: # //src/ballet/sha512:sha512 [action 'Compiling src/ballet/sha512/fd_sha512_core_avx2.s', configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4, execution platform: @local_config_platform//:host]
(cd /home/ripatel/.cache/bazel/_bazel_ripatel/c4b4531357e10c25e070592873e21602/execroot/firedancer && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
  external/gcc11_x86-64-v2/bin/gcc -fPIC -Wno-misleading-indentation -Wno-ignored-attributes '-DFD_HAS_DOUBLE=1' '-DFD_HAS_ALLOCA=1' '-DFD_HAS_X86=1' '-D_XOPEN_SOURCE=700' '-DFD_HAS_HOSTED=1' -pthread '-DFD_HAS_THREADS=1' '-DFD_HAS_ATOMIC=1' -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -isystemexternal/sysroot_x86_64//include/c++/10.3.0 -isystemexternal/sysroot_x86_64//include/c++/10.3.0/x86_64-linux -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include-fixed -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include -isystemexternal/sysroot_x86_64//usr/include -c src/ballet/sha512/fd_sha512_core_avx2.s -o bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512_core_avx2.pic.o)
# Configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4
# Execution platform: @local_config_platform//:host
ERROR: /data/prj/firedancer/src/ballet/sha512/BUILD:5:14: Compiling src/ballet/sha512/fd_sha512_core_avx2.s failed: (Exit 1): gcc failed: error executing command (from target //src/ballet/sha512:sha512) external/gcc11_x86-64-v2/bin/gcc -fPIC -Wno-misleading-indentation -Wno-ignored-attributes '-DFD_HAS_DOUBLE=1' '-DFD_HAS_ALLOCA=1' '-DFD_HAS_X86=1' '-D_XOPEN_SOURCE=700' '-DFD_HAS_HOSTED=1' -pthread ... (remaining 17 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/main/tools/linux-sandbox-pid1.cc:490: "execvp(external/gcc11_x86-64-v2/bin/gcc, 0x1149cf0)": No such file or directory
Target //src/ballet/sha512:sha512 failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.132s, Critical Path: 0.04s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

Build with `.S` file (success)
Loading: 
Loading: 0 packages loaded
Analyzing: target //src/ballet/sha512:sha512 (1 packages loaded, 0 targets configured)
INFO: Analyzed target //src/ballet/sha512:sha512 (1 packages loaded, 4 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
SUBCOMMAND: # //src/ballet/sha512:sha512 [action 'Compiling src/ballet/sha512/fd_sha512_core_avx2.S', configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4, execution platform: @local_config_platform//:host]
(cd /home/ripatel/.cache/bazel/_bazel_ripatel/c4b4531357e10c25e070592873e21602/execroot/firedancer && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
  external/gcc11_x86-64-v2/bin/gcc -MD -MF bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512_core_avx2.pic.d -fPIC -iquote . -iquote bazel-out/k8-fastbuild/bin -isystem bazel-out/k8-fastbuild/bin/external/numa/libnuma_headers/include -isystem bazel-out/k8-fastbuild/bin/external/numa/libnuma/include -Wno-misleading-indentation -Wno-ignored-attributes '-DFD_HAS_DOUBLE=1' '-DFD_HAS_ALLOCA=1' '-DFD_HAS_X86=1' '-D_XOPEN_SOURCE=700' '-DFD_HAS_HOSTED=1' -pthread '-DFD_HAS_THREADS=1' '-DFD_HAS_ATOMIC=1' --sysroot external/sysroot_x86_64 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -isystemexternal/sysroot_x86_64//include/c++/10.3.0 -isystemexternal/sysroot_x86_64//include/c++/10.3.0/x86_64-linux -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include-fixed -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include -isystemexternal/sysroot_x86_64//usr/include -c src/ballet/sha512/fd_sha512_core_avx2.S -o bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512_core_avx2.pic.o)
# Configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4
# Execution platform: @local_config_platform//:host
SUBCOMMAND: # //src/ballet/sha512:sha512 [action 'Linking src/ballet/sha512/libsha512.a', configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4, execution platform: @local_config_platform//:host]
(cd /home/ripatel/.cache/bazel/_bazel_ripatel/c4b4531357e10c25e070592873e21602/execroot/firedancer && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
  external/gcc11_x86-64-v2/bin/ar rcsD bazel-out/k8-fastbuild/bin/src/ballet/sha512/libsha512.a bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512.pic.o bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512_core_avx2.pic.o)
# Configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4
# Execution platform: @local_config_platform//:host
SUBCOMMAND: # //src/ballet/sha512:sha512 [action 'Linking src/ballet/sha512/libsha512.so', configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4, execution platform: @local_config_platform//:host]
(cd /home/ripatel/.cache/bazel/_bazel_ripatel/c4b4531357e10c25e070592873e21602/execroot/firedancer && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
  external/gcc11_x86-64-v2/bin/gcc -shared -o bazel-out/k8-fastbuild/bin/src/ballet/sha512/libsha512.so bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512.pic.o bazel-out/k8-fastbuild/bin/src/ballet/sha512/_objs/sha512/fd_sha512_core_avx2.pic.o -pthread -Wl,-S -Wl,-z,relro,-z,now -pass-exit-codes -lm -lstdc++ --sysroot external/sysroot_x86_64 -Bexternal/gcc11_x86-64-v2/bin -Bexternal/sysroot_x86_64//usr/lib -Bexternal/sysroot_x86_64//lib64 -Lexternal/sysroot_x86_64//lib64 -Lexternal/sysroot_x86_64//usr/lib -Lexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0)
# Configuration: 462f7a8353785ed4ab21eca57082c09d0458027d8309ce41bb7dd96b8ad0bff4
# Execution platform: @local_config_platform//:host
Target //src/ballet/sha512:sha512 up-to-date:
  bazel-bin/src/ballet/sha512/libsha512.a
  bazel-bin/src/ballet/sha512/libsha512.so
INFO: Elapsed time: 0.775s, Critical Path: 0.64s
INFO: 4 processes: 1 internal, 3 linux-sandbox.
INFO: Build completed successfully, 4 total actions
INFO: Build completed successfully, 4 total actions
f0rmiga commented 1 year ago

Unfortunately, we don't have control over this since it's a native implementation in Bazel. https://bazel.build/reference/be/c-cpp#cc_library

A bug report should be filed on https://github.com/bazelbuild/bazel.