Search code examples
clinkerscons

[Scons][Linker] Unable to find linker script


I'm trying to use scons to build a simple hello world project, explicitly setting the linker flags to read a custom linker script:

env.Append(LINKFLAGS = [
    '-T script/linker_script.ld'
    ])

The problem is that when this is run, SCons puts double quotes " " around the -T option, which results in something like this:

arm-none-eabi-ld -o bareMetalStartupScons.elf "-T script/linker_script.ld" src/main.o asm/startup.o
arm-none-eabi-ld: cannot open linker script file  script/linker_script.ld: No such file or directory

The script is there, and if I just remove the double quotes and run the command manually, it completes without errors, e.g.

arm-none-eabi-ld -T script/linker_script.ld src/main.o asm/startup.o

Any solution for this issue or any idea why this is happening?


Solution

  • Actually I found a workaround for this issue, which is to specify the path of the linker script without any space from the -T, e.g.

    env.Append(LINKFLAGS = [
        '-Tscript/linker_script.ld'
        ])
    

    In this case SCons will not put the double quotes around the argument "as a string" when passing it to the executable.