Skip to content

Commit

Permalink
[BUILD] Support clang++ compiler (#1316)
Browse files Browse the repository at this point in the history
* [BUILD] Support clang++ compiler

Signed-off-by: nileshnegi <[email protected]>

* [BUILD] Enable check_symbol_exists for BFD and clang++

Signed-off-by: nileshnegi <[email protected]>

* [BUILD] Define default C compiler

Signed-off-by: nileshnegi <[email protected]>

---------

Signed-off-by: nileshnegi <[email protected]>
  • Loading branch information
nileshnegi authored Sep 5, 2024
1 parent 391c7ea commit d3012d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ if("${CMAKE_CXX_COMPILER}" MATCHES ".*amdclang\\+\\+")
set(COMPILER_EXE_NAME amdclang++)
set(COMPILER_GREP_STRING "AMD clang version")
set(COMPILER_AWK_CMD "awk -F\" \" '{ printf $4}'")
elseif("${CMAKE_CXX_COMPILER}" MATCHES ".*clang\\+\\+")
message(STATUS "Compiling with clang++")
set(COMPILER_EXE_NAME clang++)
set(COMPILER_GREP_STRING "AMD clang version")
set(COMPILER_AWK_CMD "awk -F\" \" '{ printf $4}'")
elseif("${CMAKE_CXX_COMPILER}" MATCHES ".*hipcc$")
message(STATUS "Compiling with hipcc")
set(COMPILER_EXE_NAME hipcc)
Expand Down Expand Up @@ -238,6 +243,9 @@ if(BUILD_BFD)
if (HAVE_BFD)
message(STATUS "-- Found BFD support")

### Required for checking HIP device symbols when building with amdclang++
set(CMAKE_REQUIRED_LIBRARIES hip::device)

# Check for specific BFD feature support
CHECK_SYMBOL_EXISTS(bfd_get_section_flags "bfd.h" HAVE_DECL_BFD_GET_SECTION_FLAGS)
CHECK_SYMBOL_EXISTS(bfd_get_section_vma "bfd.h" HAVE_DECL_BFD_GET_SECTION_VMA)
Expand All @@ -253,6 +261,8 @@ if(BUILD_BFD)
}"
HAVE_TWO_ARG_BFD_SECTION_SIZE)

unset(CMAKE_REQUIRED_LIBRARIES)

# Check for iberty support
find_library(HAVE_IBERTY iberty PATHS /usr/lib64 /usr/lib/ PATH_SUFFIXES x86_64-linux-gnu)
if(HAVE_IBERTY)
Expand Down
11 changes: 11 additions & 0 deletions toolchain-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ if (NOT DEFINED ENV{CXXFLAGS})
set(CMAKE_CXX_FLAGS_DEBUG "-g -O1")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()

if (NOT DEFINED ENV{CC})
set(CMAKE_C_COMPILER "${rocm_bin}/amdclang" CACHE PATH "Path to the C compiler")
else()
set(CMAKE_C_COMPILER "$ENV{CC}" CACHE PATH "Path to the C compiler")
endif()

if (NOT DEFINED ENV{CFLAGS})
set(CMAKE_C_FLAGS_DEBUG "-g -O1")
set(CMAKE_C_FLAGS_RELEASE "-O3")
endif()

0 comments on commit d3012d3

Please sign in to comment.