arduino / ArduinoCore-sam

81 stars 107 forks source link

compiler.c.elf.extra_flags is in the wrong place - precompiled libs, ldflags #46

Open kgoveas opened 6 years ago

kgoveas commented 6 years ago

In platform.txt, the recipe for combining the elf file is incorrect. It should be placed before the linker flags for other static libraries like below.

Background: In order for the arduino-builder to be able to use precompiled libs, the ldflags are loaded into compiler.c.elf.extra_flags (as per @facchinm 's commits in March 2017).

As per ld conventions, one should list the linker flags at the end. This stackoverflow issue highlights a case.

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}"  "-L{build.path}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group {compiler.arm.cmsis.ldflags} {compiler.c.elf.extra_flags} -lm "{build.path}/{archive_file}" -Wl,--end-group