You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/06/03 07:07:32 UTC

[GitHub] [incubator-nuttx] AlexanderVasiljev opened a new pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

AlexanderVasiljev opened a new pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836


   ## Summary
   
   The flags -nostartfiles -nodefaultlibs are not the flags of LD but are the flags of GCC
   
   ## Impact
   
   Now GNU ld just doesn't recognize them.
   New GNU ld version 2.36.x will treat this as error.
   See issue https://github.com/apache/incubator-nuttx/issues/3826
   
   ## Testing
   
   custom board
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856536628


   ea3131/pgnsh fails on locked.r. GCC treat this file as fortran file. 
   
   ```
   ====================================================================================
   Configuration/Tool: ea3131/pgnsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
   ------------------------------------------------------------------------------------
     Cleaning...
     Configuring...
     Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABIL
     Enabling CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
     Building NuttX...
   arm-none-eabi-gcc: error: locked.r: Ratfor compiler not installed on this system
   make[1]: *** [Makefile:156: nuttx] Error 1
   make: *** [tools/Makefile.unix:412: nuttx] Error 2
   make: Target 'all' not remade because of errors.
   /github/workspace/sources/nuttx/tools/testbuild.sh: line 252: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
     Normalize ea3131/pgnsh
   ```
   
   I have changed defconfig.
   
   CONFIG_PASS1_OBJECT="locked.r"
   to
   CONFIG_PASS1_OBJECT="-Wl,locked.r"


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858567182


   @masayuki2009 Is your apps on the recent commit?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-855679790


   @gustavonihei  Thank you!
   
   Now I am stuck on spresense:nsh_trace.
   
   spresense:nsh - OK
   
   spresense:nsh_trace - FAILED
   
   ```
   arm-none-eabi-gcc: error: _exit: No such file or directory
   arm-none-eabi-gcc: error: exit: No such file or directory
   arm-none-eabi-gcc: error: getpid: No such file or directory
   ...
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   > 	{
   > 		FILL(0xff)
   > 
   > 		/* Order matters */
   > 
   > 		*src/imxrt_start.o(.text)
   > 		*src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change will render them unbootable, since it makes the linker fail to allocate the output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is placed on address 0x20000000, which corresponds to the beginning of the `.text` output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt vector table instead at that address, pushing the `__start` symbol to an unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly the effect of this, but it seems for these cases where the Linker is required to perform the section placement from specific input files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change and reverting the modification to the linker scripts the generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   > 	{
   > 		FILL(0xff)
   > 
   > 		/* Order matters */
   > 
   > 		*src/imxrt_start.o(.text)
   > 		*src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change will render them unbootable, since it makes the linker fail to allocate the output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is placed on address 0x20000000, which corresponds to the beginning of the `.text` output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt vector table instead at that address, pushing the `__start` symbol to an unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly the effect of this, but it seems for these cases where the Linker script needs to perform the placement from specific object files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change and reverting the modification to the linker scripts the generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei closed pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei closed pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858549128


   @masayuki2009  It have built successfully on my PC. Can you make clean? And reconfigure! Make.defs file should be relocated!
   
   ```
   CC:  sim_appinit.c
   CC:  sim_bringup.c
   AR (create): libboard.a   dummy.o sim_appinit.o sim_bringup.o 
   make[2]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/boards/sim/sim/sim/src'
   LD:  nuttx
   make[1]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/arch/sim/src'
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   > 	{
   > 		FILL(0xff)
   > 
   > 		/* Order matters */
   > 
   > 		*src/imxrt_start.o(.text)
   > 		*src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change will render them unbootable, since it makes the linker fail to allocate the output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is placed on address 0x20000000, which corresponds to the beginning of the `.text` output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt vector table instead at that address, pushing the `__start` symbol to an unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly the effect of this, but it seems for these cases where the Linker script needs to perform the placement from specific object files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T,$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change and reverting the modification to the linker scripts the generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856727916


   > riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   
   I saw that you passed the flag to GCC as `-Wl,-m,elf32lriscv`, I believe the second comma might not be necessary.
   
   > Something strange happens with riscv boards. The github workflow tries to build some configurations, which I cannot configure locally.
   > 
   > On github
   > 
   > ```
   > ====================================================================================
   > Configuration/Tool: esp32c3-devkit/elf,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   > ------------------------------------------------------------------------------------
   >   Cleaning...
   >   Configuring...
   >   Disabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   >   Enabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   >   Building NuttX...
   > riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   > make[5]: *** [Makefile:70: errno] Error 1
   > ```
   > 
   > Locally
   > 
   > ```
   > tools/configure.sh esp32c3-devkit:elf
   > Directory for esp32c3-devkit:elf does not exist.
   > ```
   > 
   > Ok, these configurations have been created recently. But why does the workflow build against them? My branch doesn't have them. Should I merge from master? But how the pull-request system will treat this merge?
   
   The CI always builds the branch after rebasing it to the HEAD of the target repository, which in this case is the **master**.
   So, in order to correctly build this new `elf` configuration, it is recommended that you do the same, because a recent commit created some new variables:
   https://github.com/apache/incubator-nuttx/commit/dd4962b2f8d3d98d5bef03b433c32fdd1bc62340


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648240005



##########
File path: boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs
##########
@@ -51,8 +51,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections

Review comment:
       `--warn-common` is also the correct, with two dashes.
   Let's address everything later.

##########
File path: boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs
##########
@@ -51,8 +51,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections

Review comment:
       `--warn-common` is also the correct, with two dashes.
   Let's address everything later in another 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858549128


   @masayuki2009  It have built successfully on my PC. Can you make clean?
   
   ```
   CC:  sim_appinit.c
   CC:  sim_bringup.c
   AR (create): libboard.a   dummy.o sim_appinit.o sim_bringup.o 
   make[2]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/boards/sim/sim/sim/src'
   LD:  nuttx
   make[1]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/arch/sim/src'
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856651406


   Following configurations have multiple definition of `__start'
   
   > imxrt1060-evk/nshocram
   > imxrt1064-evk/nshocram
   > raspberrypi-pico/nshsram
   
   It is due to they insert object files in ld scripts and then pass them to gcc.
   
   ```
   SECTIONS
   {
       .text : {
           _stext = ABSOLUTE(.);
           rp2040_start.o(.text)
           . = ALIGN(256);
           *(.vectors)
           *(.text .text.*)
   
   ```
   
    ```
    .flashxip : ALIGN(4)
   	{
   		FILL(0xff)
   
   		/* Order matters */
   
   		imxrt_start.o(.text)
   		imxrt_boot.o(.text)
   
   ```
   
   Log
   
   ```
   
   Building NuttX...
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: imxrt_start.o: in function `__start':
   imxrt_start.c:(.text+0x0): multiple definition of `__start'; /github/workspace/sources/nuttx/staging/libarch.a(imxrt_start.o):imxrt_start.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_ocram_initialize':
   imxrt_boot.c:(.text+0x0): multiple definition of `imxrt_ocram_initialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_boardinitialize':
   imxrt_boot.c:(.text+0x44): multiple definition of `imxrt_boardinitialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x44): first defined here
   ```
   
   
   It seems that LD can deal with such situation. Gcc not.
   
   
   I found a solution. It compiles. But I cannot test if it works
   ```
   .flashxip : ALIGN(4)
   	{
   		FILL(0xff)
   
   		/* Order matters */
   
   		*src/imxrt_start.o(.text)
   		*src/imxrt_boot.o(.text)
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856737522


   > @gustavonihei This is the right form -Wl,-m,elf32lriscv
   > 
   > The problem is that I don't have esp32c3-devkit/elf configuration locally, so I cannot correct it.
   > 
   > Anyway I gave up to correct RISCV. I have changed back it to LD.
   
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859149602


   > By the way, in places like this:
   > 
   > ```
   > NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
   > ```
   > 
   > Why does the `-r` option need to remain without `-Wl,`?
   
   `-r` is a link option processed by the GCC driver, so it needs to be forwarded to the linker:
   
   https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#:~:text=produce%20a%20relocatable%20object%20as%20output.%20this%20is%20also%20known%20as%20partial%20linking.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r650172969



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       I've successfully with
   
   In my Ubuntu 21.04 machine, I've just successfully built `sim:nsh` with clang. For forcing the `clang` compiler since it's not symlinked to `cc`, I've applied the following patch:
   ```patch
   diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
   index 067914aea2..0d2a861890 100644
   --- a/boards/sim/sim/sim/scripts/Make.defs
   +++ b/boards/sim/sim/sim/scripts/Make.defs
   @@ -80,10 +80,10 @@ ifeq ($(CONFIG_SIM_M32),y)
      ARCHCPUFLAGSXX += -m32
    endif
    
   -CC = $(CROSSDEV)cc
   -CXX = $(CROSSDEV)c++
   -CPP = $(CROSSDEV)cc -E -P -x c
   -LD = $(CROSSDEV)gcc
   +CC = $(CROSSDEV)clang
   +CXX = $(CROSSDEV)clang++
   +CPP = $(CROSSDEV)clang -E -P -x c
   +LD = $(CROSSDEV)clang
    ifeq ($(CONFIG_HOST_MACOS),y)
    STRIP = $(CROSSDEV)strip
    AR = $(TOPDIR)/tools/macar-rcs.sh
   ```
   Also, I've successfully built `sim:nsh` on **macOS** with clang as the default compiler.
   
   @lulingar, from the command line you've posted we can see that `--start-group` was incorrectly passed instead of `-Wl,--start-group`. Have you performed a `distclean` after you pulled the latest changes from upstream? Since the Makefiles from the board were changed, these are not automatically refreshed by `make` because the NuttX build system makes a copy of them on the target `configure` step.

##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       In my Ubuntu 21.04 machine, I've just successfully built `sim:nsh` with clang. For forcing the `clang` compiler since it's not symlinked to `cc`, I've applied the following patch:
   ```patch
   diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
   index 067914aea2..0d2a861890 100644
   --- a/boards/sim/sim/sim/scripts/Make.defs
   +++ b/boards/sim/sim/sim/scripts/Make.defs
   @@ -80,10 +80,10 @@ ifeq ($(CONFIG_SIM_M32),y)
      ARCHCPUFLAGSXX += -m32
    endif
    
   -CC = $(CROSSDEV)cc
   -CXX = $(CROSSDEV)c++
   -CPP = $(CROSSDEV)cc -E -P -x c
   -LD = $(CROSSDEV)gcc
   +CC = $(CROSSDEV)clang
   +CXX = $(CROSSDEV)clang++
   +CPP = $(CROSSDEV)clang -E -P -x c
   +LD = $(CROSSDEV)clang
    ifeq ($(CONFIG_HOST_MACOS),y)
    STRIP = $(CROSSDEV)strip
    AR = $(TOPDIR)/tools/macar-rcs.sh
   ```
   Also, I've successfully built `sim:nsh` on **macOS** with clang as the default compiler.
   
   @lulingar, from the command line you've posted we can see that `--start-group` was incorrectly passed instead of `-Wl,--start-group`. Have you performed a `distclean` after you pulled the latest changes from upstream? Since the Makefiles from the board were changed, these are not automatically refreshed by `make` because the NuttX build system makes a copy of them on the `configure` step.

##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       In my Ubuntu 21.04 machine, I've just successfully built `sim:nsh` with clang. For forcing the `clang` compiler since it's not symlinked to `cc`, I've applied the following patch:
   ```patch
   diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
   index 067914aea2..0d2a861890 100644
   --- a/boards/sim/sim/sim/scripts/Make.defs
   +++ b/boards/sim/sim/sim/scripts/Make.defs
   @@ -80,10 +80,10 @@ ifeq ($(CONFIG_SIM_M32),y)
      ARCHCPUFLAGSXX += -m32
    endif
    
   -CC = $(CROSSDEV)cc
   -CXX = $(CROSSDEV)c++
   -CPP = $(CROSSDEV)cc -E -P -x c
   -LD = $(CROSSDEV)gcc
   +CC = $(CROSSDEV)clang
   +CXX = $(CROSSDEV)clang++
   +CPP = $(CROSSDEV)clang -E -P -x c
   +LD = $(CROSSDEV)clang
    ifeq ($(CONFIG_HOST_MACOS),y)
    STRIP = $(CROSSDEV)strip
    AR = $(TOPDIR)/tools/macar-rcs.sh
   ```
   Also, I've successfully built `sim:nsh` on **macOS** with clang as the default compiler.
   
   @lulingar, from the command line you've posted we can see that `--start-group` was incorrectly passed instead of `-Wl,--start-group`. Have you performed a `distclean` after you pulled the latest changes from upstream? Since the Makefiles from the board were changed, these are not automatically refreshed by `make` because the NuttX build system makes a copy of them on the `./tools/configure.sh` step.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856651406


   Following configurations have multiple definition of `__start'
   
   > imxrt1060-evk/nshocram
   > imxrt1064-evk/nshocram
   > raspberrypi-pico/nshsram
   
   It is due to they insert object files in ld scripts and then pass them to gcc.
   
   ```
   SECTIONS
   {
       .text : {
           _stext = ABSOLUTE(.);
           rp2040_start.o(.text)
           . = ALIGN(256);
           *(.vectors)
           *(.text .text.*)
   
   ```
   
    ```
    .flashxip : ALIGN(4)
   	{
   		FILL(0xff)
   
   		/* Order matters */
   
   		imxrt_start.o(.text)
   		imxrt_boot.o(.text)
   
   ```
   
   Log
   
   ```
   
   Building NuttX...
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: imxrt_start.o: in function `__start':
   imxrt_start.c:(.text+0x0): multiple definition of `__start'; /github/workspace/sources/nuttx/staging/libarch.a(imxrt_start.o):imxrt_start.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_ocram_initialize':
   imxrt_boot.c:(.text+0x0): multiple definition of `imxrt_ocram_initialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_boardinitialize':
   imxrt_boot.c:(.text+0x44): multiple definition of `imxrt_boardinitialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x44): first defined here
   ```
   
   
   It seems that LD can deal with such situation. Gcc not.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853845272


   @davids5 , please, see issue #3826 and my question on binutlis https://sourceware.org/pipermail/binutils/2021-June/116825.html
   Linker just ignored these flags


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853877230


   @davids5 @gustavonihei  OK, I will try to change LD for GCC in this pull request.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853882164


   I will start with armv7-m. 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853843183


   Do we have any idea how the linker was interpreting these and what the effect was?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853785193


   > It is not so simple.
   > 
   > ```
   > LD: nuttx
   > arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   > arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   > ```
   
   Yeah, these flags and some others are specific to LD, so when provided to the GCC frontend they must be provided with `-Wl,--start-group`


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] hartmannathan commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
hartmannathan commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859123970


   By the way, in places like this:
   
   ```
   NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
   ```
   
   Why does the `-r` option need to remain without `-Wl,`?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853753487


   I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   
   I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   This change will also be needed for supporting LTO builds, eventually.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-854814831


   @xiaoxiang781216 When all the tests will pass, I will squash them.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853878837


   > > @v01d - any implication on the Cmake side?
   > 
   > Not really, cmake is much clearer about the distinction between compiler/linker flags so I did not encounter this issue.
   
   A related comment could be that in fact CMake does not normally access `ld` directly (it uses the compiler to link). This means that I had to account for the `-Wl` and other issues arising from this difference. 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853869408


   @gustavonihei -On a separate note for a future feature with LTO it would be great to get it working,
   
   I have seen it destroy working code when we needed the size saving. I did not dig into it as the time, nor do I want to have to just because of an NuttX upgrade. So please consider Kconfig control (with it off by default)  


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-857869496


   @hartmannathan please note this change.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] lulingar commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
