anchao commented on PR #16976: URL: https://github.com/apache/nuttx/pull/16976#issuecomment-3256866431
@trns1997 @acassis Thanks for your detailed analysis! `CONFIG_LIBC_MODLIB` has been deprecated in commit https://github.com/apache/nuttx/pull/15765 and is now named `CONFIG_LIBC_MODLIB` -> `CONFIG_LIBC_ELF` On current architectures, `gnu-elf.ld.in` requires compiler preprocessing before use, so it cannot be simply copied: https://github.com/apache/nuttx/blob/master/libs/libc/elf/Makefile#L25-L28 Since `make export` is the Nuttx SDK's export feature, it has nothing to do with whether ELF is enabled. Therefore, it is recommended to remove this check and always generate `gnu-elf.ld`: I have 2 suggestions for fixing this issue: 1. Remove the check for CONFIG_LIBC_ELF and always generate gnu-elf.ld: <img width="1017" height="496" alt="image" src="https://github.com/user-attachments/assets/015693f5-13ad-4862-8211-968e7b3593ba" /> ``` diff --git a/libs/libc/Makefile b/libs/libc/Makefile index 33bcba86d0..00c2a4f8df 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -183,9 +183,7 @@ context:: bin kbin ifeq ($(CONFIG_LIBC_ZONEINFO_ROMFS),y) $(Q) $(MAKE) -C zoneinfo context BIN=$(BIN) endif -ifeq ($(CONFIG_LIBC_ELF),y) $(Q) $(MAKE) -C elf context -endif # Dependencies ``` 2. Add a check in mkexport.sh to only copy gnu-elf.ld if CONFIG_LIBC_ELF is enabled: <img width="839" height="782" alt="image" src="https://github.com/user-attachments/assets/1f19b429-85c9-4621-b594-c3ceb0d8e3a2" /> ``` diff --git a/tools/mkexport.sh b/tools/mkexport.sh index 9d8c42d9c6..aa30c4bef4 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -123,6 +123,10 @@ if [ ! -z "${CONFIG_VERSION_STRING}" -a "${CONFIG_VERSION_STRING}" != "0.0" ]; t VERSION="-${CONFIG_VERSION_STRING}" fi +# Get the config string + +source "${TOPDIR}/.config" + # Create the export directory EXPORTSUBDIR="nuttx-export${VERSION}" @@ -184,15 +188,19 @@ cp "${TOPDIR}/tools/incdir.c" "${EXPORTDIR}/tools/." # Copy the board specific linker if found, or use the default when not. -APPLD=gnu-elf.ld -if [ -f "${BOARDDIR}/scripts/${APPLD}" ]; then - cp -f "${BOARDDIR}/scripts/${APPLD}" "${EXPORTDIR}/scripts/." -else - cp -f "${TOPDIR}/libs/libc/elf/${APPLD}" "${EXPORTDIR}/scripts/." -fi +if [ ! -z "${CONFIG_LIBC_ELF}" ]; then + APPLD=gnu-elf.ld + if [ -f "${BOARDDIR}/scripts/${APPLD}" ]; then + cp -f "${BOARDDIR}/scripts/${APPLD}" "${EXPORTDIR}/scripts/." + else + cp -f "${TOPDIR}/libs/libc/elf/${APPLD}" "${EXPORTDIR}/scripts/." + fi -if [ "${NUTTX_BUILD}" = "kernel" ]; then - LDNAME=${APPLD} + if [ "${NUTTX_BUILD}" = "kernel" ]; then + LDNAME=${APPLD} + else + LDNAME="" + fi fi # Copy the board config script ``` I prefer option 2 : ) . If you agree with either solution, please update the current PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
