f0rmiga / gcc-toolchain

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

Unable to use gcc-toolchain with configure_make #168

Closed TimotheusBachinger closed 5 months ago

TimotheusBachinger commented 5 months ago

First of all: Thanks for the great work of enabling an hermetic gcc toolchain in Bazel! It helped us already a lot for our understanding.

Description

At the moment we're trying to integrate your toolchain (with a bumped gcc version) in our build but I am already failing to compile a third party project (which we're bundling/shipping/linking against).

The configure_make step is failing during configure with a lot of errors, where some of them seem to be toolchain related. e.g.:

configure:3724: /home/timotheus/.cache/bazel/_bazel_timotheus/17bdf0994d16870d211e03bc3a9d26dd/sandbox/linux-sandbox/21/execroot/_main/external/gcc_toolchain_x86_64/bin/gcc  -c -Dredacted="redacted"  conftest.c >&5
conftest.c:10:10: fatal error: stdio.h: No such file or directory
   10 | #include <stdio.h>
      |          ^~~~~~~~~
compilation terminated.

This looks to me as configure is expecting gcc to find the system include paths by its own. But those paths are explicitly registered (as I assume the pre-compiled/relocated gcc won't be able to do that on his own)

        gcc_toolchain_workspace_name = rctx.attr.gcc_toolchain_workspace_name,
        target_compatible_with = str(target_compatible_with),
        toolchain_files_repository_name = rctx.attr.toolchain_files_repository_name,

        # Sysroot
        sysroot = sysroot,

        # Includes
        cxx_builtin_include_directories = str(cxx_builtin_include_directories),

This may all be an issue of the external rrdtool project but you guys may have more insights / tips regarding that?

Repro

The issue should be fully reproducible with: https://github.com/Checkmk/gcc-toolchain/commit/3be3a14817d423b0b3ac68399b32599f45f4f8cd

bazel build --sandbox_add_mount_pair=/tmp  --sandbox_debug --verbose_failures --platforms=//platforms:x86_64_linux //examples/rrdtool:rrdtool
TimotheusBachinger commented 5 months ago

Ok - found the issue. One should not overwrite CFLAGS - sorry for the interruption. https://github.com/Checkmk/gcc-toolchain/commit/3be3a14817d423b0b3ac68399b32599f45f4f8cd#diff-a6681743cb45c373cc4ca9f6dfec3a42706c06f3174471bc8e6c6ac7c51aecd3R27