HomeFreeBSD

bsd.compiler.mk: Fix cross-building from non-FreeBSD

Description

bsd.compiler.mk: Fix cross-building from non-FreeBSD

On non-FreeBSD, the various MACHINE variables for the host when
bootstrapping can be missing or not match FreeBSD's naming, causing
bsd.endian.mk to be unable to infer the endianness. Work around this by
assuming it's unsupported.

Note that we can't check BOOTSTRAPPING here as Makefile.inc1 includes
bsd.compiler.mk before that is set, and so we are unable to catch errors
during buildworld itself when cross-building and bsd.endian.mk failed,
but such errors should also show up when building on FreeBSD.

Fixes: 47363e99d3d3 ("Enable compressed debug on little-endian targets")

Details

Provenance
jrtc27Authored on Aug 12 2021, 10:45 PM
Parents
rGc5bf58add0d5: Revert "ar: diff reduction against ELF Tool Chain"
Branches
Unknown
Tags
Unknown

Event Timeline

arichardson added inline comments.
/share/mk/bsd.compiler.mk
248

Wouldn't it make more sense to add something like

.else
.error "Cannot infer endianess for MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} MACHINE_CPUARCH=${MACHINE_CPUARCH} "

to bsd.endian.mk?

/share/mk/bsd.compiler.mk
248

Then you'd have to add a complex guard around .include <bsd.endian.mk> to avoid triggering the error, or have a simple "not FreeBSD" one that then doesn't infer endianness even when the machine is known. This way it does the best it can. You still get an error if you blindly use TARGET_ENDIANNESS (what this commit is fixing, the old malformed conditional due to an undefined variable).

/share/mk/bsd.compiler.mk
248

I just had a look at bsd.endian.mk and I see also sets other variables that will be empty for unknown MACHINE/etc. variables. I believe those are only needed for the TARGET_* values so yeah I guess the host value doesn't really matter right now.
Maybe a .warning would be appropriate though (in addition to this commit)?

/share/mk/bsd.compiler.mk
248

That just seems like it'll be noisy, giving out warnings users can't do anything about and we know get hit. It's going to fail anyway if the include site isn't prepared for them to be undefined.

/share/mk/bsd.compiler.mk
248

Yeah but are we aware of any values other than x86_64 that need to be handled? I was proposing adding the warning after handling x86_64.