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

LowFat with link-time optimizations not working #18

Open
taddeus opened this issue May 6, 2019 · 8 comments
Open

LowFat with link-time optimizations not working #18

taddeus opened this issue May 6, 2019 · 8 comments

Comments

@taddeus
Copy link

taddeus commented May 6, 2019

I am trying to compile benchmarks with link-time optimizations by adding -flto to CFLAGS and LDFLAGS. To have these options available, I added -DLLVM_ENABLE_LTO=ON to build.sh on line 76. This breaks the build script with the following error:

CMake Error at projects/compiler-rt/cmake/Modules/AddCompilerRT.cmake:133 (message):
  Architecture x86_64 can't be targeted
Call Stack (most recent call first):
  projects/compiler-rt/lib/lowfat/CMakeLists.txt:10 (add_compiler_rt_runtime)

See the complete output of the build script here: https://gist.github.com/taddeus/7c2babd439e2846abb7a598ec12a029a

@GJDuck
Copy link
Owner

GJDuck commented May 6, 2019

Thanks for the report. I am not sure if LowFat has ever been tested with LTO before, so I am not surprised something breaks. Unfortunately the error message here is not very helpful.

@taddeus
Copy link
Author

taddeus commented May 7, 2019

Yeah I understand. It would be nice to get it to work though, the instrumentation should not break with LTO in principle. I'm not sure how to approach fixing this in the build script, though. Could you give me some pointers on that?

@GJDuck
Copy link
Owner

GJDuck commented May 14, 2019

By chance I was looking into LTO for a different project. I don't think the -DLLVM_ENABLE_LTO=ON build option makes an LTO-compatible LLVM, rather it builds LLVM itself with LTO.

For the former you need to compile+install the gold linker and point -DLLVM_BINUTILS_INCDIR to the binutils include directory: https://llvm.org/docs/GoldPlugin.html

@taddeus
Copy link
Author

taddeus commented May 14, 2019

Ah, of course. Come to think of it, I'm doing this for another project as well... I will try to get this working tomorrow and let you know if it works.

@taddeus
Copy link
Author

taddeus commented May 15, 2019

@GJDuck did you get this to work? I tried to get it to compile with the same binutils setup I have working in another setup but the lowfat compiler breaks with a syntax error in the lowfat.ld linker script (unexpected STRING).

@GJDuck
Copy link
Owner

GJDuck commented May 15, 2019

No, I was using LTO for something else. I am not sure if ld.gold supports linker scripts, so perhaps that is the problem. All I can think of is removing the reference to lowfat.ld from the modified clang front end, with compile with global support disabled -mllvm -lowfat-no-replace-globals,

@taddeus
Copy link
Author

taddeus commented May 16, 2019

Hmm, I do need the full instrumentation. It seems like LTO is not going to work, then.

@taddeus
Copy link
Author

taddeus commented May 16, 2019

Looked into this a bit, the problem is the INSERT AFTER command in the linker script which tells ld to augment the default linker script. gold does not have a default linker script and does not support the command. One would have to extend the linker script with ld's default script instead of using INSERT AFTER. See also this thread: https://bugzilla.redhat.com/show_bug.cgi?id=927573

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