From: Tilman Sauerbeck Date: Sun, 29 Dec 2019 11:16:49 +0000 (+0100) Subject: build: Link libgcc from the command line instead of the linker script. X-Git-Url: http://git.code-monkey.de/?p=gps-watch.git;a=commitdiff_plain;h=7fb6d100bd5f916d8e9684d654c27796665f3ef1 build: Link libgcc from the command line instead of the linker script. Pulling it in via the linker script will only work if we use our C toolchain's linker and would fail if we used the Rust linker. --- diff --git a/SConscript.target b/SConscript.target index b42eece..1e5f402 100644 --- a/SConscript.target +++ b/SConscript.target @@ -1,3 +1,4 @@ +import subprocess import os Import('env') @@ -33,6 +34,10 @@ env.Append(LINKFLAGS = [ '-nostartfiles', ]) +libgcc_path = \ + subprocess.check_output('{} -print-libgcc-file-name'.format(env['CC']), + shell=True).strip() + env.Append(RUSTCFLAGS = [ '-C', 'opt-level=s', '--target=thumbv6m-none-eabi', @@ -76,9 +81,15 @@ for s in ['intermediate', 'final']: '-Tsrc/bootloader/bootloader-{}.ld'.format(s), ]) + bootloader_libs = [ + 'bootloader-{}'.format(s), + 'common', + File(libgcc_path), + ] + bootloader_elf = \ bootloader_env.Program('gps-watch-bootloader-{}.elf'.format(s), - start_o, LIBS = ['bootloader-{}'.format(s), 'common']) + start_o, LIBS = bootloader_libs) bootloader_bin = bootloader_env.Objcopy(bootloader_elf) @@ -104,9 +115,14 @@ application_env.Append(LINKFLAGS = [ '-Tsrc/application/application.ld' ]) +application_libs = [ + 'application', + 'common', + File(libgcc_path), +] + application_elf = application_env.Program('gps-watch-application.elf', - start_o, - LIBS = ['application', 'common']) + start_o, LIBS = application_libs) application_bin = application_env.Objcopy(application_elf) diff --git a/src/application/application.ld b/src/application/application.ld index 12ba625..f79d433 100644 --- a/src/application/application.ld +++ b/src/application/application.ld @@ -14,9 +14,6 @@ MEMORY : ORIGIN = 0x1fffe000, LENGTH = 0x08000 } -/* Library configurations */ -GROUP(libgcc.a) - /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. * It references following symbols, which must be defined in code: diff --git a/src/bootloader/bootloader-final.ld b/src/bootloader/bootloader-final.ld index 4893d80..86837c4 100644 --- a/src/bootloader/bootloader-final.ld +++ b/src/bootloader/bootloader-final.ld @@ -14,9 +14,6 @@ MEMORY : ORIGIN = 0x1fffe000, LENGTH = 0x08000 } -/* Library configurations */ -GROUP(libgcc.a) - /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. * It references following symbols, which must be defined in code: diff --git a/src/bootloader/bootloader-intermediate.ld b/src/bootloader/bootloader-intermediate.ld index 7f8df3e..bbc30b9 100644 --- a/src/bootloader/bootloader-intermediate.ld +++ b/src/bootloader/bootloader-intermediate.ld @@ -14,9 +14,6 @@ MEMORY : ORIGIN = 0x1fffe000, LENGTH = 0x08000 } -/* Library configurations */ -GROUP(libgcc.a) - /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. * It references following symbols, which must be defined in code: