Repository navigation
Make: fix use of gcc as LD for modules and ELF executables builds - #4173
Merged
acassis merged 1 commit intoJul 19, 2021
Merged
Conversation
ppisa
force-pushed
the
adjust-elf-and-module-to-use-gcc-as-ld
branch
2 times, most recently
from
July 18, 2021 18:27
a1b1495 to
1b59921
Compare
The patch Make: use gcc as LD introduced use of GCC wrapper as linker. LD variable references GCC executable now. But when GCC wrapper s used to build relocatable loadable objects (ELF executables and modules) then it causes linking of toolchain default libc and other libraries even when -r is usd. Another problem is that incorrect multiarch variant is selected for libraries search and possibly even for LTO or C++ templates instantiating and other glue code which causes fails during linking if CFLAGS selects non/default miltiarch variant. Corresponding CFLAGS are passed to LDMODULEFLAGS and LDELFFLAGS as well as -nostartfiles -nodefaultlibs options. Separate line is used to easily find and adjust lines if link process is changed in future. Signed-off-by: Pavel Pisa <[email protected]>
ppisa
force-pushed
the
adjust-elf-and-module-to-use-gcc-as-ld
branch
from
July 18, 2021 23:35
1b59921 to
1702aa0
Compare
ppisa
marked this pull request as ready for review
July 19, 2021 09:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The patch
Make: use gcc as LD
introduced use of GCC wrapper as linker. LD variable references GCC
executable now. But when GCC wrapper s used to build relocatable
loadable objects (ELF executables and modules) then it causes
linking of toolchain default libc and other libraries even when -r
is usd. Another problem is that incorrect multiarch variant is selected
for libraries search and possibly even for LTO or C++ templates
instantiating and other glue code which causes fails during linking
if CFLAGS selects non/default miltiarch variant.
Corresponding CFLAGS are passed to LDMODULEFLAGS and LDELFFLAGS
as well as -nostartfiles -nodefaultlibs options.
Separate line is used to easily find and adjust lines if link
process is changed in future.
Signed-off-by: Pavel Pisa [email protected]
Impact
Testing
Tested on LX_CPU board
tools/configure.sh lx_cpu:nsh
This board default config enables ELF and MODULES which results
in the build errors
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: error:
chardev.o uses VFP register arguments, chardev does not
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: failed to
merge target specific data of file chardev.o
collect2: error: ld returned 1 exit status
If only CFLAGS are added then linking of GCC/Newlib provided CRT0 and LIBC
causes attempt t export symbols which are not provided by NuttX build and build
fails in the linking phase.