Skip to content

Commit

Permalink
Hoist --eh-frame-hdr into the build systems.
Browse files Browse the repository at this point in the history
Better than making all the users do it themselves. We can revert this
once we get a clang with https://reviews.llvm.org/D43203.

Test: ./checkbuild.py && ./run_tests.py
Bug: android/ndk#593
Bug: http://b/72512648
Change-Id: I53791d53cfab8eefe004f8e278527c80f1fa1240
(cherry picked from commit c8558428d993000a68fe0e72815b2bb85f228438)
  • Loading branch information
DanAlbert committed Feb 15, 2018
1 parent 15f3105 commit 3d72ae6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions build/cmake/android.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,12 @@ list(APPEND ANDROID_LINKER_FLAGS_EXE
-Wl,--gc-sections
-Wl,-z,nocopyreloc)

# Clang does not automatically pass --eh-frame-hdr to the linker for static
# executables.
# https://github.com/android-ndk/ndk/issues/593
# http://b/72512648
list(APPEND ANDROID_LINKER_FLAGS_EXE -Wl,--eh-frame-hdr)

# Debug and release flags.
list(APPEND ANDROID_COMPILER_FLAGS_DEBUG -O0)
if(ANDROID_ABI MATCHES "^armeabi")
Expand Down
6 changes: 6 additions & 0 deletions build/core/build-binary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ ifneq (,$(filter true,$(NDK_APP_PIE) $(TARGET_PIE)))
LOCAL_CFLAGS += -fpie
LOCAL_LDFLAGS += -fpie -pie
endif
else
# Clang does not automatically pass --eh-frame-hdr to the linker for
# static executables.
# https://github.com/android-ndk/ndk/issues/593
# http://b/72512648
LOCAL_LDFLAGS += -Wl,--eh-frame-hdr
endif
endif
endif
Expand Down
6 changes: 6 additions & 0 deletions build/tools/make_standalone_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ def make_clang_scripts(install_dir, triple, api, windows):
if arch == 'i686':
common_flags += ' -mstackrealign'

# Clang does not automatically pass --eh-frame-hdr to the linker for static
# executables.
# https://github.com/android-ndk/ndk/issues/593
# http://b/72512648
common_flags += ' -Wl,--eh-frame-hdr'

unix_flags = common_flags
unix_flags += ' --sysroot `dirname $0`/../sysroot'

Expand Down
2 changes: 1 addition & 1 deletion tests/device/clone/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := clone-static
LOCAL_SRC_FILES := clone.c
LOCAL_LDFLAGS += -static -Wl,--eh-frame-hdr
LOCAL_LDFLAGS += -static
include $(BUILD_EXECUTABLE)
3 changes: 1 addition & 2 deletions tests/device/static-executable-exceptions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ cmake_minimum_required(VERSION 3.6.0)

add_executable(static-executable jni/main.cpp)

set_target_properties(
static-executable PROPERTIES LINK_FLAGS "-static -Wl,--eh-frame-hdr")
set_target_properties(static-executable PROPERTIES LINK_FLAGS "-static")
2 changes: 1 addition & 1 deletion tests/device/static-executable-exceptions/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ include $(CLEAR_VARS)
LOCAL_MODULE := static-executable
LOCAL_SRC_FILES := main.cpp
LOCAL_CPPFLAGS := -fexceptions
LOCAL_LDFLAGS := -static -Wl,--eh-frame-hdr
LOCAL_LDFLAGS := -static
include $(BUILD_EXECUTABLE)
2 changes: 1 addition & 1 deletion tests/device/wait/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := test_wait-static
LOCAL_SRC_FILES := test_wait.c
LOCAL_LDFLAGS += -static -Wl,--eh-frame-hdr
LOCAL_LDFLAGS += -static
include $(BUILD_EXECUTABLE)

0 comments on commit 3d72ae6

Please sign in to comment.