0

I have ARM project with .c and .cpp files. I use SCONS as build system. So far everything works fine, but I wanted to add SEGGER SystemView to my project, and there is SEGGER_RTT_ASM_ARMv7M.S assembly file in it. When I just added this file like this:

src = Glob('somepath/*.c') + \
      Glob('someotherpath/*.c') + \
      Glob('resources/segger/*.c') + \
      Glob('resources/segger/*.S')

program = env.Program("my-binary.elf", src)

SCONS added '.S' file to liker stage as it was object file, without compiling it to object file:

arm-none-eabi-g++ -o build\my-binary.elf ...linker-options... object-file1.o object-file2.o resources\segger\SEGGER_RTT_ASM_ARMv7M.S

How can I make SCONS compile this assembly file to object file, like it does for .c and .cpp files? My env options (flags and paths omitted for clarity):

env_options_arm_gcc = {
    "CC"    : arch_arm_gcc + "gcc",
    "CXX"   : arch_arm_gcc + "g++",
    "LD"    : arch_arm_gcc + "g++",
    "AR"    : arch_arm_gcc + "ar",
    "STRIP" : arch_arm_gcc + "strip",
    "TARGET_ARCH" : "arm",
    "PROGSUFFIX" : ".elf",
    "OBJSUFFIX" : ".o",
    "LIBPATH" : ["#src\\Device_Startup", "#build\\resources"],
    "LINKFLAGS" : ...linker_flags...,
    "CCFLAGS" : ...c/cpp compile flags...
    "CFLAGS" : '-std=gnu99',
    "CXXFLAGS" : '-std=c++11',
    "LIBS" : 'stdc++',
    "CPPPATH" : [
    ...Include path...
    ]
}
Frant
  • 5,382
  • 1
  • 16
  • 22
Staszek
  • 849
  • 11
  • 28
  • Did you specify `tools=[...]` in your call to `Environment()` ? Also did you explicitly specify CPPSUFFIXES ? – bdbaddog Aug 12 '23 at 00:51
  • This is supposed to work - a `.S` should be treated as an assembler file that's run through the preprocessor (as distinguished from a lower-case `.s`, which isn't). Sounds like something may have been overridden (which I think is what @bdbaddog is getting at) – Mats Wichmann Aug 13 '23 at 14:39
  • I haven't specified `CPPSUFFIXES`, as documentation said, that `.S` files are already included. Should I specify it anyway? I specified `tools`, but without adding `as` tool. When I added `as` tool, SCONS tried to launch `arch_arm_gcc_as`, but I think the compiler didn't resolve preprocessor variables, and also didn't add include path for `#include` directives. ow should it be done correctly? – Staszek Aug 14 '23 at 13:18
  • Try specifying `gas` and not `as`, gas = gnu assembler. That might be sufficient to resolve this? – bdbaddog Aug 20 '23 at 19:43
  • @bdbaddog should I specify `gas` tool as `as`, or as `arch_arm_gcc_gcc` or `arch_arm_gcc_g++`? And ten, what shall be the order of the tools while creating the environment? Shall it be like this: `Environment(**env_options, tools=[''gas', gcc', 'g++', 'gnulink', 'ar'])`? – Staszek Aug 20 '23 at 21:06
  • env['AS'] specifies the tool to be called for .s, .asm, .ASM, env['CC'] specifies the tool to be called for .spp, .SPP,.sx and if case sensitive filesystem .S. – bdbaddog Aug 21 '23 at 20:22
  • order of tool specification.. shouldn't mattter, but I'd put gas last. – bdbaddog Aug 21 '23 at 20:23

0 Answers0