lulingar commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r649190581



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       This is breaking our clang-based build. Our build fails like:
   
       echo "LD:  nuttx"
       LD:  nuttx
       gcc -r  -L"/nuttx/staging" -L board  -o nuttx.rel up_head.o -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lnet -lfs -lbinfmt -lboard  -Wl,--end-group
       /bin/sh: 1: gcc: not found
       make[1]: Leaving directory '/nuttx/arch/sim/src'
       make[1]: *** [Makefile:314: nuttx] Error 127
       make: *** [tools/Makefile.unix:422: nuttx] Error 2
       The command '/bin/sh -c bear -v make -j $(grep -c ^processor /proc/cpuinfo) V=2' returned a non-zero code: 2
       make: *** [process/Build.mk:39: builder] Error 
   
   Previously it was:
   
       ld -r  -L"/nuttx/staging" -L board  -o nuttx.rel up_head.o --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lnet -lfs -lbinfmt -lboard  --end-group
   
   Certainly I agree with the suggestion this change should have been widely advertised before merging.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858544411


   Hmmm, my build test failed.
   
   ```
   make[2]: Leaving directory '/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/boards/sim/sim/sim/src'
   CPP:  nuttx-names.in-> nuttx-names.dat
   cc -E -P -x c -isystem "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/include" -D__NuttX__ -U_AIX -U_WIN32 -U__APPLE__ -U__FreeBSD__ -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__ -D__KERNEL__ -Wno-cpp -Werror -fshort-wchar -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src" -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src/chip" -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/sched"   nuttx-names.in -o  nuttx-names.dat
   echo "LD:  nuttx"
   LD:  nuttx
   gcc -r  -L"/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/staging" -L board  -o nuttx.rel up_head.o up_smpsignal.o -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard  -Wl,--end-group
   /usr/bin/ld: cannot find -lgcc_s
   /usr/bin/ld: cannot find -lgcc_s
   collect2: error: ld returned 1 exit status
   Makefile:313: recipe for target 'nuttx' failed
   make[1]: *** [nuttx] Error 1
   make[1]: Leaving directory '/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src'
   tools/Makefile.unix:422: recipe for target 'nuttx' failed
   make: *** [nuttx] Error 2
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648242527



##########
File path: boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs
##########
@@ -29,9 +29,9 @@ else ifeq ($(CONFIG_BOOT_RUNFROMISRAM),y)
 endif
 
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
+  ARCHSCRIPT = -Wl,-T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"

Review comment:
       ```suggestion
     ARCHSCRIPT = -Wl,-T"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   ```
   We need to add commas where there were spaces to maintain the same behavior.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 removed a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
