mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
Toolchain.defs adds --fixed-r10 to CFLAGS under CONFIG_PIC, but nearly
every board Make.defs includes that file and then assigns
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) ...
with ':=', which discards it. 266 of the 269 ARM board files assign
CFLAGS that way; the remaining three delegate to a shared makefile that
does the same thing.
The flag is what keeps the base firmware from allocating r10, the
register a PIC module reaches its own data through. Losing it is silent
and the symptom is remote from the cause: the build succeeds, and only a
callback from base firmware into module code -- qsort() with a module
comparison function is the standard case -- misbehaves, reading its data
through a register the firmware has since felt free to reuse.
Adding it to ARCHCFLAGS puts it on the far side of that ':=', which
re-expands ARCHCFLAGS, so every board picks it up with no board changes
at all.
A module is the other side of the --fixed-r10 contract: it gets r10 via
-mpic-register=r10, and GCC rejects both on one command line with
"unable to use 'r10' for PIC register". Every ARM board carried the
same three lines to set that up:
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
They move to arch/arm/src/common/Toolchain.defs, which also filters
--fixed-r10 back out of CPICFLAGS, CXXPICFLAGS, CELFFLAGS and
CXXELFFLAGS in one place instead of each board having to know about the
interaction. ARCHPICFLAGS uses '?=' and the derived flags use deferred
'=', so a board can still override or append after including the file,
and CFLAGS is whatever the board finally set it to.
Two boards keep a definition because they genuinely differ: am67 adds
-ffixed-r10 and tiva conditionally adds -mno-pic-data-is-text-relative.
tlsr82 previously appended -fpic to an unset variable, so only -fpic
ever reached its compiler; it now inherits the standard set, verified
against tc32-elf-gcc 4.5.1.tc32-elf-1.5 (Telink TC32 v2.0), whose
ARM-derived backend honors -msingle-pic-base and -mpic-register=r10.
The mps2, mps3, qemu-armv7a, qemu-armv7r, fvp and mcx-nxxx families
referenced ARCHPICFLAGS without ever defining it, so their CPICFLAGS
carried no PIC flags at all; they get the standard set too.
Also adds the missing space in
CXXELFFLAGS = $(CXXFLAGS)-fvisibility=hidden -mlong-calls
which ran the last token of CXXFLAGS into -fvisibility=hidden, yielding
a single malformed token such as -DNDEBUG-fvisibility=hidden.
Also exempts the pre-existing "*.siz" gsize comment in Toolchain.defs
from codespell, which reads "siz" as a misspelling and fires for any
patch touching the file, since checkpatch scans whole files rather than
changed lines.
Before, with CONFIG_PIC=y: CFLAGS has --fixed-r10: NO
After: CFLAGS has --fixed-r10: YES
CPICFLAGS/CELFFLAGS: filtered out
Assisted-by: Claude Code:claude-opus-4-8
Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
|
||
|---|---|---|
| .. | ||
| a1x/pcduino-a10 | ||
| am67/t3-gem-o1 | ||
| am335x/beaglebone-black | ||
| at32/at32f437-mini | ||
| c5471/c5471evm | ||
| common/stm32 | ||
| csk6 | ||
| cxd56xx | ||
| dm320/ntosd-dm320 | ||
| efm32 | ||
| eoss3/quickfeather | ||
| fvp-v8r-aarch32/fvp-armv8r-aarch32 | ||
| gd32f4 | ||
| ht32f491x3/esk32 | ||
| imx6/sabre-6quad | ||
| imx9 | ||
| imxrt | ||
| kinetis | ||
| kl | ||
| lc823450/lc823450-xgevk | ||
| lpc17xx_40xx | ||
| lpc31xx | ||
| lpc43xx | ||
| lpc54xx/lpcxpresso-lpc54628 | ||
| lpc214x | ||
| lpc2378/olimex-lpc2378 | ||
| max326xx/max32660-evsys | ||
| mcx-nxxx/frdm-mcxn236 | ||
| moxart/moxa | ||
| mps | ||
| mx8mp/verdin-mx8mp | ||
| nrf52 | ||
| nrf53 | ||
| nrf91 | ||
| nuc1xx/nutiny-nuc120 | ||
| phy62xx/phy6222 | ||
| qemu | ||
| ra4 | ||
| rp23xx | ||
| rp2040 | ||
| rtl8720f/rtl8720f_evb | ||
| rtl8721dx/pke8721daf | ||
| s32k1xx | ||
| s32k3xx | ||
| sam34 | ||
| sama5 | ||
| samd2l2 | ||
| samd5e5 | ||
| samv7 | ||
| stm32c0 | ||
| stm32f0 | ||
| stm32f1 | ||
| stm32f2 | ||
| stm32f3 | ||
| stm32f4 | ||
| stm32f7 | ||
| stm32g0 | ||
| stm32g4 | ||
| stm32h5 | ||
| stm32h7 | ||
| stm32l0 | ||
| stm32l1 | ||
| stm32l4 | ||
| stm32l5 | ||
| stm32n6 | ||
| stm32u5 | ||
| stm32wb | ||
| stm32wl5 | ||
| str71x/olimex-strp711 | ||
| tiva | ||
| tlsr82/tlsr8278adk80d | ||
| tms570 | ||
| xmc4 | ||