Problem linking *without* avr-libc, libm, etc.
Ian Molton <[email protected]> Thu, 29 Apr 2021 20:43:56 +0100
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <[email protected]> |
Hi,
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
buildscripts.
I have managed to get things to work, using the (abbreviated slightly)
following:
/home/ian/x-tools/avr/libexec/gcc/avr/10.3.0/collect2
-plugin ... liblto_plugin.so
-plugin-opt=...lto-wrapper
-plugin-opt=-fresolution=/tmp/ccXJW1Nw.res
-mavr6 -Tdata 0x800200 --relax
-o out.elf
-L (several times over, various paths)
--gc-sections
...all_the_objects.o...
--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,
-Ian