Ouss4 removed a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853771707


   > I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   > `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   > 
   > I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   > This change will also be needed for supporting LTO builds, eventually.
   
   Please take a look at the linked issue.  Those are options for `xx-gcc` not `xx-ld`.  We send `LDFLAGS` to `xx-ld` which is now throwing errors when unrecognized options are supplied.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853864965


   @v01d - any implication on the Cmake side?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r649371107



##########
File path: arch/arm/src/Makefile
##########
@@ -93,8 +93,8 @@ LDFLAGS += $(ARCHSCRIPT) $(EXTRALINKCMDS)
 
 # Override in Make.defs if linker is not 'ld'

Review comment:
       Actually this comment still applies, since the GCC driver will call LD to perform the linking process.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648238557



##########
File path: boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs
##########
@@ -51,8 +51,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections

Review comment:
       I don't know if this should be addressed by this PR, but it seems the correct flag is `--no-check-sections`:
   https://sourceware.org/binutils/docs/ld/Options.html#:~:text=--no-check-sections




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-857885779


   @AlexanderVasiljev - what sort of announcement did you want to make? 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858236227


   Nice idea, let do it.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853872778


   > @v01d - any implication on the Cmake side?
   
   Not really, cmake is much clearer about the distinction between compiler/linker flags so I did not encounter this issue.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r647499010



##########
File path: boards/risc-v/mpfs/icicle/scripts/Make.defs
##########
@@ -95,4 +95,4 @@ endif
 
 # File extensions
 
-LDFLAGS += --gc-sections -melf64lriscv
+LDFLAGS += --gc-sections -m,elf64lriscv

Review comment:
       I am in progress




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858549128


   @masayuki2009  It have built successfully on my PC. Can you make clean? And reconfigure! Make.def file should be relocated!
   
   ```
   CC:  sim_appinit.c
   CC:  sim_bringup.c
   AR (create): libboard.a   dummy.o sim_appinit.o sim_bringup.o 
   make[2]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/boards/sim/sim/sim/src'
   LD:  nuttx
   make[1]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/arch/sim/src'
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853785193


   > It is not so simple.
   > 
   > ```
   > LD: nuttx
   > arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   > arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   > ```
   
   Yeah, these flags and some others are specific to LD, so when provided to the GCC frontend they must be provided with `-Wl,--start-group`
   
   Other changes that I have locally here for a previous attempt to enable the LTO build:
   
   ```patch
   -LDSTARTGROUP ?= --start-group
   -LDENDGROUP ?= --end-group
   +LDSTARTGROUP ?= -Wl,--start-group
   +LDENDGROUP ?= -Wl,--end-group
    LDFLAGS += $(ARCHSCRIPT)
    
    BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
   @@ -103,7 +103,7 @@ board/libboard$(LIBEXT):
    
    nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT)
           @echo "LD: nuttx"
   -       $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
   +       $(Q) $(LD) -Wl,--entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
                   -o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \
                   $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
    ifneq ($(CONFIG_WINDOWS_NATIVE),y)
   ```
   ```patch
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  LDFLAGS += -Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" --cref
   +  LDFLAGS += -Wl,-Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" -Wl,--cref
    else
   -  LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref
   +  LDFLAGS += -Wl,-Map=$(TOPDIR)/nuttx.map -Wl,--cref
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648250471



##########
File path: boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs
##########
@@ -51,8 +51,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections

Review comment:
       https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html#:~:text=for%20options%20whose%20names%20are%20multiple%20letters%2C%20either%20one%20dash%20or%20two%20can%20precede%20the%20option%20name
   
   Yeah, LD accepts both ways.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   > 	{
   > 		FILL(0xff)
   > 
   > 		/* Order matters */
   > 
   > 		*src/imxrt_start.o(.text)
   > 		*src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change will render them unbootable, since it makes the linker fail to allocate the output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is placed on address 0x20000000, which corresponds to the beginning of the `.text` output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt vector table instead at that address, pushing the __start symbol to an unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly the effect of this, but it seems for these cases where the Linker script needs to perform the placement from specific object files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T,$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change the generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858693582


   @masayuki2009 I have just installed Ubuntu 18.04. I can see the same error. I will investigate it.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853872778






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] hartmannathan commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
hartmannathan commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858042976


   > @hartmannathan please note this change.
   
   @xiaoxiang781216 I think we need to Label all PRs that need to be mentioned in next Release Notes. I am thinking to call the label NextReleaseNotes. Would that work? Then we will have to remove each label once the PR is documented.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859149602


   > By the way, in places like this:
   > 
   > ```
   > NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
   > ```
   > 
   > Why does the `-r` option need to remain without `-Wl,`?
   
   `-r` is a link option processed by the GCC driver, so it does need to be forwarded to the linker:
   
   https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#:~:text=produce%20a%20relocatable%20object%20as%20output.%20this%20is%20also%20known%20as%20partial%20linking.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858546542


   @masayuki2009 What is your config name?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r649199464



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       ```patch
   diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
   index 65600e15ec..e4615f12f1 100644
   --- a/boards/sim/sim/sim/scripts/Make.defs
   +++ b/boards/sim/sim/sim/scripts/Make.defs
   @@ -83,7 +83,7 @@ endif
    CC = $(CROSSDEV)cc
    CXX = $(CROSSDEV)c++
    CPP = $(CROSSDEV)cc -E -P -x c
   -LD = $(CROSSDEV)gcc
   +LD = $(CROSSDEV)cc
    ifeq ($(CONFIG_HOST_MACOS),y)
    STRIP = $(CROSSDEV)strip
    AR = $(TOPDIR)/tools/macar-rcs.sh
   ```
   @lulingar Please, try applying this patch




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] lulingar commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
lulingar commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r650933355



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       Thank you for the indications. I have tested aliasing clang as gcc, after the merge of #3904, and it worked.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   > 	{
   > 		FILL(0xff)
   > 
   > 		/* Order matters */
   > 
   > 		*src/imxrt_start.o(.text)
   > 		*src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change will render them unbootable, since it makes the linker fail to allocate the output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is placed on address 0x20000000, which corresponds to the beginning of the `.text` output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt vector table instead at that address, pushing the `__start` symbol to an unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly why, but it seems for these cases where the Linker is required to perform the section placement from specific input files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change and reverting the modification to the linker scripts the generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853912652


   Linker specific flags are used intensively in NXFLATLDFLAGS1 and NXFLATLDFLAGS2 macros. But I cannot find where they 
    are used and how to test them.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853771707


   > I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   > `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   > 
   > I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   > This change will also be needed for supporting LTO builds, eventually.
   
   Please take a look at the linked issue.  Those are options for `xx-gcc` not `xx-ld`.  We send `LDFLAGS` to `xx-ld` which is now throwing errors when unrecognized options are supplied.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858544411


   Hmmm, my build test on ubuntu 18.04 x86_64 failed.
   
   ```
   make[2]: Leaving directory '/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/boards/sim/sim/sim/src'
   CPP:  nuttx-names.in-> nuttx-names.dat
   cc -E -P -x c -isystem "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/include" -D__NuttX__ -U_AIX -U_WIN32 -U__APPLE__ -U__FreeBSD__ -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__ -D__KERNEL__ -Wno-cpp -Werror -fshort-wchar -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src" -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src/chip" -I "/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/sched"   nuttx-names.in -o  nuttx-names.dat
   echo "LD:  nuttx"
   LD:  nuttx
   gcc -r  -L"/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/staging" -L board  -o nuttx.rel up_head.o up_smpsignal.o -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard  -Wl,--end-group
   /usr/bin/ld: cannot find -lgcc_s
   /usr/bin/ld: cannot find -lgcc_s
   collect2: error: ld returned 1 exit status
   Makefile:313: recipe for target 'nuttx' failed
   make[1]: *** [nuttx] Error 1
   make[1]: Leaving directory '/mnt/m2ssd/opensource/github_masayuki2009-buildtest2/nuttx/arch/sim/src'
   tools/Makefile.unix:422: recipe for target 'nuttx' failed
   make: *** [nuttx] Error 2
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853789146


   > > It is not so simple.
   > > ```
   > > LD: nuttx
   > > arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   > > arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   > > ```
   > 
   > Yeah, these flags and some others are specific to LD, so when provided to the GCC frontend they must be provided with `-Wl,--start-group`
   
   
   Other changes that I have locally here for a previous attempt to enable the LTO build:
   
   ```patch
   -LDSTARTGROUP ?= --start-group
   -LDENDGROUP ?= --end-group
   +LDSTARTGROUP ?= -Wl,--start-group
   +LDENDGROUP ?= -Wl,--end-group
    LDFLAGS += $(ARCHSCRIPT)
    
    BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
   @@ -103,7 +103,7 @@ board/libboard$(LIBEXT):
    
    nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT)
           @echo "LD: nuttx"
   -       $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
   +       $(Q) $(LD) -Wl,--entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
                   -o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \
                   $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
    ifneq ($(CONFIG_WINDOWS_NATIVE),y)
   ```
   ```patch
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  LDFLAGS += -Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" --cref
   +  LDFLAGS += -Wl,-Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" -Wl,--cref
    else
   -  LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref
   +  LDFLAGS += -Wl,-Map=$(TOPDIR)/nuttx.map -Wl,--cref
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853785193


   > It is not so simple.
   > 
   > ```
   > LD: nuttx
   > arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   > arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   > ```
   
   Yeah, these flags and some others are specific to LD, so when provided to the GCC frontend they must be provided with `-Wl,--start-group`


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-854813982


   let's sqush all patch into one.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853783167






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-854926356


   > I am currently stuck with quickfeather/nsh config. If anyone knows anything about this configuration please help.
   > 
   > ```
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(exit.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(exit.o)
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o)
   > ```
   > 
   > I also tried to change ld to gcc on mips, renesas, x86 and x86-64, but failed to build. I can completely rewrite makefiles, but i don't know why they were written as they were written.
   
   It seems that `quickfeather` is missing `-nostartfiles` and  `-nodefaultlibs` flags.
   Besides the changes you've already applied, I got to make it build by applying the following patch:
   
   ```patch
   diff --git a/boards/arm/eoss3/quickfeather/scripts/Make.defs b/boards/arm/eoss3/quickfeather/scripts/Make.defs
   index 0f9a6105d0..d551850980 100644
   --- a/boards/arm/eoss3/quickfeather/scripts/Make.defs
   +++ b/boards/arm/eoss3/quickfeather/scripts/Make.defs
   @@ -63,6 +63,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
    CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
    AFLAGS := $(CFLAGS) -D__ASSEMBLY__
    
   -NXFLATLDFLAGS1 = -r -d -warn-common
   +LDFLAGS += -nostartfiles -nodefaultlibs
   +
   +NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
    NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
    LDNXFLATFLAGS = -e main -s 2048
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858608424


   > I gave up to migrate x86. Could you explain why -static is needed there?
   
   @AlexanderVasiljev 
   When I added the change, I had link errors with gcc on my Ubuntu 18.04 x86_64.
   However, I've just confirmed that there is no error without -static option.
   
   >Doesn't your toolchain have -static flag by default?
   
   How can I confirm it?
   My gcc shows
   
   ```
   $ gcc -v
   Using built-in specs.
   COLLECT_GCC=gcc
   COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
   OFFLOAD_TARGET_NAMES=nvptx-none
   OFFLOAD_TARGET_DEFAULT=1
   Target: x86_64-linux-gnu
   Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --ho
 st=x86_64-linux-gnu --target=x86_64-linux-gnu
   Thread model: posix
   gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
   ```
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859482404


   > @masayuki2009 Please, try this patch
   
   @AlexanderVasiljev 
   Thanks! The patch works with Ubuntu 18.04 x86_64.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858356037


   > @AlexanderVasiljev - what sort of announcement did you want to make?
   
   This commit will break almost every out of tree arm board. It will be easy to fix, but people should be aware of it. To mention it in the release notes is something what i mean.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 merged pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 merged pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856651406


   Following configurations have multiple definition of `__start'
   
   > imxrt1060-evk/nshocram
   > imxrt1064-evk/nshocram
   > raspberrypi-pico/nshsram
   
   It is due to they insert object files in ld scripts and then pass them to gcc.
   
   ```
   SECTIONS
   {
       .text : {
           _stext = ABSOLUTE(.);
           rp2040_start.o(.text)
           . = ALIGN(256);
           *(.vectors)
           *(.text .text.*)
   
   ```
   
    ```
    .flashxip : ALIGN(4)
   	{
   		FILL(0xff)
   
   		/* Order matters */
   
   		imxrt_start.o(.text)
   		imxrt_boot.o(.text)
   
   ```
   
   Log
   
   ```
   
   Building NuttX...
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: imxrt_start.o: in function `__start':
   imxrt_start.c:(.text+0x0): multiple definition of `__start'; /github/workspace/sources/nuttx/staging/libarch.a(imxrt_start.o):imxrt_start.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_ocram_initialize':
   imxrt_boot.c:(.text+0x0): multiple definition of `imxrt_ocram_initialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x0): first defined here
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/arch/arm/src/board/imxrt_boot.o: in function `imxrt_boardinitialize':
   imxrt_boot.c:(.text+0x44): multiple definition of `imxrt_boardinitialize'; /github/workspace/sources/nuttx/arch/arm/src/board/libboard.a(imxrt_boot.o):imxrt_boot.c:(.text+0x44): first defined here
   ```
   
   
   It seems that LD can deal with such situation. Gcc not.
   
   
   I found a solution. It compiles. But I cannot test if it works
   ```
   
   *src/imxrt_start.o(.text)
   *src/imxrt_boot.o(.text)
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859360824






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853873157


   > @gustavonihei -On a separate note for a future feature with LTO it would be great to get it working,
   > 
   > I have seen it destroy working code when we needed the size saving. I did not dig into it as the time, nor do I want to have to just because of an NuttX upgrade. So please consider Kconfig control (with it off by default)
   
   Yes, I have done a quick attempt at enabling the LTO build for ESP32, and I haven't assessed what exactly had been removed, but that's how far I've got.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] lulingar commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
lulingar commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r649190581



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       This is breaking our clang-based build.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-857466612


   The check failed with
   
   ```
   Error response from daemon: unauthorized: GitHub Docker Registry needs login
   Error: Process completed with exit code 1.
   ```
   
   How to rerun a workflow?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-854926356


   > I am currently stuck with quickfeather/nsh config. If anyone knows anything about this configuration please help.
   > 
   > ```
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(exit.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(exit.o)
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   > /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o)
   > ```
   > 
   > I also tried to change ld to gcc on mips, renesas, x86 and x86-64, but failed to build. I can completely rewrite makefiles, but i don't know why they were written as they were written.
   
   It seems that `quickfeather` is missing `-nostartfiles` and  `-nodefaultlibs` flags.
   Besides the changes you've already applied, I got to make it build by applying the following patch:
   
   ```patch
   diff --git a/boards/arm/eoss3/quickfeather/scripts/Make.defs b/boards/arm/eoss3/quickfeather/scripts/Make.defs
   index 0f9a6105d0..d551850980 100644
   --- a/boards/arm/eoss3/quickfeather/scripts/Make.defs
   +++ b/boards/arm/eoss3/quickfeather/scripts/Make.defs
   @@ -63,6 +63,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
    CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
    AFLAGS := $(CFLAGS) -D__ASSEMBLY__
    
   -NXFLATLDFLAGS1 = -r -d -warn-common
   +LDFLAGS := -nostartfiles -nodefaultlibs
   +
   +NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
    NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
    LDNXFLATFLAGS = -e main -s 2048
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858551238


   > @masayuki2009 It have built successfully on my PC. Can you make clean?
   > 
   > ```
   > CC:  sim_appinit.c
   > CC:  sim_bringup.c
   > AR (create): libboard.a   dummy.o sim_appinit.o sim_bringup.o 
   > make[2]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/boards/sim/sim/sim/src'
   > LD:  nuttx
   > make[1]: Leaving directory '/home/avasiljev/dv/spectran/remkomplekt/embedded/mainBoard/tmpflags/incubator-nuttx/arch/sim/src'
   > ```
   
   Yes. I tried git clean -fdx for both directories before rebuilding the target.
   Can you try make V=1 -j7
   
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853783167


   It is not so simple.
   
   ```
   LD: nuttx
   arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   ```
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856555396


   Something strange happens with riscv boards. The github workflow tries to build some configurations, which I cannot configure locally.
   
   On github
   ```
   ====================================================================================
   Configuration/Tool: esp32c3-devkit/elf,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   ------------------------------------------------------------------------------------
     Cleaning...
     Configuring...
     Disabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Enabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Building NuttX...
   riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   make[5]: *** [Makefile:70: errno] Error 1
   ```
   
   
   Locally
   
   ```
   tools/configure.sh esp32c3-devkit:elf
   Directory for esp32c3-devkit:elf does not exist.
   
   ```
   
   
   Ok, these configurations have been created recently. But why does the workflow build against them? My branch doesn't have them. Should I merge from master? But how the pull-request system will treat this merge?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r647495056



##########
File path: boards/risc-v/mpfs/icicle/scripts/Make.defs
##########
@@ -95,4 +95,4 @@ endif
 
 # File extensions
 
-LDFLAGS += --gc-sections -melf64lriscv
+LDFLAGS += --gc-sections -m,elf64lriscv

Review comment:
       Since `risc-v` boards are not covered by the PR anymore, this change should be reverted.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] yamt commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
yamt commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859143242


   why do we need -nostartfiles -nodefaultlibs at all?
   my understanding is that these options controls how cc generates ld command line arguments.
   i don't see how it matters while we use ld directly.
   
   besides, having cc as LD is very confusing.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853774308


   As @gustavonihei suggest that the right fix is change LD to xxx-gcc.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856555396


   Something strange happens with riscv boards. The github workflow tries to build some configurations, which I cannot configure locally.
   
   On github
   ```
   ====================================================================================
   Configuration/Tool: esp32c3-devkit/elf,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   ------------------------------------------------------------------------------------
     Cleaning...
     Configuring...
     Disabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Enabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Building NuttX...
   riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   make[5]: *** [Makefile:70: errno] Error 1
   ```
   
   
   Locally
   
   ```
   tools/configure.sh esp32c3-devkit:elf
   Directory for esp32c3-devkit:elf does not exist.
   
   ```
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856536628


   ea3131/pgnsh fails on locked.r. GCC treat this file as fortran file. Should I change extension?
   
   ```
   ====================================================================================
   Configuration/Tool: ea3131/pgnsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
   ------------------------------------------------------------------------------------
     Cleaning...
     Configuring...
     Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABIL
     Enabling CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
     Building NuttX...
   arm-none-eabi-gcc: error: locked.r: Ratfor compiler not installed on this system
   make[1]: *** [Makefile:156: nuttx] Error 1
   make: *** [tools/Makefile.unix:412: nuttx] Error 2
   make: Target 'all' not remade because of errors.
   /github/workspace/sources/nuttx/tools/testbuild.sh: line 252: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
     Normalize ea3131/pgnsh
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-857100867


   > **I still haven't figured out exactly why**, but it seems for these cases where the Linker is required to perform the section placement from specific input files we need to forward the linker script file to the linker:
   > 
   > ```diff
   > diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   > index 2f810badf8..5f58732ab4 100644
   > --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   > +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   > @@ -30,9 +30,9 @@ else
   >  endif
   >  
   >  ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   > -  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   > +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   >  else
   > -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   > +  ARCHSCRIPT = -Wl,-T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   >  endif
   >  
   >  ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   > ```
   > 
   > After this change and reverting the modification to the linker scripts the generated output was correct.
   
   I think now I got to figure it out (maybe not completely).
   
   Functionality-wise there is no difference between passing the linker script via **-T** and **-Wl,-T**, but it will impact on the order of arguments that will be provided to the **collect2** internal GCC command, which is the one that invokes the actual linker.
   
   **-T** will be interpreted by the GCC driver and will be added to the `COLLECT_GCC_OPTIONS`, which is an environment variable used by GCC to store arguments that will be passed to its subprocesses.
   **-Wl,-T**, on the other hand, explicitly tells GCC that the **-T** flag shall be forwarded to the linker, so it won't be added to `COLLECT_GCC_OPTIONS` environment variable.
   
   The difference in the results lies in how GCC parses the flags from `COLLECT_GCC_OPTIONS` and add them no the `collect2` command line.
   The `multiple definition` error occurs because **-T** flag is processed by **collect2** after the `--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard -lgcc -lm --end-group` libraries.
   
   See the output from the verbose builds:
   
   ### Using -T
   ```shell
   $ arm-none-eabi-gcc --verbose -Wl,--entry=__start -nostartfiles -nodefaultlibs -g -T/home/nihei/Projects/NuttX/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld  -L"/home/nihei/Projects/NuttX/nuttx/staging" -L"/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board" -L "/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp" -L "/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp" -o "/home/nihei/Projects/NuttX/nuttx/nuttx" -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard -lgcc -lm -Wl,--end-group
   Using built-in specs.
   COLLECT_GCC=arm-none-eabi-gcc
   COLLECT_LTO_WRAPPER=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/lto-wrapper
   Target: arm-none-eabi
   Configured with: /mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/src/gcc/configure --target=arm-none-eabi --prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native --libexecdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/lib --infodir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plu
 gins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/arm-none-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-gmp=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpfr=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpc=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-isl=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/u
 sr --with-libelf=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain 10-2020-q4-major' --with-multilib-list=rmprofile,aprofile
   Thread model: single
   Supported LTO compression algorithms: zlib
   gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major) 
   COMPILER_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/
   LIBRARY_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi/lib/
   COLLECT_GCC_OPTIONS='-v' '-nostartfiles' '-nodefaultlibs' '-g' '-T' '/home/nihei/Projects/NuttX/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld' '-L/home/nihei/Projects/NuttX/nuttx/staging' '-L/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp' '-o' '/home/nihei/Projects/NuttX/nuttx/nuttx' '-mcpu=arm7tdmi' '-mfloat-abi=soft' '-marm' '-march=armv4t'
   *****************************************************************************************************************************
   /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/collect2 -plugin /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/liblto_plugin.so -plugin-opt=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccDnGwsd.res --sysroot=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi -X -o /home/nihei/Projects/NuttX/nuttx/nuttx -L/home/nihei/Projects/NuttX/nuttx/staging -L/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1 -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-e
 abi/lib -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi/lib --entry=__start --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard -lgcc -lm --end-group -T /home/nihei/Projects/NuttX/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld
   *****************************************************************************************************************************
   /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: rp2040_start.o: in function `__start':
   /home/nihei/Projects/NuttX/nuttx/arch/arm/src/chip/rp2040_start.c:52: multiple definition of `__start'; /home/nihei/Projects/NuttX/nuttx/staging/libarch.a(rp2040_start.o):/home/nihei/Projects/NuttX/nuttx/arch/arm/src/chip/rp2040_start.c:52: first defined here
   /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: rp2040_start.o:/home/nihei/Projects/NuttX/nuttx/arch/arm/src/chip/rp2040_start.c:52: multiple definition of `g_idle_topstack'; /home/nihei/Projects/NuttX/nuttx/staging/libarch.a(rp2040_start.o):/home/nihei/Projects/NuttX/nuttx/arch/arm/src/chip/rp2040_start.c:52: first defined here
   collect2: error: ld returned 1 exit status
   ```
   
   ### Using -Wl,-T
   ```shell
   $ arm-none-eabi-gcc --verbose -Wl,--entry=__start -nostartfiles -nodefaultlibs -g -Wl,-T/home/nihei/Projects/NuttX/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld  -L"/home/nihei/Projects/NuttX/nuttx/staging" -L"/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board" -L "/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp" -L "/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp" -o "/home/nihei/Projects/NuttX/nuttx/nuttx" -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard -lgcc -lm -Wl,--end-group
   Using built-in specs.
   COLLECT_GCC=arm-none-eabi-gcc
   COLLECT_LTO_WRAPPER=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/lto-wrapper
   Target: arm-none-eabi
   Configured with: /mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/src/gcc/configure --target=arm-none-eabi --prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native --libexecdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/lib --infodir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plu
 gins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/arm-none-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-gmp=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpfr=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpc=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-isl=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/u
 sr --with-libelf=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain 10-2020-q4-major' --with-multilib-list=rmprofile,aprofile
   Thread model: single
   Supported LTO compression algorithms: zlib
   gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major) 
   COMPILER_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/
   LIBRARY_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi/lib/
   COLLECT_GCC_OPTIONS='-v' '-nostartfiles' '-nodefaultlibs' '-g' '-L/home/nihei/Projects/NuttX/nuttx/staging' '-L/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp' '-o' '/home/nihei/Projects/NuttX/nuttx/nuttx' '-mcpu=arm7tdmi' '-mfloat-abi=soft' '-marm' '-march=armv4t'
   *****************************************************************************************************************************
   /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/collect2 -plugin /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/liblto_plugin.so -plugin-opt=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjfgjvm.res --sysroot=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi -X -o /home/nihei/Projects/NuttX/nuttx/nuttx -L/home/nihei/Projects/NuttX/nuttx/staging -L/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1 -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-e
 abi/lib -L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../arm-none-eabi/lib --entry=__start -T/home/nihei/Projects/NuttX/nuttx/boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard -lgcc -lm --end-group
   *****************************************************************************************************************************
   COLLECT_GCC_OPTIONS='-v' '-nostartfiles' '-nodefaultlibs' '-g' '-L/home/nihei/Projects/NuttX/nuttx/staging' '-L/home/nihei/Projects/NuttX/nuttx/arch/arm/src/board' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp' '-L/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp' '-o' '/home/nihei/Projects/NuttX/nuttx/nuttx' '-mcpu=arm7tdmi' '-mfloat-abi=soft' '-marm' '-march=armv4t'
   ``` 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 removed a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
Ouss4 removed a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853771707


   > I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   > `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   > 
   > I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   > This change will also be needed for supporting LTO builds, eventually.
   
   Please take a look at the linked issue.  Those are options for `xx-gcc` not `xx-ld`.  We send `LDFLAGS` to `xx-ld` which is now throwing errors when unrecognized options are supplied.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853753487


   I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   
   I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   This change is also needed for supporting LTO builds.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] hartmannathan commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
