Compile cruntime with fpic (#188)

* Detect llvm-project commit change in utils/clone-mlir.sh and rebuild llvm-project
for zLinux Jenkins build bot

* Compile libcruntime.a object with -fPIC to avoid segfault when embedded into model.so

* Enable unit tests on zLinux

Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
This commit is contained in:
gongsu832 2020-07-01 03:06:55 -04:00 committed by GitHub
parent e902506ee5
commit cf96d635cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -69,6 +69,7 @@ LLVM_PROJ_SRC=${LLVM_PROJECT_ROOT} \
LLVM_PROJ_BUILD=${LLVM_PROJECT_ROOT}/build \
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} .. \
make -j$(nproc) onnx-mlir
make -j$(nproc)
make -j$(nproc) check-onnx-lit
RUNTIME_DIR=$(pwd)/lib make -j$(nproc) check-onnx-backend
RUNTIME_DIR=$(pwd)/lib PATH=$(pwd)/bin:$PATH make -j$(nproc) test

View File

@ -1,9 +1,13 @@
# Create shared libcruntime.so since model.so linkage for backend tests
# will fail on x86 Linux if cruntime is statically linked.
# Create static libcruntime.a to be embedded in model.so to make model.so self contained.
# However, by default object code for static library is not compiled with -fPIC. Embedding
# such static library in a shared library can cause runtime failure on some architectures,
# such as z. So we override the default and explicitly compile with -fPIC.
add_library(cruntime STATIC
RtMemRef.cpp
RtMemRef.h
DataType.h)
set_target_properties(cruntime PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
add_library(RtMemRefUtils
RtMemRef.h
@ -35,6 +39,7 @@ target_include_directories(PyRuntime PRIVATE
${ONNX_MLIR_BIN_ROOT}
${ONNX_MLIR_SRC_ROOT})
# See comments above about libcruntime.a
add_library(EmbeddedDataLoader STATIC
GetEmbeddedConstPool.h
GetEmbeddedConstPool.cpp)