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

John Frankish john.frankish at outlook.com
Fri Jan 5 12:00:04 CET 2018


> > > > 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?
>
Oops - spoke too soon :(

Using libasound from alsa-lib-1.1.5 compiled with  lto, but without your update from alsa git:

$ speaker-test -Ddefault:1 -c2 -t wav -l1

speaker-test 1.1.5

Playback device is default:1
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
speaker-test: relocation error: speaker-test: symbol snd_pcm_hw_params_get_buffer_size_min, version ALSA_0.9.0rc4 not defined in file libasound.so.2 with link time reference




More information about the Alsa-devel mailing list