>= 3.0.3 can not build with LTO
Hi! When trying to build apparmor 3.0.3 with LTO (it's the default for Arch Linux now), it fails with:
/bin/sh ../libtool --tag=CC --mode=link gcc -Wall -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -fPIC -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack
-clash-protection -fcf-protection -g -fvar-tracking-assignments -fdebug-prefix-map=/build/apparmor/src=/usr/src/debug -flto -version-info 9:1:8 -XCClinker -dynamic -pthread -Wl,--version-script=../src/libapparmor.map -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto -o libapparmor.la -rpath /usr/lib grammar.lo l
ibaalogparse.lo kernel.lo scanner.lo private.lo features.lo kernel_interface.lo policy_cache.lo PMurHash.lo
libtool: link: gcc -shared -fPIC -DPIC .libs/grammar.o .libs/libaalogparse.o .libs/kernel.o .libs/scanner.o .libs/private.o .libs/features.o .libs/kernel_interface.o .libs/policy_cache.o .libs/PMurHash.o -march=x86-64 -mtune=generic -O2 -g -flto -dynamic -pthread -Wl,--version-script=../src/libapparmor.map -Wl,-O
1 -Wl,--sort-common -Wl,--as-needed -Wl,-z -Wl,relro -Wl,-z -Wl,now -flto -pthread -Wl,-soname -Wl,libapparmor.so.1 -o .libs/libapparmor.so.1.8.1
lto1: warning: unrecognized gcc debugging option: y
lto1: warning: unrecognized gcc debugging option: n
lto1: warning: unrecognized gcc debugging option: m
lto1: warning: unrecognized gcc debugging option: i
lto1: warning: unrecognized gcc debugging option: c
lto1: warning: unrecognized gcc debugging option: y
lto1: warning: unrecognized gcc debugging option: n
lto1: warning: unrecognized gcc debugging option: m
lto1: warning: unrecognized gcc debugging option: i
lto1: warning: unrecognized gcc debugging option: c
/tmp/cc59WQWy.s: Assembler messages:
/tmp/cc59WQWy.s: Error: invalid attempt to declare external version name as default in symbol `change_hat@@APPARMOR_1.0'
make[3]: *** [/tmp/ccUAfOho.mk:2: /tmp/ccMyL1C3.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:708: libapparmor.la] Error 1
make[2]: Leaving directory '/build/apparmor/src/apparmor-3.0.3/libraries/libapparmor/src'
make[1]: *** [Makefile:626: all] Error 2
make[1]: Leaving directory '/build/apparmor/src/apparmor-3.0.3/libraries/libapparmor/src'
make: *** [Makefile:409: all-recursive] Error 1
Full build log: apparmor-3.0.3-build.log