フィルターのクリア

How to disable position independent code (PIC) in CMake code generation for PIL?

10 ビュー (過去 30 日間)
Peter
Peter 2024 年 6 月 3 日
回答済み: Divyanshu 2024 年 6 月 26 日 6:06
Hi. I'm trying to create a PIL connectivity configuration for a board with a Cortex-M3 processor, using the "modern" method of target package and CMake. The code that is being generated is PIC, and I need it to not be PIC because I really do not want to write a bootloader. I simply want to run a PIL simulation and confirm that everything is calculated correctly. Handling a PIE is wasted effort.
However, I cannot see any way to disable PIC. In the internal files of the coder toolbox, file "writeCMakeLists.m" which generates the CMakeLists.txt from what I can see, the following is written:
% Always compile using position independent code
% Static libraries built without PIC might cause a failure when linked by a shared library
% See g2329017
cmakeTarget.Properties(end+1) = coder.make.internal.cmake.NameValuePair('PREFIX', '""');
cmakeTarget.Properties(end+1) = coder.make.internal.cmake.NameValuePair('POSITION_INDEPENDENT_CODE', 'ON');
So from that I take that PIC is forced on the generated code. I would like to know if there is any way to disable PIC, or, as a last resort, if modifying the above Matlab file to disable PIC would have any unintended consequences (this is a bit complicated since I don't have admin at work to modify program files, but as a last resort can be done).
Thank you.

回答 (1 件)

Divyanshu
Divyanshu 2024 年 6 月 26 日 6:06
Hi Peter,
As per my understanding from the comments specified in the internal file of the toolbox, 'PIC' is intentionally enabled or kept always 'on' for avoiding failures while linking shared libraries with static libraries.
Therefore, there should not be a way/option to disable it directly.
For more details, you may reach out to support:

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by