Skip to content

Commit a3b4f7a

Browse files
authored
Remove use of whole-archive (#677)
* Add source files wrapper library Allow to not archive HAL/LL object files to core.a. This avoid the linker to select weak definitions instead of non-weak ones when 'whole-archive' option is not used. See: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15833.html * Remove use of whole-archive * Move newlib syscall implementation outside core archive Due to a bug in the arm none eabi gcc with lto which raise an unresolved reference if syscall is in the archive (_sbrk,...)
1 parent 964576b commit a3b4f7a

File tree

141 files changed

+45
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+45
-5
lines changed

libraries/SrcWrapper/keywords.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#######################################
2+
# Syntax Coloring Map For SrcWrapper
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
#######################################
10+
# Methods and Functions (KEYWORD2)
11+
#######################################
12+
13+
#######################################
14+
# Constants (LITERAL1)
15+
#######################################
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Source Wrapper
2+
version=1.0.0
3+
author=Frederic Pillon
4+
maintainer=stm32duino
5+
sentence=Source files wrapper (HAL, LL,...)
6+
paragraph=Allow to not archive source object files to core.a. This avoid the linker to select weak definitions instead of non-weak ones when 'whole-archive' option is not used.
7+
category=Other
8+
url=
9+
architectures=stm32

libraries/SrcWrapper/src/SrcWrapper.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef __SRCWRAPPER_H__
2+
#define __SRCWRAPPER_H__
3+
4+
#endif /* __SRCWRAPPER_H__ */
File renamed without changes.

platform.txt

+17-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version=1.0.0
99

1010
# STM compile variables
1111
# ----------------------
12-
compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{build.core.path}/stm32" "-I{build.core.path}/stm32/LL" "-I{build.core.path}/stm32/usb" "-I{build.core.path}/stm32/usb/hid" "-I{build.core.path}/stm32/usb/cdc" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Inc/" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Src/" "-I{build.system.path}/{build.series}/" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
12+
compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{build.core.path}/stm32" "-I{build.core.path}/stm32/LL" "-I{build.core.path}/stm32/usb" "-I{build.core.path}/stm32/usb/hid" "-I{build.core.path}/stm32/usb/cdc" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Inc" "-I{build.system.path}/Drivers/{build.series}_HAL_Driver/Src" "-I{build.system.path}/{build.series}" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
1313

1414
compiler.warning_flags=-w
1515
compiler.warning_flags.none=-w
@@ -92,10 +92,22 @@ build.opt.name=build_opt.h
9292
build.opt.sourcepath={build.source.path}/{build.opt.name}
9393
build.opt.path={build.path}/sketch/{build.opt.name}
9494

95+
build.src_wrapper.path={build.path}/sketch/SrcWrapper.cpp
96+
97+
# Create sketch dir if not exists
98+
recipe.hooks.prebuild.1.pattern.windows=cmd /c if not exist "{build.path}\sketch" mkdir "{build.path}\sketch"
99+
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.path}/sketch ] || mkdir -p {build.path}/sketch"
100+
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.path}/sketch ] || mkdir -p {build.path}/sketch"
101+
95102
# Create empty {build.opt} if not exists in the sketch dir
96-
recipe.hooks.prebuild.1.pattern.windows=cmd /c if not exist "{build.opt.sourcepath}" mkdir "{build.path}\sketch" & type NUL > "{build.opt.path}"
97-
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
98-
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
103+
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.opt.sourcepath}" type NUL > "{build.opt.path}"
104+
recipe.hooks.prebuild.2.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || touch {build.opt.path}"
105+
recipe.hooks.prebuild.2.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || touch {build.opt.path}"
106+
107+
# Force include of SrcWrapper library
108+
recipe.hooks.prebuild.3.pattern.windows=cmd /c echo #include ^<SrcWrapper.h^> > "{build.src_wrapper.path}"
109+
recipe.hooks.prebuild.3.pattern.linux=bash -c "echo $0 > {build.src_wrapper.path}" "#include <SrcWrapper.h>"
110+
recipe.hooks.prebuild.3.pattern.macosx=bash -c "echo $0 > {build.src_wrapper.path}" "#include <SrcWrapper.h>"
99111

100112
# compile patterns
101113
# ---------------------
@@ -113,7 +125,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.i
113125
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
114126

115127
## Combine gc-sections, archives, and objects
116-
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++
128+
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} "{archive_file_path}" -lc -Wl,--end-group -lm -lgcc -lstdc++
117129

118130
## Create output (.bin file)
119131
recipe.objcopy.bin.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"

0 commit comments

Comments
 (0)