Skip to content

Commit 0c30ddd

Browse files
committed
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>
1 parent a692727 commit 0c30ddd

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

arch/arm/src/cmake/elf.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,21 @@ if(CONFIG_FDPIC)
4747
set(FDPIC_CROSSDEV arm-uclinuxfdpiceabi-)
4848
endif()
4949

50+
# Say which linker is missing rather than failing later with a command that
51+
# cannot be run.
52+
53+
find_program(FDPIC_LD "${FDPIC_CROSSDEV}ld")
54+
55+
if(NOT FDPIC_LD)
56+
message(
57+
FATAL_ERROR
58+
"CONFIG_FDPIC needs ${FDPIC_CROSSDEV}ld, which is not on PATH. "
59+
"It is in the NuttX CI image, and tools/ci/docker/linux/Dockerfile "
60+
"shows how it is built. Set FDPIC_CROSSDEV to use a different prefix")
61+
endif()
62+
5063
set(CMAKE_ELF_LD
51-
"${FDPIC_CROSSDEV}ld"
64+
"${FDPIC_LD}"
5265
CACHE INTERNAL "Linker for FDPIC modules")
5366

5467
nuttx_elf_compile_options(-mfdpic -fPIC -Wa,--noexecstack)

arch/arm/src/common/Toolchain.defs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,22 @@ ifeq ($(CONFIG_FDPIC),y)
657657
FDPIC_CROSSDEV ?= arm-uclinuxfdpiceabi-
658658
MODULELD = $(FDPIC_CROSSDEV)ld
659659

660+
# Say which linker is missing rather than letting make report a command it
661+
# cannot run. The report is deferred to the link itself rather than made
662+
# here, so that a tree configured for FDPIC on a host without the linker can
663+
# still be cleaned and reconfigured.
664+
665+
FDPIC_LD_FOUND := $(shell command -v $(MODULELD) 2> /dev/null)
666+
667+
ifeq ($(FDPIC_LD_FOUND),)
668+
FDPIC_NO_LD_MSG = CONFIG_FDPIC needs $(FDPIC_CROSSDEV)ld, which is not \
669+
on PATH. It is in the NuttX CI image, and \
670+
tools/ci/docker/linux/Dockerfile shows how it is built. Set \
671+
FDPIC_CROSSDEV to use a different prefix.
672+
673+
MODULELD = $(SHELL) -c 'echo "ERROR: $(FDPIC_NO_LD_MSG)" 1>&2; exit 1' --
674+
endif
675+
660676
CELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack
661677
CXXELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack
662678

0 commit comments

Comments
 (0)