arduino / arduino/ArduinoCore-sam
compiler.c.elf.extra_flags is in the wrong place - precompiled libs, ldflags
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
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](https://github.com/arduino/arduino-builder/pull/219) in March 2017).
As per `ld` conventions, one should list the linker flags at the end. This [stackoverflow](https://stackoverflow.com/questions/5005363/undefined-reference-to-sin) 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
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open platform.txt and inspect the recipe.c.combine.pattern entry for the ELF-linking command. Compare the ordering of compiler.c.elf.extra_flags with the linker flags and static libraries against the command shown in the issue; the work is done when the recipe reflects that ordering for precompiled libraries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system, embedded-iot
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100