hartmannathan commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-859115765


   @xiaoxiang781216 , @davids5 , @AlexanderVasiljev 
   
   This change is now described in the CWIKI Release Notes for the (future) 10.2 release:
   
   [https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.2#ld-now-called-through-gcc](https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.2#ld-now-called-through-gcc)
   
   Please proofread and feel free to make corrections.
   
   As this is a breaking change that happens when the Package Manager updates Binutils to 2.36.x, maybe it should be added to the website for anyone who encounters this problem pre-10.2-release?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853753487






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r650123327



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       @lulingar Do you have any instructions how to config clang build? What OS do you use?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856892194


   Done!


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648242527



##########
File path: boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs
##########
@@ -29,9 +29,9 @@ else ifeq ($(CONFIG_BOOT_RUNFROMISRAM),y)
 endif
 
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
+  ARCHSCRIPT = -Wl,-T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"

Review comment:
       ```suggestion
     ARCHSCRIPT = -Wl,-T"${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   ```
   We need to add commas where there were spaces to maintain the same behavior.
   There are more similar occurrences.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856737522


   > @gustavonihei This is the right form -Wl,-m,elf32lriscv
   
   The difference is that GCC will substitute the commas by spaces when passing to the LD linker. So by using `-Wl,-melf32lriscv` you'd end up with the exactly same input to LD as before.
   But either case is okay.
   
   BTW, sorry for closing the PR, I misclicked when creating the comment.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-857791768


   Every custom board should be updated. So before merging, this change should be announced!


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858581940


   @masayuki2009 I remember that I encountered this error with -lgcc_s. It was when I tried to migrate ld to gcc for x86. It failed because of "-static" flag, which was intoduced by this commit
   
   https://github.com/apache/incubator-nuttx/commit/aed9bcc001ec71b8d06c76ea3bd56562ad0fd89a#diff-2d60830f249881b0f33a243863a1f9fa2194e57d21faa126a49cd8e8c0f31c5b
   
   I gave up to migrate x86. Could you explain why -static is needed there?
   
   Doesn't your toolchain have -static flag by default?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r648242416



##########
File path: boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs
##########
@@ -51,8 +51,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections

Review comment:
       I don't see difference




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853843183






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853785193


   > It is not so simple.
   > 
   > ```
   > LD: nuttx
   > arm-none-eabi-gcc: error: unrecognized command line option '--start-group'
   > arm-none-eabi-gcc: error: unrecognized command line option '--end-group'
   > ```
   
   Yeah, these flags and some others are specific to LD, so when provided to the GCC frontend they must be provided with `-Wl,<flag>`


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853753487






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853874906


   > > @gustavonihei -On a separate note for a future feature with LTO it would be great to get it working,
   > > I have seen it destroy working code when we needed the size saving. I did not dig into it as the time, nor do I want to have to just because of an NuttX upgrade. So please consider Kconfig control (with it off by default)
   > 
   > Yes, I have done a quick attempt at enabling the LTO build for ESP32, and I haven't assessed what exactly had been removed, but that's how far I've got.
   
   So far LTO has not proven to be **L**ink **T**ime **O**ptimization but rather **L**imited **T**ime **O**ff :)


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853863709


   @AlexanderVasiljev @Ouss4  - I will test this today. 
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853771707


   > I believe adding those flags to CFLAGS is not the right option, since CFLAGS (and CXXFLAGS) relate to Compile flags.
   > `-nostarfiles` and `-nodefaultlibs` are Link Options according to GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
   > 
   > I believe that we should keep them as LDFLAGS and change the Linker command to call the GCC frontend (`LD = $(CROSSDEV)gcc`).
   > This change will also be needed for supporting LTO builds, eventually.
   
   Please take a look at the linked issue.  Those are options for `xx-gcc` not `xx-ld`.  We send `LDFLAGS` to `xx-ld` which is now throwing errors when unrecognized options are supplied.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856727916


   > riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   
   I saw that you passed the flag to GCC as `-Wl,-m,elf32lriscv`
   
   > Something strange happens with riscv boards. The github workflow tries to build some configurations, which I cannot configure locally.
   > 
   > On github
   > 
   > ```
   > ====================================================================================
   > Configuration/Tool: esp32c3-devkit/elf,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   > ------------------------------------------------------------------------------------
   >   Cleaning...
   >   Configuring...
   >   Disabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   >   Enabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   >   Building NuttX...
   > riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   > make[5]: *** [Makefile:70: errno] Error 1
   > ```
   > 
   > Locally
   > 
   > ```
   > tools/configure.sh esp32c3-devkit:elf
   > Directory for esp32c3-devkit:elf does not exist.
   > ```
   > 
   > Ok, these configurations have been created recently. But why does the workflow build against them? My branch doesn't have them. Should I merge from master? But how the pull-request system will treat this merge?
   
   The CI always builds the branch after rebasing it to the HEAD of the target repository, which in this case is the **master**.
   So, in order to correctly build this new `elf` configuration, it is recommended that you do the same, because a recent commit created some new variables:
   https://github.com/apache/incubator-nuttx/commit/dd4962b2f8d3d98d5bef03b433c32fdd1bc62340


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853792174


   @gustavonihei  you are right. But grep for LDFLAGS!


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r651009971



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       @lulingar, I've opened https://github.com/apache/incubator-nuttx/pull/3921 for fixing the support for building the simulator on systems with Clang as the default compiler.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856739065


   Arm is almost done


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853843183


   Do we have any idea how the linger was interpreting these and what the effect was?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853774308


   As @gustavonihei suggest that the right fix is change LD to xxx-gcc.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853871687


   @AlexanderVasiljev - we should either close this or update it to invoke the compiler - how would you like to proceed?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] lulingar commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
