I'm attempting to build my project, which does not use libc, or libm,
but I do want to link with libgcc.

additionally, I don't want any startup code to be linked - the project
is intended to be fully standalone.

I've had some success with gcc 10, but I need this to work on gcc 5.4.0
as well.

I'm compiling my objects as normal, with the following cflags:

         -mmcu=atmega2560 -O3 -g \
         -Wall -Wextra -Wshadow -Wundef -Wpadded \
         -MMD -nostdinc -isystem include/ \
         -fno-common -ffunction-sections -fno-builtin-vprintf

and attempting to link them thusly:

gcc-avr -mmcu=atmega2560 -Tmylds.lds -Wl,--gc-sections -mrelax -nostdlib
-o out.elf <objects>

I've found that avr-gcc 5.4 does not recognise -nolibc, which would (on
the face of it) appear to do what I want.

How can I do this? I'm pulling my hair out...

I've tried invoking LD directly, but it doesnt recognise
-mmcu=atmega2560 - I assume I have to specify -mavr6, but thats a pain,
since I have no obvious way to autodetect the architecture in my

I have managed to get things to work, using the (abbreviated slightly)

-plugin ... liblto_plugin.so
-mavr6 -Tdata 0x800200 --relax
-o out.elf
-L (several times over, various paths)
--start-group -lgcc --end-group -T mylds.lds

So the question is, what magic do I need to pass to GCC in my linking
step in order to get it to produce that linker commandline?

Thanks in advance,


Reply via email to