1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
From: Cordell Bloor <cgmb@slerp.xyz>
Date: Fri, 22 Mar 2024 16:41:37 -0600
Subject: fix clangrt check for c compilers
This patch ensures that users consistently get the message, "clangrt
compiler options not supported" when building code using the HIP host
interface with gcc or g++.
Otherwise, hip-config would warn when building for C++:
/usr/bin/C++: CLANGRT compiler options not supported.
and warn when building for C:
clangrt builtins lib not found:
despite these situations being identical.
Forwarded: no
---
hipamd/hip-config-amd.cmake | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/hipamd/hip-config-amd.cmake b/hipamd/hip-config-amd.cmake
index 6451f02..377ad1d 100755
--- a/hipamd/hip-config-amd.cmake
+++ b/hipamd/hip-config-amd.cmake
@@ -137,25 +137,25 @@ if(HIP_CLANG_NUM_PARALLEL_JOBS GREATER 1)
endif()
endif()
-# Use HIP_CXX option -print-libgcc-file-name --rtlib=compiler-rt
-# To fetch the compiler rt library file name.
-execute_process(
- COMMAND ${HIP_CXX_COMPILER} -print-libgcc-file-name --rtlib=compiler-rt
- OUTPUT_VARIABLE CLANGRT_BUILTINS
- ERROR_VARIABLE CLANGRT_Error
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE CLANGRT_BUILTINS_FETCH_EXIT_CODE)
+if(DEFINED CMAKE_CXX_COMPILER AND NOT DEFINED CLANGRT_BUILTINS_FETCH_EXIT_CODE)
+ message(STATUS "Looking for compiler-rt")
+ # Use HIP_CXX option -print-libgcc-file-name --rtlib=compiler-rt
+ # To fetch the compiler rt library file name.
+ execute_process(
+ COMMAND ${HIP_CXX_COMPILER} -print-libgcc-file-name --rtlib=compiler-rt
+ OUTPUT_VARIABLE CLANGRT_BUILTINS
+ ERROR_VARIABLE CLANGRT_Error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE CLANGRT_BUILTINS_FETCH_EXIT_CODE)
-if( CLANGRT_Error )
- message( STATUS "${HIP_CXX_COMPILER}: CLANGRT compiler options not supported.")
-else()
- # Add support for __fp16 and _Float16, explicitly link with compiler-rt
- if( "${CLANGRT_BUILTINS_FETCH_EXIT_CODE}" STREQUAL "0" )
+ if(CLANGRT_Error OR NOT "${CLANGRT_BUILTINS_FETCH_EXIT_CODE}" STREQUAL "0")
+ message(STATUS "Looking for compiler-rt - not found")
+ else()
+ message(STATUS "Looking for compiler-rt - found")
+ # Add support for __fp16 and _Float16, explicitly link with compiler-rt
# CLANG_RT Builtins found Successfully Set interface link libraries property
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${CLANGRT_BUILTINS}")
set_property(TARGET hip::device APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${CLANGRT_BUILTINS}")
- else()
- message(STATUS "clangrt builtins lib not found: ${CLANGRT_BUILTINS_FETCH_EXIT_CODE}")
- endif() # CLANGRT_BUILTINS_FETCH_EXIT_CODE Check
-endif() # CLANGRT_Error Check
+ endif() # CLANGRT_Error Check
+endif()
|