lulingar commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r650046105



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       Thanks, it failed further down the build, like:
   
       echo "LD:  nuttx"
       LD:  nuttx
       cc -r  -L"/nuttx/staging" -L board  -o nuttx.rel up_head.o --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lnet -lfs -lbinfmt -lboard  --end-group
       clang: error: unsupported option '--start-group'
       clang: error: unsupported option '--end-group'
       make[1]: Leaving directory '/nuttx/arch/sim/src'
       make[1]: *** [Makefile:314: nuttx] Error 1
       make: *** [tools/Makefile.unix:422: nuttx] Error 2
   
   But it seems #3904 fixes this, I'm testing it out.

##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -83,7 +83,7 @@ endif
 CC = $(CROSSDEV)cc
 CXX = $(CROSSDEV)c++
 CPP = $(CROSSDEV)cc -E -P -x c
-LD = $(CROSSDEV)ld
+LD = $(CROSSDEV)gcc

Review comment:
       It didn't fix it, in our clang-only build we don't have gcc. I'm testing some other ways to go about this. But this begs the question, why forcing this way the compiler to be gcc?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856555396


   Something strange happens with riscv boards. The github workflow tries to build some configurations, which I cannot configure locally.
   
   On github
   ```
   ====================================================================================
   Configuration/Tool: esp32c3-devkit/elf,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
   ------------------------------------------------------------------------------------
     Cleaning...
     Configuring...
     Disabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Enabling CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
     Building NuttX...
   riscv64-unknown-elf-gcc: error: unrecognized command line option '-melf32lriscv'
   make[5]: *** [Makefile:70: errno] Error 1
   ```
   
   
   Locally
   
   ```
   tools/configure.sh esp32c3-devkit:elf
   Directory for esp32c3-devkit:elf does not exist.
   
   ```
   
   
   Ok, this configurations have been created recently. But why does the workflow build against them? My branch doesn't have them. Should I merge from master? But how the pull-request system will treat this merge?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-855679790


   @gustavonihei  Thank you!
   
   Now I am stuck on spresense:nsh_trace.
   
   spresense:nsh - OK
   
   spresense:nsh_trace - FAILED
   
   ```
   arm-none-eabi-gcc: error: _exit: No such file or directory
   arm-none-eabi-gcc: error: exit: No such file or directory
   arm-none-eabi-gcc: error: getpid: No such file or directory
   ...
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   arm-none-eabi-gcc: error: unrecognized command line option '--wrap'; did you mean '--wrapv'?
   
   ```
   
   I found the reason. It was
   EXTRALINKCMDS += @$(TOPDIR)/syscall/syscall_wraps.ldcmd


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856742451


   > Anyway I gave up to correct RISCV. I have changed back it to LD.
   
   No problem, I think this can be done later.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853801893


   > @gustavonihei you are right. But grep for LDFLAGS!
   
   You do not need to change every flag provided to LDFLAGS. These ones I mentioned are the ones that are specific to the LD linker. There might be some others that may need to passed via `-Wl,`, but the majority are handled via the GCC frontend, e.g. `-L` and `-l`.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-854915209


   I am currently stuck with quickfeather/nsh config. If anyone knows anything about this configuration please help.
   
   ```
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(exit.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(exit.o)
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: error: /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o) uses VFP register arguments, /github/workspace/sources/nuttx/nuttx does not
   /tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /github/workspace/sources/nuttx/staging/libsched.a(nx_start.o)
   ```
   
   I also tried to change ld to gcc on mips, renesas, x86 and x86-64, but failed to build. I can completely rewrite makefiles, but i don't know why they were written as they were written.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
