From 69061ea24662e86f94c4b4db45d4c354ddff08f6 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Fri, 28 Aug 2026 18:42:26 +0200 Subject: [PATCH] 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 --- arch/arm/src/cmake/elf.cmake | 15 ++++++++++++++- arch/arm/src/common/Toolchain.defs | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/cmake/elf.cmake b/arch/arm/src/cmake/elf.cmake index 91b1037d631..ab09828847c 100644 --- a/arch/arm/src/cmake/elf.cmake +++ b/arch/arm/src/cmake/elf.cmake @@ -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) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 949b7161573..a1d65803263 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -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