amd / aocl-libm-ose

AOCL-LibM
Other
100 stars 15 forks source link

LTO build not working #10

Open DarjanKrijan opened 3 years ago

DarjanKrijan commented 3 years ago

I tried adding Link Time Optimization by adding '-flto' to CCFLAGS and LINKFLAGS in src/SConscript, it results in compiler warnings and eventually errors: libalm_gcc_lto_warnings_errors.txt This is with GCC 11.1.0.

Also AOCC 3.1.0 gives an error not finding LLVMgold.so, while other compiles with -flto work with it:

$ scons -j1 --compiler=aocc
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
 [    CC] fast/_exp_tables.c => src/fast/_exp_tables.o
 [    CC] fast/expf.c => src/fast/expf.o
 [    CC] fast/logf.c => src/fast/logf.o
 [    CC] fast/powf.c => src/fast/powf.o
 [    CC] fast/tan.c => src/fast/tan.o
 [    CC] fast/tanf.c => src/fast/tanf.o
 [    AR] src/fast/libalmfast.a
 [RANLIB] src/fast/libalmfast.a
 [SHLINK] src/fast/libalmfast.so
/usr/bin/ld: /opt/aocc/bin/../lib/LLVMgold.so: error loading plugin: /opt/aocc/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [build/aocl-release/src/fast/libalmfast.so] Error 1
scons: building terminated because of errors.
====================== Configuration ======================

        Compiler     : aocc                  Build    : release
        ABI          : aocl                  Developer: 0
        ToolchainDir : /usr/bin
        BuildDir     : build/aocl-release

===========================================================

Link Time Optimization would be very benefitial for a library like this for better linking, inlining some functionality. Is this something that could be fixed and supported?

RobRich999 commented 2 years ago

I know this is a late reply, but nonetheless....

I do not think AOCC ships with the LLVM version of the gold linker. YMMV.

Still for AOCC/LLVM you should be able to use the LLD linker instead. Try adding "-fuse-ld=lld" to your linker flags.

LINKFLAGS="-fuse-ld=lld"

Otherwise, AFAICT, SCons should accept a LINK construction variable pointing to a linker in the build config.

For AOCC/LLVM software building also consider trying ThinLTO to potentially speed build times versus FullLTO by using "-flto=thin" in your compiler flags.