Skip to content

Commit a0d1c64

Browse files
authored
Keep custom user flags passed via build_flags, such as a custom LD script (#4680)
1 parent d582cab commit a0d1c64

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/platformio-build.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,24 @@ def scons_patched_match_splitext(path, suffixes=None):
8484

8585
LIBSOURCE_DIRS=[
8686
join(FRAMEWORK_DIR, "libraries")
87-
]
88-
)
87+
],
8988

90-
env.Replace(
9189
LINKFLAGS=[
92-
"-Os",
93-
"-nostdlib",
94-
"-Wl,--no-check-sections",
95-
"-Wl,-static",
96-
"-Wl,--gc-sections",
9790
"-Wl,-wrap,system_restart_local",
9891
"-Wl,-wrap,spi_flash_read",
99-
"-u", "app_entry",
100-
"-u", "_printf_float",
101-
"-u", "_scanf_float"
92+
"-u", "app_entry"
10293
]
10394
)
10495

96+
# remove LINKFLAGS defined in main.py and keep user custom flags
97+
try:
98+
index = env['LINKFLAGS'].index("call_user_start")
99+
if index > 0 and env['LINKFLAGS'][index - 1] == "-u":
100+
del env['LINKFLAGS'][index - 1]
101+
env['LINKFLAGS'].remove("call_user_start")
102+
except IndexError:
103+
pass
104+
105105
flatten_cppdefines = env.Flatten(env['CPPDEFINES'])
106106

107107
#

0 commit comments

Comments
 (0)