Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow compilation with NVIDIA nvc++ #16975

Open
cgleggett opened this issue Nov 18, 2024 · 3 comments
Open

Allow compilation with NVIDIA nvc++ #16975

cgleggett opened this issue Nov 18, 2024 · 3 comments
Assignees

Comments

@cgleggett
Copy link

cgleggett commented Nov 18, 2024

Explain what you would like to see improved and how.

The main obstacle to compiling root with nvc++ is the extraction of the system headers by cling. With gcc, this is done via g++ -xc++ -E -v /dev/null and then a sed script to extract the paths in interpreter/cling/lib/Interpreter/CMakeLists.cxx. This doesn't work with nvc++, but a new flag in hpc sdk version 24.11 was added explicitly for this: -drygccinc. I can offer a patch for this file, but there are a LOT of different code paths through it, and I'm not certain of what they all do, so I probably haven't covered all use cases:

diff --git a/interpreter/cling/lib/Interpreter/CMakeLists.txt b/interpreter/cling/lib/Interpreter/CMakeLists.txt
index e397da97f6..7639cbc58e 100644
--- a/interpreter/cling/lib/Interpreter/CMakeLists.txt
+++ b/interpreter/cling/lib/Interpreter/CMakeLists.txt
@@ -242,24 +242,34 @@ if (UNIX)
   endif()
 
   if(NOT CLING_CXX_HEADERS)
-    if (CLING_CXX_PATH)
-      execute_process(COMMAND ${CLING_CXX_PATH} ${CLING_CXX_PATH_ARGS} -xc++ -E -v /dev/null
+    
+    if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "NVHPC")
+        execute_process(COMMAND ${CLING_CXX_RLTV} -drygccinc
                       OUTPUT_QUIET ERROR_VARIABLE CLING_CXX_HEADERS)
-      set(CLING_CXX_PATH "${CLING_CXX_PATH} ${CLING_CXX_PATH_ARGS}")
+        execute_process(
+          COMMAND echo ${CLING_CXX_HEADERS}
+          COMMAND sed s/:/\\\n/g
+        OUTPUT_VARIABLE CLING_CXX_HEADERS)
     else()
-      # convert CMAKE_CXX_FLAGS to a list for execute_process
-      string(REPLACE "-fdiagnostics-color=always" "" cling_tmp_arg_list ${CMAKE_CXX_FLAGS})
-      string(REPLACE "-fcolor-diagnosics" "" cling_tmp_arg_list ${cling_tmp_arg_list})
-      string(REPLACE " " ";" cling_tmp_arg_list ${cling_tmp_arg_list})
-      execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${cling_tmp_arg_list} -xc++ -E -v /dev/null
-                      OUTPUT_QUIET ERROR_VARIABLE CLING_CXX_HEADERS)
+       if (CLING_CXX_PATH)
+         execute_process(COMMAND ${CLING_CXX_PATH} ${CLING_CXX_PATH_ARGS} -xc++ -E -v /dev/null
+                         OUTPUT_QUIET ERROR_VARIABLE CLING_CXX_HEADERS)
+         set(CLING_CXX_PATH "${CLING_CXX_PATH} ${CLING_CXX_PATH_ARGS}")
+       else()
+         # convert CMAKE_CXX_FLAGS to a list for execute_process
+         string(REPLACE "-fdiagnostics-color=always" "" cling_tmp_arg_list ${CMAKE_CXX_FLAGS})
+         string(REPLACE "-fcolor-diagnosics" "" cling_tmp_arg_list ${cling_tmp_arg_list})
+         string(REPLACE " " ";" cling_tmp_arg_list ${cling_tmp_arg_list})
+         execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${cling_tmp_arg_list} -xc++ -E -v /dev/null
+                         OUTPUT_QUIET ERROR_VARIABLE CLING_CXX_HEADERS)
+       endif()
+
+       execute_process(
+         COMMAND echo ${CLING_CXX_HEADERS}
+         COMMAND sed -n -e /^.include/,\$\{ -e /^\\\ \\\/.*++/p -e \}
+         OUTPUT_VARIABLE CLING_CXX_HEADERS)
     endif()
 
-    execute_process(
-      COMMAND echo ${CLING_CXX_HEADERS}
-      COMMAND sed -n -e /^.include/,\$\{ -e /^\\\ \\\/.*++/p -e \}
-      OUTPUT_VARIABLE CLING_CXX_HEADERS)
-
     stripNewLine("${CLING_CXX_HEADERS}" CLING_CXX_HEADERS)
   endif()

Also, we can add NVHPC to the list of supported compilers in cmake/modules/CheckCompiler.cmake:

diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake
index 4efd0b5946..64ed9761ff 100644
--- a/cmake/modules/CheckCompiler.cmake
+++ b/cmake/modules/CheckCompiler.cmake
@@ -8,7 +8,7 @@
 #  CheckCompiler.cmake
 #---------------------------------------------------------------------------------------------------
 
-if(NOT CMAKE_CXX_COMPILER_ID MATCHES "(Apple|)Clang|GNU|Intel|MSVC")
+if(NOT CMAKE_CXX_COMPILER_ID MATCHES "(Apple|)Clang|GNU|Intel|MSVC|NVHPC")
   message(WARNING "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}.")
 endif()

ROOT version

tried with 6.33.01

Installation method

build from source

Operating system

linux alma9

Additional context

requires at least v24.11 of NVIDIA nvc++

@dpiparo
Copy link
Member

dpiparo commented Nov 19, 2024

Hi @cgleggett , thanks. At the moment this is not a platform we have the effort to support. Are you interested contributing, perhaps with PRs?

@dpiparo dpiparo self-assigned this Nov 19, 2024
@dpiparo
Copy link
Member

dpiparo commented Nov 20, 2024

Also, is this #11511 still an issue for you?

@cgleggett
Copy link
Author

Hi Danilo - I'm happy to submit a PR!

not sure about 11511 - I will have to revisit the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants