Skip to content

Conversation

@umanwizard
Copy link
Contributor

Certain systems, e.g. Guix, have e.g. $ARCH-unknown-linux-gnu-gcc rather than $ARCH-linux-gnu-gcc.

Thus, use the former as a fallback if the latter isn't found.

Certain systems, e.g. Guix, have e.g. $ARCH-unknown-linux-gnu-gcc rather than
$ARCH-linux-gnu-gcc.

Thus, use the former as a fallback if the latter isn't found.
@umanwizard umanwizard requested review from a team as code owners October 16, 2025 23:57
Copy link
Contributor

@florianl florianl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - just a nit.

umanwizard and others added 2 commits October 16, 2025 23:47
Co-authored-by: Florian Lehner <[email protected]>
Co-authored-by: Florian Lehner <[email protected]>
Comment on lines +32 to +33
export CC = $(shell command -v $(ARCH_PREFIX)-linux-gnu-gcc || command -v $(ARCH_PREFIX)-unknown-linux-gnu-gcc)
export OBJCOPY = $(shell command -v $(ARCH_PREFIX)-linux-gnu-objcopy || command -v $(ARCH_PREFIX)-unknown-linux-gnu-objcopy)
Copy link
Member

@christos68k christos68k Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't use these when building the artifacts (as we dropped CGo), they're only used in tests where we explicitly enable CGo. In which case, shouldn't we just run the tests through the Docker image as well for reproducibility (and also avoiding adding environment-specific fallbacks)?

One issue with this implementation is that if no compiler is found, the errors read weird as CC is empty:

test.c -g -o with-debug-syms
make[1]: test.c: No such file or directory
make[1]: *** [Makefile:21: with-debug-syms] Error 127
make[1]: *** Waiting for unfinished jobs....
/bin/sh: 1: test.c: not found

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are also used when running make generate.

Copy link
Member

@christos68k christos68k Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are also used when running make generate.

I missed this because make generate doesn't fail when the command -v invocations don't find a compiler (make test will however fail as shown in my previous comment):

$ (cd ./support; CC=$(command -v false) ./generate.sh)
$ (cd ./support; CC=$(command -v foo) ./generate.sh)
types_gen.go

strace is showing Go searching for and executing gcc when CC=. So essentially, there are multiple points of discussion here:

  1. We want make to fail when no compiler matching our criteria is found instead of introducing indeterminism.
  2. Rather than adding environment-specific fallbacks (Guix, Nix, ..), we should probably strive for a cleaner Makefile and strongly recommend people use our build container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants