Skip to content

LTO_AVAILABLE check failing for clang #2120

@springmeyer

Description

@springmeyer

Currently the -flto configure check is failing for clang++ linux builds on travis: https://travis-ci.org/Project-OSRM/osrm-backend/jobs/116873025#L1200

The way LTO works with clang on linux is:

  • -flto needs to be passed to CXXFLAGS
  • -flto needs to be passed to LDFLAGS
  • The gold linker needs to either be /usr/bin/ld or you need to pass -B/path/to/custom/bin if the gold linker lives at /path/to/custom/bin/ld
  • libLLVMgold.so needs to be installed apt-get install llvm-3.7-dev

The reason that the configure check is failing in our builds right now is that -flto is not being passed to the linking flags for the check_cxx_compiler_flag check here. And therefore the linker is not put in LTO mode for that configure check and the .o file with LTO support cannot be read. The error in the cmake logs is: CMakeFiles/cmTryCompileExec3478428907.dir/src.cxx.o: file not recognized: File format not recognized

One workaround I've found is to do export LDFLAGS="-flto" which then triggers the check_cxx_compiler_flag to use -flto in the linker flags and then the binary produced is valid and can be run. But ideally some better workaround could be found, however my knowledge of cmake is too limited to begin to know what to do.

/cc @daniel-j-h for help.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions