<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103547/zephry-lto-optimization</link><description>Hello! 
 Code size is quite crucial in our project, naturally CONFIG_SIZE_OPTIMIZATIONS is enabled. In other projects I&amp;#39;ve experience with LTO (link time optimization), this feature could cut off a few more percents from final binary size. Alas I haven</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 May 2024 10:36:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103547/zephry-lto-optimization" /><item><title>RE: Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/thread/482240?ContentTypeID=1</link><pubDate>Tue, 07 May 2024 10:36:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4a0ff79-8cff-4a0a-8323-231286002e31</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Experimental support for LTO was added in nRF Connect SDK v2.6.0. It can be enabled by setting&amp;nbsp;CONFIG_LTO=y and&amp;nbsp;CONFIG_ISR_TABLES_LOCAL_DECLARATION=y in your prj.conf file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/thread/448830?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 13:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a507aa85-a3cd-47e9-ad6d-022c3566ab1e</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;H Tamas, sorry for the delay.&lt;/p&gt;
[quote user="Tamas Selmeci"]I tried the statement found in the PR with more NCS-2.2.0 and NCS-2.4.1 applications, and surprisingly the final binary was usually greater than without LTO![/quote]
&lt;p&gt;Our developers are experiencing the same as well.&lt;/p&gt;
[quote user="Tamas Selmeci"]Is there any way forcing NCS to use &lt;code&gt;-lflto&lt;/code&gt; not only for the application code, but for the rest (Zephyr kernel) too? I&amp;#39;d give it a try...[/quote]
&lt;p&gt;This is something currently being implemented. However, I am not able to predict at what time anything will be available.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/thread/446972?ContentTypeID=1</link><pubDate>Thu, 21 Sep 2023 04:04:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5e511ac-e767-44c1-8990-2e902342d1b7</guid><dc:creator>Tamas Selmeci</dc:creator><description>&lt;p&gt;I used to have success with LTO in my other projects during the recent years. The required technique usually was to specify &lt;code&gt;-flto&lt;/code&gt; both during compile and linking, and at the cost of a much longer linking the resulting binary size was 3-5-7% less than without LTO. In some circumstances this can mean a lot ;)&lt;/p&gt;
&lt;p&gt;I tried the statement found in the PR with more NCS-2.2.0 and NCS-2.4.1 applications, and surprisingly the final binary was usually greater than without LTO!&lt;/p&gt;
&lt;p&gt;Is there any way forcing NCS to use &lt;code&gt;-lflto&lt;/code&gt; not only for the application code, but for the rest (Zephyr kernel) too? I&amp;#39;d give it a try...&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/thread/445427?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 13:25:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a858afc4-c5db-4d6b-a889-e2fa68a8fba5</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;There is ongoing work with to enable LTO. Please see &lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/11349"&gt;PR#11349 - asset_tracker_v2: Enable link time optimization&lt;/a&gt; as an example which enables LTO for the application code only. You may try the same technique to get LTO working for the application part of the code.&lt;/p&gt;
&lt;p&gt;What is going on in the mentioned PR is that &lt;code&gt;-flo&lt;/code&gt; is passed to the compiler when it compiles the application code. That is what this does:&amp;nbsp; &lt;code&gt;target_compile_options(app PRIVATE &amp;quot;-flto&amp;quot;) &lt;/code&gt;and that is done if&amp;nbsp;&lt;code&gt;&lt;span&gt;&lt;span dir="ltr"&gt;CONFIG_ASSET_TRACKER_V2_LTO&lt;/span&gt;&lt;/span&gt;&lt;/code&gt; is enabled.&lt;/p&gt;
&lt;p&gt;More about the &lt;code&gt;-flto&lt;/code&gt; flag can be found here: &lt;a href="https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html"&gt;https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;What it really does is that it strips out unused functions from the final executable thereby saving flash space.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]zephyr_ld_options(&amp;quot;-flto&amp;quot;)[/quote]
&lt;p&gt;This only adds the &lt;code&gt;-flto&lt;/code&gt; option to the linker stage. The flag should be added to the compile stage instead, as in the PR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephry LTO optimization</title><link>https://devzone.nordicsemi.com/thread/444954?ContentTypeID=1</link><pubDate>Thu, 07 Sep 2023 13:23:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ffaabbe-6cff-47c1-aeb5-b1f1afcc8714</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hello Tamas, &lt;/p&gt;
&lt;p&gt;I am checking what can be done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>