<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">On Wed, Jul 8, 2020 at 12:11 PM Christian Mauderer <<a href="mailto:christian.mauderer@embedded-brains.de">christian.mauderer@embedded-brains.de</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 08/07/2020 08:35, Niteesh G. S. wrote:<br>
> On Wed, Jul 8, 2020 at 11:52 AM Christian Mauderer<br>
> <<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a><br>
> <mailto:<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a>>> wrote:<br>
> <br>
>     On 08/07/2020 08:13, Sebastian Huber wrote:<br>
>     > On 08/07/2020 08:10, Niteesh G. S. wrote:<br>
>     ><br>
>     >> On Tue, Jul 7, 2020 at 10:42 AM Sebastian Huber<br>
>     >> <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
>     <mailto:<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>><br>
>     >> <mailto:<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
>     <mailto:<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>>> wrote:<br>
>     >><br>
>     >>     Hello,<br>
>     >><br>
>     >>     the problem is that the new build system doesn't export<br>
>     optimization<br>
>     >>     flags such as -Wl,--gc-sections. The libbsd build should<br>
>     enable this<br>
>     >>     linker option unconditionally.<br>
>     >><br>
>     >><br>
>     >> Thank you. I got it fixed (temporarily) by modifying rtems.py.<br>
>     >><br>
>     >> conf.env.CFLAGS    = cflags['cflags'] + ['-ffunction-sections'] +<br>
>     >> ['-fdata-sections']<br>
>     > This instructs the compiler to add data elements and functions into<br>
>     > separate sections. This is necessary so that the linker can carry out<br>
>     > the garbage collection.<br>
> <br>
>     There is an unused function in libbsd that can't link because a function<br>
>     it calls isn't there. Till now the two flags had been provided by the<br>
>     BSP. It seems that now they are not provided anymore.<br>
> <br>
>     The problematic function is m_unmappedtouio in uipc_mbuf.c. It tries to<br>
>     use PHYS_TO_VM_PAGE which isn't defined in libbsd. I think we should<br>
>     just remove m_unmappedtouio (with #ifndef __rtems__) on the longer term.<br>
>     But not having the -ffunction-sections and -fdata-sections most likely<br>
>     makes our binary bigger and maybe leads to other similar bugs. Therefore<br>
>     I suggested to add the CFLAGS first.<br>
> <br>
>     >><br>
>     >> As per Christian suggestions, I tried exporting CFLAGS with these GCC<br>
>     >> flags and then calling ./waf configure but they didn't work.<br>
>     > You have to add -Wl,--gc-sections to the linker flags.<br>
> <br>
>     As far as I know Niteesh used that one too. I think for that one LDFLAGS<br>
>     worked as a workarround.<br>
> <br>
>  <br>
> Yes, I did try exporting LDFLAGS too but they also didn't work out.<br>
> I tried the following:<br>
> 1) export LDFLAGS="-Wl,--gc-sections"<br>
> 2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6<br>
> --rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini<br>
> I also tried running<br>
> 1) LDFLAGS="-Wl,--gc-sections" ./waf configure --prefix=$RTEMS/6<br>
> --rtems-version=6 --rtems-bsps=arm/beagleboneblack<br>
> --buildset=buildset/minimal.ini<br>
> Both of them didn't work out.<br>
<br>
Have the flags been ignored and not used or did that not fix the<br>
problem? I would assume the second. You should see the difference if you<br>
call "./waf -v" and take a look at one of the linker calls to generate<br>
the test applications.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, it is the second case. The linker flags are being used but it doesn't fix the problem.</div><div class="gmail_default" style="font-size:small">I used the following commands to ensure this.</div><div class="gmail_default" style="font-size:small">1) export LDFLAGS="-Wl,--gc-sections"</div><div class="gmail_default" style="font-size:small">2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6 --rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini</div><div class="gmail_default" style="font-size:small">3) ./waf -j1 -v</div><div class="gmail_default" style="font-size:small">On using the above commands I get the following output</div><div class="gmail_default" style="font-size:small">['/home/niteesh/development/rtems/6/bin/arm-rtems6-gcc', '-qrtems', '-B/home/niteesh/development/rtems/6/arm-rtems6/beagleboneblack/lib', '-mcpu=cortex-a8', '-MMD', 'testsuite/arphole/test_main.c.45.o', '-o/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/arphole.exe', '-Wl,-Bstatic', '-L.', '-lbsd', '-Wl,-Bdynamic', '-lbsd', '-lm', '-lz', '-lrtemstest',<b> '-Wl,--gc-sections'</b>]<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I then tried unsetting the LDFLAGS</div><div class="gmail_default" style="font-size:small">1) unset LDFLAGS</div><div class="gmail_default" style="font-size:small">2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6 --rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini</div><div class="gmail_default" style="font-size:small">3) ./waf -j1 -v</div><div class="gmail_default" style="font-size:small">Using the above commands give the following output</div><div class="gmail_default" style="font-size:small">['/home/niteesh/development/rtems/6/bin/arm-rtems6-gcc', '-qrtems', '-B/home/niteesh/development/rtems/6/arm-rtems6/beagleboneblack/lib', '-mcpu=cortex-a8', '-MMD', 'testsuite/arphole/test_main.c.45.o', '-o/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/arphole.exe', '-Wl,-Bstatic', '-L.', '-lbsd', '-Wl,-Bdynamic', '-lbsd', '-lm', '-lz', '-lrtemstest']<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If this help,</div><div class="gmail_default" style="font-size:small">With the LDFLAGS set already, ./waf configure doesn't mention that is already defined</div><div class="gmail_default" style="font-size:small">but when the CFLAGS are set, for eg: export CFLAGS="-ffunction-sections"</div><div class="gmail_default" style="font-size:small">./waf configure mentions that CFLAGS is already been set</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Pasting the ./waf configure output</div><div class="gmail_default" style="font-size:small">//////////////////////////////////////////////</div><div class="gmail_default" style="font-size:small">Setting top to                           : /home/niteesh/development/rtems/rtems-libbsd                                                                                            <br>Setting out to                           : /home/niteesh/development/rtems/rtems-libbsd/build                                                                                      <br>Environment variable set                 : CFLAGS                                                                                                                                  <br>RTEMS Version                            : 6                                                                                                                                       <br>Architectures                            : arm-rtems6                                                                                                                              <br>Board Support Package (BSP)              : arm-rtems6-beagleboneblack                                                                                                              <br>Show commands                            : no                                                                                                                                      <br>Long commands                            : no            <br></div><div class="gmail_default" style="font-size:small">////////////////////////////////////////////////</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">But it doesn't do the same for LDFLAGS</div><div class="gmail_default" style="font-size:small">export LDFLAGS="-Wl,--gc-sections"</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">output of ./waf configure</div><div class="gmail_default" style="font-size:small">/////////////////////////////////////////////////</div><div class="gmail_default" style="font-size:small">Setting top to                           : /home/niteesh/development/rtems/rtems-libbsd                                                                                            <br>Setting out to                           : /home/niteesh/development/rtems/rtems-libbsd/build                                                                                      <br>RTEMS Version                            : 6                                                                                                                                       <br>Architectures                            : arm-rtems6                                                                                                                              <br>Board Support Package (BSP)              : arm-rtems6-beagleboneblack                                                                                                              <br>Show commands                            : no                                                                                                                                      <br>Long commands                            : no            <br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default">/////////////////////////////////////////////////</div><div class="gmail_default"></div></div><div class="gmail_default" style="font-size:small"><br></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
> I might be wrong here but waf seems to add the "-Wl,--gc-sections"<br>
> flags if "--function-sections" flags are defined.<br>
> <a href="https://git.rtems.org/rtems_waf/tree/rtems.py#n389" rel="noreferrer" target="_blank">https://git.rtems.org/rtems_waf/tree/rtems.py#n389</a><br>
> <br>
<br>
That's a bit odd. I don't think that I ever used that flag. But you are<br>
right: If CFLAGS contains the -function-section (only one -),<br>
"-Wl,--gc-sections" is added to the LDFLAGS here.<br>
<br>
>  <br>
> <br>
>     Best regards<br>
> <br>
>     Christian<br>
>     -- <br>
>     --------------------------------------------<br>
>     embedded brains GmbH<br>
>     Herr Christian Mauderer<br>
>     Dornierstr. 4<br>
>     D-82178 Puchheim<br>
>     Germany<br>
>     email: <a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a><br>
>     <mailto:<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a>><br>
>     Phone: +49-89-18 94 741 - 18<br>
>     Fax:   +49-89-18 94 741 - 08<br>
>     PGP: Public key available on request.<br>
> <br>
>     Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
> <br>
<br>
-- <br>
--------------------------------------------<br>
embedded brains GmbH<br>
Herr Christian Mauderer<br>
Dornierstr. 4<br>
D-82178 Puchheim<br>
Germany<br>
email: <a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a><br>
Phone: +49-89-18 94 741 - 18<br>
Fax:   +49-89-18 94 741 - 08<br>
PGP: Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
</blockquote></div></div>