Skip to content

Commit

Permalink
Fix openmp tests.
Browse files Browse the repository at this point in the history
We don't currently have any infrastructure for copying the openmp
runtime to the device as part of the test. Keep using the static
openmp like we used to.

For ndk-build, we should be copying the runtime library to the install
directory if appropriate.

For CMake, the install directory is not used. We have this same
problem with ASan, so if we decide that CMake should do anything about
that we can handle openmp the same way.

Test: ./run_tests.py --rebuild --filter openmp
Bug: android/ndk#1028
Change-Id: Id41455c7dad1117aeae4587a2bc1b9601d55e472
  • Loading branch information
DanAlbert committed Aug 23, 2019
1 parent 8a52d02 commit 5242573
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions build/core/build-binary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ libs_in_ldflags := \

include $(BUILD_SYSTEM)/system_libs.mk

# The only way to statically link libomp.a is with
# `-Wl,-Bstatic -lomp -Wl,-Bdynamic`, so we need to accept `-lomp`.
# https://github.com/android-ndk/ndk/issues/1028
NDK_SYSTEM_LIBS += libomp.so

libs_in_ldflags := $(filter-out $(NDK_SYSTEM_LIBS:lib%.so=-l%),$(libs_in_ldflags))

ifneq (,$(strip $(libs_in_ldflags)))
Expand Down
11 changes: 8 additions & 3 deletions tests/device/openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.6.0)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -fopenmp")

add_executable(openmp jni/openmp.c)
set_target_properties(openmp PROPERTIES COMPILE_OPTIONS -fopenmp)
target_link_libraries(openmp -Wl,-Bstatic -lomp -Wl,-Bdynamic)

add_executable(openmp2 jni/openmp2.c)
set_target_properties(openmp2 PROPERTIES COMPILE_OPTIONS -fopenmp)
target_link_libraries(openmp2 -Wl,-Bstatic -lomp -Wl,-Bdynamic)

add_executable(fib jni/fib.c)
set_target_properties(fib PROPERTIES COMPILE_OPTIONS -fopenmp)
target_link_libraries(fib -Wl,-Bstatic -lomp -Wl,-Bdynamic)
6 changes: 3 additions & 3 deletions tests/device/openmp/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ include $(CLEAR_VARS)
LOCAL_MODULE := openmp
LOCAL_SRC_FILES := openmp.c
LOCAL_CFLAGS += -fopenmp
LOCAL_LDFLAGS += -fopenmp
LOCAL_LDFLAGS += -Wl,-Bstatic -lomp -Wl,-Bdynamic
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
LOCAL_MODULE := openmp2
LOCAL_SRC_FILES := openmp2.c
LOCAL_CFLAGS += -fopenmp
LOCAL_LDFLAGS += -fopenmp
LOCAL_LDFLAGS += -Wl,-Bstatic -lomp -Wl,-Bdynamic
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
LOCAL_MODULE := fib
LOCAL_SRC_FILES := fib.c
LOCAL_CFLAGS += -fopenmp
LOCAL_LDFLAGS += -fopenmp
LOCAL_LDFLAGS += -Wl,-Bstatic -lomp -Wl,-Bdynamic
include $(BUILD_EXECUTABLE)

0 comments on commit 5242573

Please sign in to comment.