[alsa-devel] Compiling alsa-lib fails with lto

Takashi Iwai tiwai at suse.de
Fri Jan 5 08:42:24 CET 2018


On Fri, 05 Jan 2018 07:18:36 +0100,
John Frankish wrote:
> 
> > > Using gcc-7.2.0 and alsa-lib-1.1.5
> > > 
> > > Is there a way to compile alsa-lib with lto (the method below works with alsa-plugins and alsa-utils)?
> > > 
> > > Compiling alsa-lib like this works fine:
> > > 
> > > CC="gcc -mtune=generic -Os -pipe" CXX="g++ -mtune=generic -Os -pipe 
> > > -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local 
> > > --disable-static --localstatedir=/var 
> > > --with-configdir=/usr/local/etc/alsa
> > > 
> > > ..but compiling with lto like this fails as per below:
> > > 
> > > CC=" gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe" CXX="g++ 
> > > -flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions 
> > > -fno-rtti" ./configure --prefix=/usr/local --disable-static 
> > > --localstatedir=/var --with-configdir=/usr/local/etc/alsa
> > > 
> > > libtool: link: gcc -flto -fuse-linker-plugin -mtune=generic -Os -pipe 
> > > -o .libs/aserver aserver.o  ../src/.libs/libasound.so -lm -ldl 
> > > -lpthread -lrt
> > > /tmp/ccoTf6DH.ltrans0.ltrans.o: In function `pcm_shm_cmd':
> > > <artificial>:(.text+0xe7a): undefined reference to `snd_pcm_forward'
> > > ../src/.libs/libasound.so: undefined reference to `snd_timer_params_set_filter'
> > > ../src/.libs/libasound.so: undefined reference to `snd_ctl_elem_info_get_dimension'
> > > ../src/.libs/libasound.so: undefined reference to `snd_ctl_elem_info_get_dimensions'
> > > collect2: error: ld returned 1 exit status
> > > make[1]: *** [Makefile:333: aserver] Error 1
> > > make[1]: Leaving directory '/usr/src/alsa-lib-1.1.5/aserver'
> > > make: *** [Makefile:338: all-recursive] Error 1 Command exited with 
> > > non-zero status 2
> > 
> > That's interesting.  These are basically fallouts of the internal function calls,
> > and they should have been called with INTERNAL() wrapper for covering
> > the versioned symbols.
> > 
> > I fixed the latest git tree, but still something doesn't work with linkage
> > in aserver.  I guess Makefile.am in aserver needs to be fixed somehow,
> > but I leave it as is for now, as you can work around it by disabling via the
> > configure option.
> >
> Thanks - I'm not sure though what you mean by "configure option" - there is no "--disable-aserver"?

It can be done by specifying --with-pcm-plugins without shm.
But it'd be good to have --disable-aserver option for the easiness
(or at best fix the aserver build :)

> In any case, libasound is built before "make" halts and is 29kb smaller (stripped) with lto :)

And does everything still work, hopefully?


Takashi


More information about the Alsa-devel mailing list