NEW BUILD SYSTEM: Cannot build rtems-libbsd
Niteesh G. S.
niteesh.gs at gmail.com
Wed Jul 8 07:22:22 UTC 2020
On Wed, Jul 8, 2020 at 12:11 PM Christian Mauderer <
christian.mauderer at embedded-brains.de> wrote:
> On 08/07/2020 08:35, Niteesh G. S. wrote:
> > On Wed, Jul 8, 2020 at 11:52 AM Christian Mauderer
> > <christian.mauderer at embedded-brains.de
> > <mailto:christian.mauderer at embedded-brains.de>> wrote:
> >
> > On 08/07/2020 08:13, Sebastian Huber wrote:
> > > On 08/07/2020 08:10, Niteesh G. S. wrote:
> > >
> > >> On Tue, Jul 7, 2020 at 10:42 AM Sebastian Huber
> > >> <sebastian.huber at embedded-brains.de
> > <mailto:sebastian.huber at embedded-brains.de>
> > >> <mailto:sebastian.huber at embedded-brains.de
> > <mailto:sebastian.huber at embedded-brains.de>>> wrote:
> > >>
> > >> Hello,
> > >>
> > >> the problem is that the new build system doesn't export
> > optimization
> > >> flags such as -Wl,--gc-sections. The libbsd build should
> > enable this
> > >> linker option unconditionally.
> > >>
> > >>
> > >> Thank you. I got it fixed (temporarily) by modifying rtems.py.
> > >>
> > >> conf.env.CFLAGS = cflags['cflags'] + ['-ffunction-sections'] +
> > >> ['-fdata-sections']
> > > This instructs the compiler to add data elements and functions into
> > > separate sections. This is necessary so that the linker can carry
> out
> > > the garbage collection.
> >
> > There is an unused function in libbsd that can't link because a
> function
> > it calls isn't there. Till now the two flags had been provided by the
> > BSP. It seems that now they are not provided anymore.
> >
> > The problematic function is m_unmappedtouio in uipc_mbuf.c. It tries
> to
> > use PHYS_TO_VM_PAGE which isn't defined in libbsd. I think we should
> > just remove m_unmappedtouio (with #ifndef __rtems__) on the longer
> term.
> > But not having the -ffunction-sections and -fdata-sections most
> likely
> > makes our binary bigger and maybe leads to other similar bugs.
> Therefore
> > I suggested to add the CFLAGS first.
> >
> > >>
> > >> As per Christian suggestions, I tried exporting CFLAGS with these
> GCC
> > >> flags and then calling ./waf configure but they didn't work.
> > > You have to add -Wl,--gc-sections to the linker flags.
> >
> > As far as I know Niteesh used that one too. I think for that one
> LDFLAGS
> > worked as a workarround.
> >
> >
> > Yes, I did try exporting LDFLAGS too but they also didn't work out.
> > I tried the following:
> > 1) export LDFLAGS="-Wl,--gc-sections"
> > 2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6
> > --rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini
> > I also tried running
> > 1) LDFLAGS="-Wl,--gc-sections" ./waf configure --prefix=$RTEMS/6
> > --rtems-version=6 --rtems-bsps=arm/beagleboneblack
> > --buildset=buildset/minimal.ini
> > Both of them didn't work out.
>
> Have the flags been ignored and not used or did that not fix the
> problem? I would assume the second. You should see the difference if you
> call "./waf -v" and take a look at one of the linker calls to generate
> the test applications.
>
Yes, it is the second case. The linker flags are being used but it doesn't
fix the problem.
I used the following commands to ensure this.
1) export LDFLAGS="-Wl,--gc-sections"
2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6
--rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini
3) ./waf -j1 -v
On using the above commands I get the following output
['/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',* '-Wl,--gc-sections'*]
I then tried unsetting the LDFLAGS
1) unset LDFLAGS
2) ./waf configure --prefix=$RTEMS/6 --rtems-version=6
--rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini
3) ./waf -j1 -v
Using the above commands give the following output
['/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']
If this help,
With the LDFLAGS set already, ./waf configure doesn't mention that is
already defined
but when the CFLAGS are set, for eg: export CFLAGS="-ffunction-sections"
./waf configure mentions that CFLAGS is already been set
Pasting the ./waf configure output
//////////////////////////////////////////////
Setting top to :
/home/niteesh/development/rtems/rtems-libbsd
Setting out to :
/home/niteesh/development/rtems/rtems-libbsd/build
Environment variable set : CFLAGS
RTEMS Version : 6
Architectures : arm-rtems6
Board Support Package (BSP) : arm-rtems6-beagleboneblack
Show commands : no
Long commands : no
////////////////////////////////////////////////
But it doesn't do the same for LDFLAGS
export LDFLAGS="-Wl,--gc-sections"
output of ./waf configure
/////////////////////////////////////////////////
Setting top to :
/home/niteesh/development/rtems/rtems-libbsd
Setting out to :
/home/niteesh/development/rtems/rtems-libbsd/build
RTEMS Version : 6
Architectures : arm-rtems6
Board Support Package (BSP) : arm-rtems6-beagleboneblack
Show commands : no
Long commands : no
/////////////////////////////////////////////////
> >
> > I might be wrong here but waf seems to add the "-Wl,--gc-sections"
> > flags if "--function-sections" flags are defined.
> > https://git.rtems.org/rtems_waf/tree/rtems.py#n389
> >
>
> That's a bit odd. I don't think that I ever used that flag. But you are
> right: If CFLAGS contains the -function-section (only one -),
> "-Wl,--gc-sections" is added to the LDFLAGS here.
>
> >
> >
> > Best regards
> >
> > Christian
> > --
> > --------------------------------------------
> > embedded brains GmbH
> > Herr Christian Mauderer
> > Dornierstr. 4
> > D-82178 Puchheim
> > Germany
> > email: christian.mauderer at embedded-brains.de
> > <mailto:christian.mauderer at embedded-brains.de>
> > Phone: +49-89-18 94 741 - 18
> > Fax: +49-89-18 94 741 - 08
> > PGP: Public key available on request.
> >
> > Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
> >
>
> --
> --------------------------------------------
> embedded brains GmbH
> Herr Christian Mauderer
> Dornierstr. 4
> D-82178 Puchheim
> Germany
> email: christian.mauderer at embedded-brains.de
> Phone: +49-89-18 94 741 - 18
> Fax: +49-89-18 94 741 - 08
> PGP: Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200708/0459eb84/attachment-0001.html>
More information about the devel
mailing list