davids5 edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-853843183


   Do we have any idea how the linker was interpreting these and what the effect was?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] juniskane commented on a change in pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
juniskane commented on a change in pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#discussion_r649267611



##########
File path: arch/arm/src/Makefile
##########
@@ -93,8 +93,8 @@ LDFLAGS += $(ARCHSCRIPT) $(EXTRALINKCMDS)
 
 # Override in Make.defs if linker is not 'ld'

Review comment:
       Now misleading comment




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] AlexanderVasiljev commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
AlexanderVasiljev commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858555616


   @masayuki2009 Here are my steps
   git clone https://github.com/apache/incubator-nuttx.git
   tools/configure.sh sim:smp
   make V=1 -j7
   
   
   Result
   ```
   make[2]: Leaving directory '/tmp/nuttx/incubator-nuttx/boards/sim/sim/sim/src'
   echo "LD:  nuttx"
   LD:  nuttx
   gcc -r  -L"/tmp/nuttx/incubator-nuttx/staging" -L board  -o nuttx.rel up_head.o up_smpsignal.o -Wl,--start-group -lsched -ldrivers -lboards -lc -lmm -larch -lapps -lfs -lbinfmt -lboard  -Wl,--end-group
   objcopy --redefine-syms=nuttx-names.dat nuttx.rel
   cc -g -Wl,-verbose 2>&1 | \
        sed -e '/====/,/====/!d;//d' -e 's/__executable_start/_stext/g' -e 's/__init_array_start/_sinit/g' \
            -e 's/__init_array_end/_einit/g' -e 's/__fini_array_start/_sfini/g' -e 's/__fini_array_end/_efini/g' >nuttx.ld
   echo "__init_array_start = .; __init_array_end = .; __fini_array_start = .; __fini_array_end = .;" >>nuttx.ld
   "cc" -g -L board -T nuttx.ld -o /tmp/nuttx/incubator-nuttx/nuttx nuttx.rel up_hostirq.o up_hostmemory.o up_hosttime.o up_simuart.o up_testset.o up_simsmp.o -lpthread -lrt
   nm /tmp/nuttx/incubator-nuttx/nuttx | \
           grep -v '\(compiled\)\|\(\.o$\)\|\( [aUw] \)\|\(\.\.ng$\)\|\(LASH[RL]DI\)' | \
           sort > /tmp/nuttx/incubator-nuttx/System.map
   make[1]: Leaving directory '/tmp/nuttx/incubator-nuttx/arch/sim/src'
   if [ -w /tftpboot ] ; then \
           cp -f nuttx /tftpboot/nuttx.sim; \
   fi
   echo nuttx > nuttx.manifest
   printf "%s\n" *.map >> nuttx.manifest
   ```
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856737522


   > @gustavonihei This is the right form -Wl,-m,elf32lriscv
   
   The difference is that GCC will substitute the commas by spaces when passing to the LD linker. So by using `-Wl,-melf32lriscv` you'd end up with the exactly same input to LD as before.
   But either case is okay.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] yamt commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
yamt commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-860334125


   > > why do we need -nostartfiles -nodefaultlibs at all?
   > > my understanding is that these options controls how cc generates ld command line arguments.
   > > i don't see how it matters while we use ld directly.
   > > besides, having cc as LD is very confusing.
   > 
   > Almost every board configuration has these options. It seems like to be a copypasta. But actualy LD doesn't process them. My first proposal was to change it to CFLAGS. But changing LD to GCC can give more options for linking optimization. So it was decided to take more effort.
   
   i'm not sure if i agree the decision. i submitted a revert. https://github.com/apache/incubator-nuttx/pull/3900


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #3836: Make: -nostartfiles -nodefaultlibs are not flags of LD but flags of GCC

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-858547595


   > @masayuki2009 What is your config name?
   
   sim:smp
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org