Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTO build not working #10

Open
DarjanKrijan opened this issue Sep 28, 2021 · 1 comment
Open

LTO build not working #10

DarjanKrijan opened this issue Sep 28, 2021 · 1 comment

Comments

@DarjanKrijan
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants