Page MenuHome GnuPG

libgcrypt: FTBFS with LTO
Closed, ResolvedPublic


Architecture: AMD64 (x86_64)
GCC version: 6.2.0 20160822 (AOSC OS, Core) (GCC)
LD (gold version): 2.27 (1.12)

When LTO is enabled in CFLAGS and LDFLAGS (-flto=jobserver -fuse-linker-plugins
to GCC and LD, respectively), libgcrypt refuses to build with an inlining error.

libtool: compile: gcc -DHAVE_CONFIG_H -I.
-I/var/lib/abbs/build/tmp.FrJpnZY70I/libgcrypt-1.7.5/cipher -I.. -I../src
-I/var/lib/abbs/build/tmp.FrJpnZY70I/libgcrypt-1.7.5/src -D_FORTIFY_SOURCE=2
-Wa,--noexecstack -pipe -Wno-error -fstack-protector-strong
--param=ssp-buffer-size=4 -fomit-frame-pointer -O2 -march=x86-64 -mtune=core2
-msse -msse2 -msse3 -fira-loop-pressure -fira-hoist-pressure -ftree-vectorize
-specs=/usr/lib/autobuild3/specs/hardened-cc1 -flto=jobserver -MT
camellia-aesni-avx-amd64.lo -MD -MP -MF .deps/camellia-aesni-avx-amd64.Tpo -c
-fPIC -DPIC -o .libs/camellia-aesni-avx-amd64.o
In file included from /usr/include/features.h:368:0,

from /usr/include/stdio.h:27,

/var/lib/abbs/build/tmp.FrJpnZY70I/libgcrypt-1.7.5/cipher/rijndael-ssse3-amd64.c: In
function '_gcry_aes_ssse3_do_setkey':
/usr/include/bits/string3.h:50:1: error: inlining failed in call to
always_inline 'memcpy': target specific option mismatch
NTH (memcpy (void *restrict dest, const void *restrict __src,
note: called from here

memcpy(&ctx->keyschdec32[0][0], key, keybits / 8);

mv -f .deps/camellia-aesni-avx2-amd64.Tpo .deps/camellia-aesni-avx2-amd64.Plo
mv -f .deps/camellia-aesni-avx-amd64.Tpo .deps/camellia-aesni-avx-amd64.Plo
make[1]: * [Makefile:660: rijndael-ssse3-amd64.lo] Error 1
* Waiting for unfinished jobs....
mv -f .deps/rfc2268.Tpo .deps/rfc2268.Plo
mv -f .deps/idea.Tpo .deps/idea.Plo
mv -f .deps/salsa20.Tpo .deps/salsa20.Plo
mv -f .deps/camellia-glue.Tpo .deps/camellia-glue.Plo
mv -f .deps/camellia.Tpo .deps/camellia.Plo
mv -f .deps/seed.Tpo .deps/seed.Plo
make[1]: Leaving directory
make: *** [Makefile:477: install-recursive] Error 1



Event Timeline

JeffBai set Version to 1.7.5.
JeffBai added a subscriber: JeffBai.

Jussi: would you be so kind and look at this problem?

The configure option --disable-asm might help.

werner: Well... Doesn't it destroy libgcrypt's performance?

Attached patch should solve LTO problems with rinjdael-ssse-amd64.c.

'memcpy' problem seems to be because of bad interaction between -flto and
#pragma "no-sse". Strangely switching memcpy to buf_cpy solved problem, even
through buf_cpy itself just uses memcpy (on x86).

With this issue solved, I ran in to problem with rijndael-ssse3 assembly code
blocks going missing with -flto and link failing. So rest of the changes in
patch are for fixing lto visibility of assembly.

werner added a project: Unreleased.

The patch has been applied to master and the 1.7 branch. A 1.7.6 will be
released soon.

werner removed a project: Unreleased.
werner added a project: Testing.

There have been some problems backporting the batch to 1.7 thus it will not go
into 1.7.6.

werner removed a project: Testing.
werner added a project: Unreleased.