arch/x86: default CROSSDEV on a macOS host - #19567
Merged
Merged
Conversation
casaroli
force-pushed
the
fix-x86-crossdev
branch
from
July 28, 2026 07:11
0d64c00 to
6506605
Compare
arch/x86 set CROSSDEV only under Cygwin, so everywhere else the build used the bare tool names and got the host compiler. On Linux that is a native gcc which can produce i486 ELF objects, which is what the board README assumes. On macOS it is Apple clang, and on Apple Silicon that cannot target i386 in any form -- so there is no configuration in which the default works and a cross toolchain is not optional. Default it to i686-elf-, which Homebrew packages and which accepts the -march=i486 -mtune=i486 already in ARCHCPUFLAGS. arch/x86_64 has had exactly this stanza for its own toolchain all along; this is the same shape. The Cygwin assignment becomes ?= to match, so that a CROSSDEV passed in from the environment or the command line is honoured rather than overridden. Note for anyone tempted by the toolchain they already have: a 64-bit x86 compiler with -m32 is not a substitute unless it was built with multilib. Homebrew's x86_64-elf-gcc compiles 32-bit objects perfectly happily and has no 32-bit libgcc to link them against, so the entire build succeeds and only the final link fails, on __udivdi3, __divdi3, __moddi3 and __udivmoddi4. `x86_64-elf-gcc -print-multi-lib' prints just `.;', which is the toolchain saying so up front. Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com> Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Done The two comment blocks are merged into one above it. Re-verified after the change: |
casaroli
force-pushed
the
fix-x86-crossdev
branch
from
July 28, 2026 07:16
6506605 to
29cb5f7
Compare
casaroli
marked this pull request as ready for review
July 28, 2026 07:18
xiaoxiang781216
approved these changes
Jul 28, 2026
jerpelea
approved these changes
Jul 28, 2026
jerpelea
requested changes
Jul 28, 2026
jerpelea
left a comment
Contributor
There was a problem hiding this comment.
please replace
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
with
Assisted-by: Claude Opus 5 (1M context) noreply@anthropic.com
casaroli
force-pushed
the
fix-x86-crossdev
branch
2 times, most recently
from
July 28, 2026 07:55
57b3f4a to
8996364
Compare
Contributor
Author
|
@jerpelea hello can you please re-review? |
jerpelea
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Summary
arch/x86/src/common/Toolchain.defssetsCROSSDEVonly under Cygwin:Everywhere else
CROSSDEVis empty, soCCbecomes the bare hostgcc. Thatis fine on an x86 Linux box and useless anywhere else. On macOS the host
compiler is Apple clang, which on Apple Silicon cannot target i386 at all, so
the build fails in a thoroughly misleading way — the ARM assembler rejecting
x86 inline asm out of an x86 header:
This gives
CROSSDEVa sane default on macOS and makes the Cygwin oneoverridable (
=→?=), matching whatarch/x86_64already does.Homebrew's
i686-elf-gccis the intended target; a 64-bit x86 toolchain with-m32is not a substitute unless built with multilib, since it compiles 32-bitobjects and then has no 32-bit libgcc to link them against — which surfaces
only at the final link as undefined
__udivdi3and friends.Impact
Only
CONFIG_HOST_MACOS=ybuilds ofarch/x86change, and only by picking acompiler that can actually target the architecture.
?=keeps any existingoverride — including the Cygwin default — working.
Testing
qemu-i486:nshon macOS 15 / Apple Silicon, Homebrewi686-elf-gcc16.1.0:i686-elf-gccis invoked and the build completes — rc 0, 3.0 MBnuttx.elf.One caveat worth recording for anyone reproducing this: the shipped
qemu-i486:nshdefconfig setsCONFIG_LIBM_TOOLCHAIN=y, which defersmath.hto the toolchain, and Homebrew's
i686-elf-gccis bare-metal with no newlibheaders. Selecting NuttX's own
CONFIG_LIBM=yinstead builds cleanly. That isindependent of this change and is not addressed here.
tools/checkpatch.sh -c -u -m -gclean.