Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
flags/lto: handle Clang case
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Mar 11, 2017
1 parent bffb365 commit 165aec9
Showing 1 changed file with 31 additions and 46 deletions.
77 changes: 31 additions & 46 deletions flags/lto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,40 @@ else()
polly_add_cache_flag(CMAKE_CXX_FLAGS_INIT "-flto")
polly_add_cache_flag(CMAKE_C_FLAGS_INIT "-flto")

if(CMAKE_HOST_WIN32)
set(_host_tag "windows")
elseif(CMAKE_HOST_APPLE)
set(_host_tag "darwin")
else()
set(_host_tag "linux")
endif()

# Fix for "BFD: ... : plugin needed to handle lto object" {
set(
CMAKE_AR
"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${_host_tag}-x86_64/bin/arm-linux-androideabi-gcc-ar"
CACHE
PATH
""
FORCE
)
string(COMPARE EQUAL "${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}" "clang" _is_clang)

set(
CMAKE_RANLIB
"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${_host_tag}-x86_64/bin/arm-linux-androideabi-gcc-ranlib"
CACHE
PATH
""
FORCE
)
# }


if(0) # TODO: do we need it?
set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_AR} qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()

# SECTION A
if(0) # TODO: do we need it?
if(_is_clang)
# Fix for error "format not recognized"
# (tested with 'android-ndk-r14-api-21-arm64-v8a-clang-hid-sections-lto')
polly_add_cache_flag(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=gold")
polly_add_cache_flag(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=gold")

polly_add_cache_flag(CMAKE_EXE_LINKER_FLAGS_INIT "-flto")
polly_add_cache_flag(CMAKE_SHARED_LINKER_FLAGS_INIT "-flto")
endif()

# SECTION B
if(0) # TODO: do we need it?
polly_add_cache_flag(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-flto")
polly_add_cache_flag(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-flto")
polly_add_cache_flag(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-fuse-ld=gold")
polly_add_cache_flag(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-fuse-ld=gold")
else()
# GCC, fix for "BFD: ... : plugin needed to handle lto object"
if(CMAKE_HOST_WIN32)
set(_host_tag "windows")
elseif(CMAKE_HOST_APPLE)
set(_host_tag "darwin")
else()
set(_host_tag "linux")
endif()

set(
CMAKE_AR
"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${_host_tag}-x86_64/bin/arm-linux-androideabi-gcc-ar"
CACHE
PATH
""
FORCE
)

set(
CMAKE_RANLIB
"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${_host_tag}-x86_64/bin/arm-linux-androideabi-gcc-ranlib"
CACHE
PATH
""
FORCE
)
endif()
endif()

Expand Down

0 comments on commit 165aec9

Please sign in to comment.