Do not cross compile mknames.go

`GOOS` and `GOARCH` can be set to cross compile the Go code. But
`good-names.go` is generated at build time using `mknames.go`, which
must be built for the build platform. `GOOS` and `GOARCH` can be unset
to do this. In many circumstances, Go will use its own internal linker
to build the binary, which means it won't need to use `$CC`. But in
some scenarios, e.g. when building PIE binaries, it will use `$CC` as
the linker, so this needs to be set to the build platform's compiler
for `go run`.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
This commit is contained in:
Will Fancher 2025-11-10 11:24:19 -05:00 committed by Andrew G. Morgan
parent 3b2513a1ba
commit d628b3bfe4

View File

@ -49,7 +49,7 @@ $(topdir)/libcap/cap_names.h:
$(MAKE) -C $(topdir)/libcap cap_names.h
good-names.go: $(topdir)/libcap/cap_names.h vendor/$(IMPORTDIR)/cap mknames.go
CC="$(CC)" $(GO) run -mod=vendor mknames.go --header=$< --textdir=$(topdir)/doc/values | gofmt > $@ || rm -f $@
CC="$(BUILD_CC)" GOOS= GOARCH= $(GO) run -mod=vendor mknames.go --header=$< --textdir=$(topdir)/doc/values | gofmt > $@ || rm -f $@
diff -u ../cap/names.go $@
PSXGOPACKAGE: vendor/$(IMPORTDIR)/psx ../psx/*.go $(DEPS)