arch/arm: Say which linker is missing when FDPIC has none.

Without this the build says "arm-uclinuxfdpiceabi-ld: Command not found",
which does not say what that is, where to get it, or that the prefix can be
changed.

The make build reports at the link rather than while parsing, so that a tree
configured for FDPIC on a host without the linker can still be cleaned and
reconfigured: an error at parse time takes make distclean with it.  The
cmake build reports while configuring, where nothing is built yet.

Both name FDPIC_CROSSDEV, so a linker under another prefix can be used.

Checked on mps3-an547:picostest with CONFIG_FDPIC and the linker off PATH:
make distclean succeeds, and a module link stops with the message.  With the
linker present the modules build as before.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
Marco Casaroli 2026-08-28 18:42:26 +02:00 committed by Xiang Xiao
parent 77f263b4fa
commit 69061ea246
2 changed files with 30 additions and 1 deletions

View file

@ -39,8 +39,21 @@ if(CONFIG_FDPIC)
set(FDPIC_CROSSDEV arm-uclinuxfdpiceabi-)
endif()
# Say which linker is missing rather than failing later with a command that
# cannot be run.
find_program(FDPIC_LD "${FDPIC_CROSSDEV}ld")
if(NOT FDPIC_LD)
message(
FATAL_ERROR
"CONFIG_FDPIC needs ${FDPIC_CROSSDEV}ld, which is not on PATH. "
"It is in the NuttX CI image, and tools/ci/docker/linux/Dockerfile "
"shows how it is built. Set FDPIC_CROSSDEV to use a different prefix")
endif()
set(CMAKE_ELF_LD
"${FDPIC_CROSSDEV}ld"
"${FDPIC_LD}"
CACHE INTERNAL "Linker for FDPIC modules")
nuttx_elf_compile_options(-mfdpic -fPIC -Wa,--noexecstack)

View file

@ -653,6 +653,22 @@ ifeq ($(CONFIG_FDPIC),y)
FDPIC_CROSSDEV ?= arm-uclinuxfdpiceabi-
MODULELD = $(FDPIC_CROSSDEV)ld
# Say which linker is missing rather than letting make report a command it
# cannot run. The report is deferred to the link itself rather than made
# here, so that a tree configured for FDPIC on a host without the linker can
# still be cleaned and reconfigured.
FDPIC_LD_FOUND := $(shell command -v $(MODULELD) 2> /dev/null)
ifeq ($(FDPIC_LD_FOUND),)
FDPIC_NO_LD_MSG = CONFIG_FDPIC needs $(FDPIC_CROSSDEV)ld, which is not \
on PATH. It is in the NuttX CI image, and \
tools/ci/docker/linux/Dockerfile shows how it is built. Set \
FDPIC_CROSSDEV to use a different prefix.
MODULELD = $(SHELL) -c 'echo "ERROR: $(FDPIC_NO_LD_MSG)" 1>&2; exit 1' --
endif
CELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack
CXXELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack