Skip to content

Commit

Permalink
Merge pull request #2 from channel960608/feature/java2.0-proto-09252021
Browse files Browse the repository at this point in the history
FIX: skip signal handler registration when building java package
  • Loading branch information
channel960608 authored Sep 25, 2021
2 parents 1b1f190 + 6955539 commit 4915e06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ cmake_dependent_option(ENABLE_TESTCOVERAGE "Enable compilation with test coverag
option(BUILD_EXTENSION_PATH "Path to extension to build" "")
option(BUILD_CYTHON_MODULES "Build cython modules." OFF)
option(LOG_FATAL_THROW "Log exceptions but do not abort" ON)
option(BUILD_JAVA_NATIVE "Skip signal handler registration for Java Binding" OFF)
cmake_dependent_option(USE_SPLIT_ARCH_DLL "Build a separate DLL for each Cuda arch (Windows only)." ON "MSVC" OFF)
cmake_dependent_option(USE_CCACHE "Attempt using CCache to wrap the compilation" ON "UNIX" OFF)
cmake_dependent_option(MXNET_FORCE_SHARED_CRT "Build with dynamic CRT on Windows (/MD)" ON "MXNET_BUILD_SHARED_LIBS" OFF)
Expand Down Expand Up @@ -970,6 +971,10 @@ if(USE_CPP_PACKAGE)
target_compile_definitions(mxnet PUBLIC MXNET_USE_CPP_PACKAGE=1)
endif()

if(BUILD_JAVA_NATIVE)
add_definitions(-DSKIP_SIGNAL_HANDLER_REGISTRATION=1)
endif()

if(NOT CMAKE_BUILD_TYPE STREQUAL "Distribution")
# Staticbuild applies linker version script to hide private symbols, breaking unit tests
add_subdirectory(tests)
Expand Down
27 changes: 20 additions & 7 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,8 @@ build_ubuntu_cpu() {
build_ubuntu_cpu_openblas
}

build_ubuntu_cpu_and_test() {
build_ubuntu_cpu
java_package_integration_test
}

build_ubuntu_gpu_and_test() {
build_ubuntu_gpu
build_ubuntu_cpu_and_test_java() {
build_ubuntu_cpu_openblas_java
java_package_integration_test
}

Expand Down Expand Up @@ -349,6 +344,24 @@ build_ubuntu_cpu_openblas() {
ninja
}

build_ubuntu_cpu_openblas_java() {
set -ex
cd /work/build
CXXFLAGS="-Wno-error=strict-overflow" CC=gcc-7 CXX=g++-7 cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_TVM_OP=ON \
-DUSE_BLAS=Open \
-DUSE_ONEDNN=OFF \
-DUSE_CUDA=OFF \
-DUSE_DIST_KVSTORE=ON \
-DBUILD_CYTHON_MODULES=ON \
-DBUILD_EXTENSION_PATH=/work/mxnet/example/extensions/lib_external_ops \
-DBUILD_JAVA_NATIVE=ON \
-G Ninja /work/mxnet
ninja
}

build_ubuntu_cpu_mkl() {
set -ex
cd /work/build
Expand Down
4 changes: 1 addition & 3 deletions src/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ static inline void printStackTrace(FILE *out = stderr,
#endif
}

#define SKIP_SIGNAL_HANDLER_REGISTRATION 1

#define SIGNAL_HANDLER(SIGNAL, HANDLER_NAME, IS_FATAL) \
std::shared_ptr<void(int)> HANDLER_NAME( \
signal(SIGNAL, [](int signum) { \
Expand Down Expand Up @@ -378,7 +376,7 @@ std::shared_ptr<void(int)> HANDLER_NAME( \
[](auto f) { signal(SIGNAL, f); });

// TODO(cspchen): avoid jvm exit with code 139. By now, we just skip it
#if SKIP_SIGNAL_HANDLER_REGISTRATION
#if !SKIP_SIGNAL_HANDLER_REGISTRATION
SIGNAL_HANDLER(SIGSEGV, SIGSEGVHandler, true);
SIGNAL_HANDLER(SIGFPE, SIGFPEHandler, false);
SIGNAL_HANDLER(SIGBUS, SIGBUSHandler, false);
Expand Down

0 comments on commit 4915e06

Please sign in to comment.