Page MenuHomeFreeBSD

Makefile.inc1: override MACHINE for native-xtools
ClosedPublic

Authored by mhorne on Feb 25 2020, 7:33 PM.

Details

Summary

For the final step of the native-xtools target, "everything" is built
with TARGET and TARGET_ARCH set to the architecture we wish to
cross-build for. However, CROSSENV overwrites the values of MACHINE and
MACHINE_ARCH, setting them to be identical to TARGET and TARGET_ARCH.
For native-xtools this is undesirable since we are building binaries to
run on the host architecture, that can cross compile for the target
architecture.

When building native-xtools for RISC-V, this issue manifests as an
invalid argument for "-march", as the compiler is expecting an x86
processor, not rv64imafdc. These flags are set in bsd.cpu.mk depending
on MACHINE_CPUARCH, therefore demonstrating the need for MACHINE and
MACHINE_ARCH to be set to the host's architecture.

Test Plan

Building native-xtools for RISC-V succeeds on an amd64 host.
Building native-xtools for arm64 and mips continues to succeed on an amd64 host.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Ping. I've created a snippet P376 showing the build failure. As you can see the target triple is set correctly to amd64, but RISC-V CFLAGS are being picked up from bsd.cpu.mk.

I think this is fine but defer to @imp for anything ${MACHINE} or ${MACHINE_ARCH} related

Looks good to me. MACHINE may not be strictly necessary, but it doesn't hurt in this case, and may help a few stragglers that improperly depend on it.

This revision is now accepted and ready to land.Mar 24 2020, 7:47 PM
This revision was automatically updated to reflect the committed changes.