Sysprogs forums › Forums › VisualGDB › Preprocess linker scripts
- This topic has 4 replies, 3 voices, and was last updated 11 hours, 21 minutes ago by urosg.
-
AuthorPosts
-
December 10, 2019 at 08:20 #26833UdoEberhardtParticipant
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
December 10, 2019 at 19:16 #26845supportKeymasterNo 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.
December 11, 2019 at 17:27 #26848UdoEberhardtParticipantJust 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
December 11, 2019 at 18:52 #26853supportKeymasterNo 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.
November 21, 2024 at 23:10 #36150urosgParticipantHi, 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.
-
AuthorPosts
- You must be logged in to reply to this topic.