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