1
votes

I am setting up a CMake build for an excisting project, and has successfully compiled all sources (.c) and reached the linker-stage.

Here I run into the following error:

/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find gc-sections: No such file or directory.

The compilation is done using "arm-none-eabi-gcc" with the following flags:

-Wall  -fdata-sections -ffunction-sections -std=gnu99 -mabi=aapcs -mcpu=cortex-m4 -mthumb -mfloat-abi=hard'

The linker uses the following flags:

-Wl,-Map=out.map -Wl,gc-sections -mabi=aapcs -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -T${LINKER_SCRIPT_PATH}

Anyone understand why the linker is loooking for gc_sections?

Edit: Apparently I miss the leading hyphens of the argument. The correct linker flag is of course -Wl,--gc-sections, not -Wl,gc-sections.

How embarrassing.

1
Anyone understand why the linker is loooking for gc_sections? - most likely, because of option -Wl,gc-sections passed to the linker. It should be --gc-sections or -Wl,--gc-sections.Tsyvarev

1 Answers

1
votes

Apparently I miss the leading hyphens of the argument. The correct linker flag is of course -Wl,--gc-sections, not -Wl,gc-sections.

How embarrassing.