scrypt-jane icon indicating copy to clipboard operation
scrypt-jane copied to clipboard

Undefined reference to chunkmix with gcc LTO

Open hmage opened this issue 8 years ago • 0 comments

When I try to compile with LTO enabled, the linker suddenly suddenly can't see the assembler function bodies (LTO pass probably removes them too early).

I tried to set __attribute__((used)) on them but I failed, maybe you will find a faster way to do it.

Without LTO it compiles fine:

bujak_e@wraith:~/temp/scrypt-jane$ gcc scrypt-jane-speed.c -O3 -DSCRYPT_SHA256 -DSCRYPT_SALSA $3 -o scrypt_speed

With LTO it gives out link errors:

bujak_e@wraith:~/temp/scrypt-jane$ gcc scrypt-jane-speed.c -O3 -flto -DSCRYPT_SHA256 -DSCRYPT_SALSA $3 -o scrypt_speed
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_sse2.lto_priv.12':
ccK78ets.ltrans2.o:(.text+0x117): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x149): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x1b1): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x1d3): undefined reference to `scrypt_ChunkMix_sse2'
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_avx.lto_priv.11':
ccK78ets.ltrans2.o:(.text+0x367): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x399): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x401): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x423): undefined reference to `scrypt_ChunkMix_avx'
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_xop.lto_priv.10':
ccK78ets.ltrans2.o:(.text+0x5b7): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x5e9): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x651): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x673): undefined reference to `scrypt_ChunkMix_xop'
collect2: error: ld returned 1 exit status

GCC version:

bujak_e@wraith:~/temp/scrypt-jane$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

hmage avatar Apr 25 '16 18:04 hmage