Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm-none-eabi-ld: Error: unable to disambiguate: -nostartfiles #3826

Closed
AlexanderVasiljev opened this issue Jun 2, 2021 · 5 comments · Fixed by #3836
Closed

arm-none-eabi-ld: Error: unable to disambiguate: -nostartfiles #3826

AlexanderVasiljev opened this issue Jun 2, 2021 · 5 comments · Fixed by #3836

Comments

@AlexanderVasiljev
Copy link
Contributor

AlexanderVasiljev commented Jun 2, 2021

I have faced the same issue as #3209.

I have just installed Ubuntu 21.04. The first build on new Ubuntu failed with this error.

LOG

LD: nuttx
arm-none-eabi-ld: Error: unable to disambiguate: -nostartfiles (did you mean --nostartfiles ?)
make[1]: *** [Makefile:156: nuttx] Error 1

GCC version

arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:9-2019-q4-0ubuntu2) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

Ld version

arm-none-eabi-ld --version
GNU ld (2.36.1-0ubuntu1+14build1) 2.36.1
@Ouss4
Copy link
Member

Ouss4 commented Jun 2, 2021

Oh this issue is now on Debian based distros as well?

We've seen this (a general did you mean --option instead of -option) in arch based distros. We couldn't see any references in the GNU project where -option is replaced with --option, so we assumed an issue in the Arch package.

Anyway, did you try to download the toolchain as described in #3209?

@AlexanderVasiljev
Copy link
Contributor Author

AlexanderVasiljev commented Jun 2, 2021

See my question on binutils
https://sourceware.org/pipermail/binutils/2021-June/116825.html

The answer https://sourceware.org/pipermail/binutils/2021-June/116826.html
from nickc@redhat.com is

The -nostartfiles option is a gcc command line option, not a linker
command line option. It is used when gcc is creating an executable
binary and it tells gcc not to include the standard system files
(eg crt1.o, crtbegin.o, crtend.o etc) when gcc invokes the linker.

All of which means that in your build system somewhere you have:

arm-none-eabi-ld -nostartfiles ...

whereas you probably meant to have:

arm-none-eabi-gcc -nostartfiles ...

Note: the reason why this problem has appeared when you upgraded is
that we recently added some extra error checking to the linker to
attempt to detect mis-spelt command line options.
In particular the
linker interprets options that start with a single dash as if they
were multiple, single letter options. So "-nostartfiles" would be
treated as "-n" "-o startfiles" which is probably not what the user
wanted. Hence the error message.

Plus, just to be clear, the linker does not support a --nostartfiles
option. The code that generates the error message does not actually
check to see if the double dash version of the option exists...

@AlexanderVasiljev
Copy link
Contributor Author

AlexanderVasiljev commented Jun 2, 2021

The flag nostartfiles is not a flag of ld. So it shouldn't appear in LDFLAGS += -nostartfiles

I assume that we should change
LDFLAGS += -nostartfiles -nodefaultlibs
to
CXXFLAGS += -nostartfiles -nodefaultlibs
in every board Make.defs

It works for my board

@AlexanderVasiljev
Copy link
Contributor Author

#3836

@hartmannathan
Copy link
Contributor

This is caused by Binutils being updated to the 2.36.x line.

This is fixed by PR #3836

This is now documented at Release Notes for the (future) NuttX-10.2 release:

https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.2#ld-now-called-through-gcc

osmocom-gerrit pushed a commit to osmocom/osmocom-bb that referenced this issue Nov 22, 2023
…of GCC

It seems that those flags have always been gcc flags, and not ld flags.

After decades of tolerating this, binutils 2.36.x no longer tolerates
those flags but prints an error:

arm-none-eabi-ld: Error: unable to disambiguate: -nostartfiles (did you mean --nostartfiles ?)

See also apache/nuttx#3826 and the related
apache/nuttx#3836 how this was solved in another
project - I adopted that solution here 1:1

Change-Id: Id199e4d03d5aae07a347c98f47791f42c12008c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants