Skip to content

Commit

Permalink
[LIBCLC] Make sure flags are unset when building libclc for AMD (#4991)
Browse files Browse the repository at this point in the history
Without this patch the flags always contain `-mcpu=tahiti`. The problem occurs when llvm compiles the spirv module it chooses `llvm::AMDGPUSubtarget::SOUTHERN_ISLANDS` as the subtarget. The instruction encoding differers, and when targeting `llvm::AMDGPUSubtarget::GFX9` the final binary is invalid. This in turns causes the `HSA_STATUS_ERROR_ILLEGAL_INSTRUCTION`.
  • Loading branch information
jchlanda authored Nov 22, 2021
1 parent c4fa95f commit 9eb5c99
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
endforeach()
endforeach()

# Please NOTE that variables in the foreach are not local and thus need
# to be reset every iteration.
foreach( d ${${t}_devices} )
# Some targets don't have a specific GPU to target
if( ${d} STREQUAL "none" OR ${ARCH} STREQUAL "spirv" OR ${ARCH} STREQUAL "spirv64" )
Expand All @@ -330,6 +332,8 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
# Disables NVVM reflection to defer to after linking
set( flags "SHELL:-Xclang -target-feature" "SHELL:-Xclang +ptx72"
"SHELL:-march=sm_86" "SHELL:-mllvm --nvvm-reflect-enable=false")
else()
set ( flags )
endif()
set( arch_suffix "${t}" )
else()
Expand Down

0 comments on commit 9eb5c99

Please sign in to comment.