<?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>gcc dead code elimination</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4754/gcc-dead-code-elimination</link><description>Hello, 
 I see that the make files that have been included have provision to remove dead code from the projects to reduce code food print. This is accomplished using the following commands 
 -ffunction-sections -fdata-sections
Wl,--gc-sections 
 However</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Dec 2014 12:05:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4754/gcc-dead-code-elimination" /><item><title>RE: gcc dead code elimination</title><link>https://devzone.nordicsemi.com/thread/16838?ContentTypeID=1</link><pubDate>Thu, 11 Dec 2014 12:05:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f1524af-a7d6-4e4c-8213-c8bf2f41d04f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I tested it here by adding an unused dummy function in the code. Checking the map file afterwards confirmed that it was dumped by the linker. Did you make sure to add the flags to the linker, and not just the compiler?&lt;/p&gt;
&lt;p&gt;Example on how to set the flags:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# keep every function in separate section. This will allow linker to dump unused functions
CFLAGS += -ffunction-sections

# let linker to dump unused sections
LDFLAGS := -Wl,--gc-sections
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case you&amp;#39;re not aware of it, one trick to easily determine the difference in size of the build is to echo the size. This can be done by adding the following lines to makefile.common:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; #Toolchain commands. Line ~34
SIZE    		:= &amp;quot;$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size&amp;quot;

#Line ~141
$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>