- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
How do I set custom compile options of gcc for only one file in Modus Toolbox2.1?
For example, the active of build configuration is "release" but only the mail.c file set non-optimized compilation options like -g.
I want to set different compilation options only for the main.c file.
Thanks,
Kenshow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you try using "pragma"
"#pragma GCC optimization_level n" may provide the service you want.
Refer to
https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NoTa_4591161,
As of now, there is no direct way to do this. I will be raising an internal ticket to track this issue so that the internal teams can evaluate the request.
As a workaround you can follow these steps for now:
1. Using the modus shell, perform a verbose build using the command 'make build VERBOSE=1'. You can refer to this blog to know about modus shell - Build, Program and Debug your ModusToolbox Application using the Command Line Interface (CLI)
2. Copy the compilation command of the required source file to a text file. For simplicity, I will consider main.c
3. Modify the arguments and run the compilation command directly on the modus shell to create a new main.o file.
4. Run the build again to run the linker.
Please let me know if this works for you.
Thanks and Regards,
Rakshith M B
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rakshith,
Thank you for your suggestions.
Well, I've never used LCI or VSCODE, so please give me time to check this.
Best Regards,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Len,
I've picked up main.c file as an example, but my question is how to change the options for a particular file. Although your approach based on the Volatile Declaration is valid, it is a little different from this thread. But, thank you for your advice.
Regards,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Motoo,
I think that using pragma is effective for optimization. However, this time I would like to use for the build option, so I will consider modifying the makefile.
Thanks for your advice.
Regards,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rakshith,
I tried your suggestion but realized that it could be done with Modus IDE.
Copy the project, change the options in the destination project, and use that object in the original project. Delete the original source files and build the original.
This time it was easier to use #pragma. However, I would like to be able to set custom options for each file in the Modus IDE.
Thanks,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NoTa_4591161,
Thank you for sharing.
Yes, I agree with you. All the different ways suggested here are workarounds. I have already raised an internal ticket to add this feature into the build system so that this request can be tracked.
Hope this helps.
Best regards,
Rakshith M B
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kenshow,
It looks like you are trying to prevent optimization on the file mail.c. I'm assuming this is because you are trying to debug code in this file.(?)
I believe the gcc compiler has some compile-time keyword parameters to disable types of optimization from within the module itself.
For example, using the volatile keyword on a variable (especially a local variable) will prevent the compiler from only making it available in CPU registers. It forces the variable to be accessed in RAM (or in registers).
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you try using "pragma"
"#pragma GCC optimization_level n" may provide the service you want.
Refer to
https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I just came up with this idea.
Since ModusToolbox 2.1 uses "Makefile", can't we add lines something like below?
==============
main.o : main.c
$(CC) -g -c main.c
==============
moto