Fix embedding PCH

Change-Id: Ibaf043c9e331f15965185cd4195da98d9441cba3


[ROCm/hip commit: b7f66b634a]
This commit is contained in:
Yaxun (Sam) Liu
2020-11-17 16:38:15 -05:00
committed by agodavar
parent c8278b9e47
commit 91950fbf62
2 changed files with 15 additions and 6 deletions
+6 -4
View File
@@ -49,12 +49,14 @@ __hip_pch_size:
.long __hip_pch_size - __hip_pch
EOF
$LLVM_DIR/bin/clang -O3 -std=c++17 -nogpulib -isystem $HIP_INC_DIR -isystem $HIP_BUILD_INC_DIR -isystem $HSA_DIR/include --cuda-device-only -x hip $tmp/hip_pch.h -E >$tmp/pch.cui
set -x
cat $tmp/hip_macros.h >> $tmp/pch.cui
$LLVM_DIR/bin/clang -O3 --rocm-path=$HIP_INC_DIR/.. -std=c++17 -nogpulib -isystem $HIP_INC_DIR -isystem $HIP_BUILD_INC_DIR -isystem $HSA_DIR/include --cuda-device-only -x hip $tmp/hip_pch.h -E >$tmp/pch.cui &&
$LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip.pch -x hip-cpp-output - <$tmp/pch.cui
cat $tmp/hip_macros.h >> $tmp/pch.cui &&
$LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj
$LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip.pch -x hip-cpp-output - <$tmp/pch.cui &&
$LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj &&
rm -rf $tmp
+9 -2
View File
@@ -36,6 +36,10 @@ endif()
set(USE_PROF_API "1")
# Need to add /opt/rocm/llvm to package search path since ROCclr will
# find package amd_comgr and amd_comgr will find package llvm/clang.
# Without this, the system llvm/clang at /usr/local may be found.
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/opt/rocm/llvm")
find_package(ROCclr REQUIRED CONFIG)
#############################
@@ -69,7 +73,7 @@ endif()
#Custom install path can be provided at compile time as cmake parameter(-DCMAKE_PREFIX_PATH="")
#/opt/rocm:default:For amd_comgr,hsa-runtime64
#/opt/rocm/llvm/:default:For llvm/clang pulled in as dependency from hsa/comgr
list( APPEND CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/opt/rocm" "/opt/rocm/llvm")
list( APPEND CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/opt/rocm")
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
set(CMAKE_MODULE_PATH${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -139,7 +143,10 @@ endif()
# Short-Term solution for pre-compiled headers for online compilation
# Enable pre compiled header
if(__HIP_ENABLE_PCH)
execute_process(COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/../bin/hip_embed_pch.sh ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/include ${LLVM_DIR} ${HSA_PATH}")
execute_process(COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/../bin/hip_embed_pch.sh ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/include ${LLVM_DIR} ${HSA_PATH}" COMMAND_ECHO STDERR RESULT_VARIABLE EMBED_PCH_RC)
if (EMBED_PCH_RC AND NOT EMBED_PCH_RC EQUAL 0)
message(FATAL_ERROR "Failed to embed PCH")
endif()
add_definitions(-D__HIP_ENABLE_PCH)
endif()