Preprocess linker scripts

Sysprogs forums Forums VisualGDB Preprocess linker scripts

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26833
    UdoEberhardt
    Participant

    Hello,

    In our embedded (bare metal) projects we use C preprocessor statements such as #ifdef and #include in our linker scripts and produce the final linker script through a prebuild step. This greatly simplifies linker script customization/configuration and enables us to use the same linker script template in many projects. This technique also seems to be used in various other embedded frameworks and projects.

    As creating a proper prebuild step is not simple (see also here) it would be nice if VGDB supports this feature directly. I can think of several ways to integrate that:

    a) Define a file extension for the linker script source file, e.g. .ldsrc, and if such a file is present in the project, run it through gcc -E -P to produce a .ld file which gets passed to the linker. Also pass all -D and -I options to gcc that are normally used for C++ compilation.

    b) In a normal C++ project you can open properties on a file item and then set Item Type to “Custom Build Tool”. This adds a “Custom Build Tool” property sheet to the dialog where you can configure tool details. The Custom Build Tool feature seems not to be available in VGDB. Making it available could also solve the problem. However, I’m not sure if include path and preprocessor definitions can be accessed as required.

    c) Add a new Yes|No option named “Pre-process Linker Script” to the linker settings. If the option is set to Yes, the script that is specified in the “Linker Script” option will run through gcc -E -P (plus all -D and -I options) before it gets passed to the linker.

    Udo

    #26845
    support
    Keymaster

    No problem, we have added experimental support for preprocessing linker scripts in MSBuild projects to the following build: VisualGDB-5.5.2.3415.msi

    You can enable linker script preprocessing via VS Project Properties -> Linker -> Linker Script. You can use other properties on the same page to define additional preprocessor macros/include directories and to control whether the default C/C++ ones get automatically inherited.

    Let us know if you have any feedback on the new feature and we will be happy to make VisualGDB even better.

    #26848
    UdoEberhardt
    Participant

    Just tried it and it works as expected. The options you added in project properties make sense to me. Great job!

    I really appreciate your support. Unbelievable how fast you react on a feature suggestion. This is the second time I experienced this. First time I suggested separate Additional Options for C and C++. Will think about more feature ideas 😉

    Thanks again.

    Udo

    #26853
    support
    Keymaster

    No worries. This feature has been on our radar for a while. We were initially planning to add it later in the v5.5 release cycle together with other smaller MSBuild-related improvements, but as it’s always better to get feedback from real-world projects, we managed to fast-track it when you mentioned it.

    Let us know if you have any feedback or other feature suggestions and we will be happy to make VisualGDB better.

    #36150
    urosg
    Participant

    Hi, just tried to use this feature and as soon as I enable the option it breaks the build process.

    Error listed is: ninja: error: ‘{_exe_NAME}.lds’, needed by ‘ProjectName’, missing and no known rule to make it.

    This is a new clean project made with VisualGDB and STM32CubeMX.

    No changes were made to the built project just enabled the option.

    Any help would be appreciated.

     

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.