Skip to content

Commit

Permalink
[jni][fix] Multi-device SPIR-V exploration fixed
Browse files Browse the repository at this point in the history
This PR solves the issue of `stack smashing detected` during a jni return call for the LevelZero device exploration.

As stated in the Ubuntu documentation:

    > NOTE: In Ubuntu 14.10 and later versions, -fstack-protector-strong is
      enabled by default for C, C++, ObjC, ObjC++, if none of -fno-stack-protector,
      -nostdlib, nor -ffreestanding are found.

As suggested here:
https://stackoverflow.com/questions/10712972/what-is-the-use-of-fno-stack-protector

    > In the standard/stock GCC, stack protector is off by default.
    However, some Linux distributions have patched GCC to turn it on by default.

We need this flag to turn off for the integration with the Level Zero drivers.
  • Loading branch information
jjfumero committed Sep 22, 2023
1 parent 721b8ae commit fe20b18
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion levelZeroLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ find_package(JNI REQUIRED)

# set the C++14 standard
set(CMAKE_CXX_STANDARD 14)
set(GCC_INTEL_LEVEL0 "-std=c++14 -O2 -fpermissive -rdynamic -fPIC -lstdc++")
set(GCC_INTEL_LEVEL0 "-std=c++14 -O2 -fpermissive -rdynamic -fPIC -lstdc++ -fno-stack-protector")


# This should point to: "PATH-TO/level-zero/build/lib/libze_loader.so"
set(ZE_LOADER $ENV{ZE_SHARED_LOADER})
Expand Down

0 comments on commit fe20b18

Please sign in to comment.