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

John Frankish john.frankish at outlook.com
Fri Jan 5 07:18:36 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"?

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

John



More information about the Alsa-devel mailing list