Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect linking order of libraries #8263

Merged
merged 4 commits into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions tools/platformio-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ def scons_patched_match_splitext(path, suffixes=None):
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
],

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

LIBSOURCE_DIRS=[
join(FRAMEWORK_DIR, "libraries")
Expand Down Expand Up @@ -218,43 +214,44 @@ def scons_patched_match_splitext(path, suffixes=None):
#
# lwIP
#
lwip_lib = None
if "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY" in flatten_cppdefines:
env.Append(
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip6-536-feat"]
)
lwip_lib = "lwip6-536-feat"
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH" in flatten_cppdefines:
env.Append(
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip6-1460-feat"]
)
lwip_lib = "lwip6-1460-feat"
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH" in flatten_cppdefines:
env.Append(
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip2-1460-feat"]
)
lwip_lib = "lwip2-1460-feat"
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH" in flatten_cppdefines:
env.Append(
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip2-536"]
)
lwip_lib = "lwip2-536"
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH" in flatten_cppdefines:
env.Append(
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip2-1460"]
)
lwip_lib = "lwip2-1460"
# PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY (default)
else:
env.Append(
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)],
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
LIBS=["lwip2-536-feat"]
)
lwip_lib = "lwip2-536-feat"

#
# Waveform
Expand All @@ -266,17 +263,17 @@ def scons_patched_match_splitext(path, suffixes=None):
#
# Exceptions
#
stdcpp_lib = None
if "PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS" in flatten_cppdefines:
env.Append(
CXXFLAGS=["-fexceptions"],
LIBS=["stdc++-exc"]
)
stdcpp_lib = "stdc++-exc"
else:
env.Append(
CXXFLAGS=["-fno-exceptions"],
LIBS=["stdc++"]
)

stdcpp_lib = "stdc++"
#
# VTables
#
Expand Down Expand Up @@ -355,6 +352,15 @@ def scons_patched_match_splitext(path, suffixes=None):
assert mmu_flags
env.Append(CPPDEFINES=mmu_flags)

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

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