This is an automated email from the ASF dual-hosted git repository.

michallenc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 05d975469952853918466031a853137b3dde8f57
Author: Brijesh Thakkar <[email protected]>
AuthorDate: Sun Oct 18 03:11:07 2026 +0530

    arch/sim: pass no-pie through the gcc driver in CMake.
    
    Pass -no-pie through the gcc driver instead of forwarding it as
    -Wl,-no-pie. fd907e6ef4 ("sim: pass no-pie through gcc driver") already
    did this for the Make build; the CMake build still used -Wl,-no-pie.
    
    -Wl,-no-pie bypasses the driver, so the driver still sets up a PIE
    link: it passes -pie and uses Scrt1.o and crtbeginS.o, and only then
    hands -no-pie to ld. On gcc 10 / binutils 2.34 ld then searches for
    libgcc_s.a only, which Ubuntu does not ship, and the link fails:
    
      /usr/bin/ld: cannot find -lgcc_s
      /usr/bin/ld: cannot find -lgcc_s
      collect2: error: ld returned 1 exit status
    
    -lgcc_s is reported twice because the gcc driver puts it on the link
    line both before and after -lc. libgcc-s1 and libgcc-10-dev being
    installed makes no difference. A plain hello.c linked with
    -Wl,-no-pie fails the same way while -no-pie links fine.
    
    Reproduced on ubuntu:20.04 with gcc 10.5.0-1ubuntu1~20.04 and CMake
    4.4: configure aborts in the compiler check, because the test program
    is linked with -Wl,-no-pie. Fixed with this patch: configure, build and
    boot of sim:nsh all work.
    
    Assisted-by: Claude:claude-sonnet-5-5
    Signed-off-by: Brijesh Thakkar <[email protected]>
---
 arch/sim/src/cmake/Toolchain.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sim/src/cmake/Toolchain.cmake 
b/arch/sim/src/cmake/Toolchain.cmake
index 65b8a2aae35..3b600ab781a 100644
--- a/arch/sim/src/cmake/Toolchain.cmake
+++ b/arch/sim/src/cmake/Toolchain.cmake
@@ -255,7 +255,7 @@ elseif(NOT APPLE AND NOT SIM_HOST_ARM64)
   # static archive; skipping it lets gcc use the default PIE link path which
   # works correctly on aarch64 hosts.
   add_compile_options(-no-pie)
-  add_link_options(-Wl,-no-pie)
+  add_link_options(-no-pie)
 endif()
 
 if(CONFIG_LIBCXX)

Reply via email to