Skip to content

Commit

Permalink
Silence unused -Wa argument warning from linking with clang.
Browse files Browse the repository at this point in the history
CMake automatically forwards all compiler flags to the linker,
and clang doesn't like having -Wa flags being used for linking.

To prevent CMake from doing this would require meddling with the
CMAKE_<LANG>_COMPILE_OBJECT rules, which would get quite messy.

Bug: android/ndk#171
Change-Id: I3295948db64d3459db3af7ba3f0d431689812f80
(cherry picked from commit 78eb716552a0b43c2fc36bebf8ad991e6c77dca9)
  • Loading branch information
chaoren committed Aug 3, 2016
1 parent b78a980 commit 974f298
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions android.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ else()
list(APPEND ANDROID_LINKER_FLAGS
-Wl,-z,noexecstack)
endif()
if(ANDROID_TOOLCHAIN STREQUAL clang)
# CMake automatically forwards all compiler flags to the linker,
# and clang doesn't like having -Wa flags being used for linking.
# To prevent CMake from doing this would require meddling with
# the CMAKE_<LANG>_COMPILE_OBJECT rules, which would get quite messy.
list(APPEND ANDROID_LINKER_FLAGS
-Qunused-arguments)
endif()
if(ANDROID_DISABLE_RELRO)
list(APPEND ANDROID_LINKER_FLAGS
-Wl,-z,norelro -Wl,-z,lazy)
Expand Down
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.6.0)
if(CMAKE_NINJA_FORCE_RESPONSE_FILE)
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

add_library(c_shared SHARED shared/shared.c)
add_library(c_static STATIC static/static.c)
set(C_LIBRARIES c_shared c_static)
Expand Down

0 comments on commit 974f298

Please sign in to comment.