8000 Respect linking order of libraries for PlatformIO (#8263) · esp8266/Arduino@f7951e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7951e6

Browse files
authored
Respect linking order of libraries for PlatformIO (#8263)
* Respect linking order of libraries Now has the same order as the Arduino IDE does with its platform.txt * Remove double-referenced libs * Change implementation style Instead of injecting at magic indices, which might break when some other extra-scripts inject other libraries, let's create the LIBS array at the bottom in easy to understand and correct order.
1 parent 9f30f24 commit f7951e6

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

tools/platformio-build.py

Lines changed: 21 additions & 15 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,8 @@ def scons_patched_match_splitext(path, suffixes=None):
139139
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
140140
],
141141

142-
# A list of one or more libraries that will be linked with any executable programs created by this environment
143-
LIBS=[
144-
"hal", "phy", "pp", "net80211", "wpa", "crypto", "main",
145-
"wps", "bearssl", "espnow", "smartconfig", "airkiss", "wpa2",
146-
"m", "c", "gcc"
147-
],
142+
# LIBS is set at the bottom of the builder script
143+
# where we know about all system libraries to be included
148144

149145
LIBSOURCE_DIRS=[
150146
join(FRAMEWORK_DIR, "libraries")
@@ -218,43 +214,44 @@ def scons_patched_match_splitext(path, suffixes=None):
218214
#
219215
# lwIP
220216
#
217+
lwip_lib = None
221218
if "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY" in flatten_cppdefines:
222219
env.Append(
223220
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)],
224221
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
225-
LIBS=["lwip6-536-feat"]
226222
)
223+
lwip_lib = "lwip6-536-feat"
227224
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH" in flatten_cppdefines:
228225
env.Append(
229226
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)],
230227
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
231-
LIBS=["lwip6-1460-feat"]
232228
)
229+
lwip_lib = "lwip6-1460-feat"
233230
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH" in flatten_cppdefines:
234231
env.Append(
235232
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)],
236233
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
237-
LIBS=["lwip2-1460-feat"]
238234
)
235+
lwip_lib = "lwip2-1460-feat"
239236
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH" in flatten_cppdefines:
240237
env.Append(
241238
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)],
242239
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
243-
LIBS=["lwip2-536"]
244240
)
241+
lwip_lib = "lwip2-536"
245242
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH" in flatten_cppdefines:
246243
env.Append(
247244
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)],
248245
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
249-
LIBS=["lwip2-1460"]
250246
)
247+
lwip_lib = "lwip2-1460"
251248
# PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY (default)
252249
else:
253250
env.Append(
254251
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)],
255252
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
256-
LIBS=["lwip2-536-feat"]
257253
)
254+
lwip_lib = "lwip2-536-feat"
258255

259256
#
260257
# Waveform
@@ -266,17 +263,17 @@ def scons_patched_match_splitext(path, suffixes=None):
266263
#
267264
# Exceptions
268265
#
266+
stdcpp_lib = None
269267
if "PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS" in flatten_cppdefines:
270268
env.Append(
271269
CXXFLAGS=["-fexceptions"],
272-
LIBS=["stdc++-exc"]
273270
)
271+
stdcpp_lib = "stdc++-exc"
274272
else:
275273
env.Append(
276274
CXXFLAGS=["-fno-exceptions"],
277-
LIBS=["stdc++"]
278275
)
279-
276+
stdcpp_lib = "stdc++"
280277
#
281278
# VTables
282279
#
@@ -355,6 +352,15 @@ def scons_patched_match_splitext(path, suffixes=None):
355352
assert mmu_flags
356353
env.Append(CPPDEFINES=mmu_flags)
357354

355+
# A list of one or more libraries that will be linked with any executable programs created by this environment
356+
# We do this at this point so that we can put the libraries in their correct order more easily
357+
env.Append(
358+
LIBS=[
359+
"hal", "phy", "pp", "net80211", lwip_lib, "wpa", "crypto", "main",
360+
"wps", "bearssl", "espnow", "smartconfig", "airkiss", "wpa2",
361+
stdcpp_lib, "m", "c", "gcc"
362+
]
363+
)
358364

359365
# Build the eagle.app.v6.common.ld linker file
360366
app_ld = env.Command(

0 commit comments

Comments
 (0)
0