From 4bb6e01ea3d9b6b3235ce3a6221e44d734f4d130 Mon Sep 17 00:00:00 2001 From: agodavar Date: Thu, 22 Oct 2020 09:33:30 -0400 Subject: [PATCH] SWDEV-249870: Generate Pre-Compiled Headers from includes in source repo for Online Compilation Change-Id: I663f510603e983927f80f7944df4d039ba7bc0b0 [ROCm/clr commit: 9ef681a6188816182a72382ef49ff4776c1268ac] --- projects/clr/hipamd/CMakeLists.txt | 30 +++++++++++------------ projects/clr/hipamd/bin/hip_embed_pch.sh | 7 ++++-- projects/clr/hipamd/rocclr/CMakeLists.txt | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/projects/clr/hipamd/CMakeLists.txt b/projects/clr/hipamd/CMakeLists.txt index 8eb2da5314..117f4d0a9a 100755 --- a/projects/clr/hipamd/CMakeLists.txt +++ b/projects/clr/hipamd/CMakeLists.txt @@ -314,6 +314,21 @@ if (BUILD_HIPIFY_CLANG) add_subdirectory(hipify-clang) endif() +# Generate hip_version.h +set(_versionInfoHeader +"// Auto-generated by cmake\n +#ifndef HIP_VERSION_H +#define HIP_VERSION_H\n +#define HIP_VERSION_MAJOR ${HIP_VERSION_MAJOR} +#define HIP_VERSION_MINOR ${HIP_VERSION_MINOR} +#define HIP_VERSION_PATCH ${HIP_VERSION_GITDATE} +#define HIP_VERSION (HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR)\n +#define __HIP_HAS_GET_PCH ${_pchStatus}\n +#endif\n +") +file(WRITE "${PROJECT_BINARY_DIR}/include/hip/hip_version.h" ${_versionInfoHeader}) +include_directories(${PROJECT_BINARY_DIR}/include) + if(HIP_RUNTIME STREQUAL "rocclr") include_directories(${PROJECT_SOURCE_DIR}/include) add_subdirectory(rocclr) @@ -463,21 +478,6 @@ if(NOT DEFINED HIP_VERSION_GITDATE) set(HIP_VERSION_GITDATE 0) endif() -# Generate hip_version.h -set(_versionInfoHeader -"// Auto-generated by cmake\n -#ifndef HIP_VERSION_H -#define HIP_VERSION_H\n -#define HIP_VERSION_MAJOR ${HIP_VERSION_MAJOR} -#define HIP_VERSION_MINOR ${HIP_VERSION_MINOR} -#define HIP_VERSION_PATCH ${HIP_VERSION_GITDATE} -#define HIP_VERSION (HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR)\n -#define __HIP_HAS_GET_PCH ${_pchStatus}\n -#endif\n -") -file(WRITE "${PROJECT_BINARY_DIR}/include/hip/hip_version.h" ${_versionInfoHeader}) -include_directories(${PROJECT_BINARY_DIR}/include) - # Build doxygen documentation find_program(DOXYGEN_EXE doxygen) if(DOXYGEN_EXE) diff --git a/projects/clr/hipamd/bin/hip_embed_pch.sh b/projects/clr/hipamd/bin/hip_embed_pch.sh index 0f2cbabd84..1843c8d5c4 100755 --- a/projects/clr/hipamd/bin/hip_embed_pch.sh +++ b/projects/clr/hipamd/bin/hip_embed_pch.sh @@ -1,7 +1,10 @@ #!/bin/bash #set -x -LLVM_DIR="$1/../../../" +HIP_BUILD_INC_DIR=$1 +HIP_INC_DIR=$2 +LLVM_DIR="$3/../../../" +HSA_DIR="$4" tmp=/tmp/hip_pch.$$ mkdir -p $tmp @@ -46,7 +49,7 @@ __hip_pch_size: .long __hip_pch_size - __hip_pch EOF -$LLVM_DIR/bin/clang -O3 -c -std=c++17 -isystem $LLVM_DIR/lib/clang/11.0.0/include/.. -isystem /opt/rocm/include -nogpulib --cuda-device-only -x hip $tmp/hip_pch.h -E >$tmp/pch.cui +$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 cat $tmp/hip_macros.h >> $tmp/pch.cui diff --git a/projects/clr/hipamd/rocclr/CMakeLists.txt b/projects/clr/hipamd/rocclr/CMakeLists.txt index 77f0b1a020..c447ac8b95 100755 --- a/projects/clr/hipamd/rocclr/CMakeLists.txt +++ b/projects/clr/hipamd/rocclr/CMakeLists.txt @@ -155,7 +155,7 @@ 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 ${LLVM_DIR}") + 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}") add_definitions(-D__HIP_ENABLE_PCH) endif()