Closed ax3l closed 2 years ago
Does this repo change the default of -std=c++<...> for clang++?
This repo doesn't change the C++ version. That is set by the llvm compiler. Using -x hip
sets the version to C++11 in llvm because that is the minimum version needed to use hip header files, but this can be overwritten with passing a different version like -std+c++14
.
At the time, I believe hip was created, llvm used C++98 by default, which is why we bumped it to c++11. When llvm switched to C++14 by default, it seems they didn't update it for all languages.
and only with this clang++ in hip 4.1.0 I see no flags getting added to the command line.
That sounds like a bug in CMake. The cxx_std_14
should add at least the -std=c++14
flags(or later).
Hi @pfultz2,
thanks for the background.
At the time, I believe hip was created, llvm used C++98 by default, which is why we bumped it to c++11. When llvm switched to C++14 by default, it seems they didn't update it for all languages.
Makes sense, I think we should now update this to C++14 just to stay in lockstep with the C++ frontend & avoid confusion.
That sounds like a bug in CMake. The cxx_std_14 should add at least the -std=c++14 flags(or later).
Depends, CMake does the following logic for all languages it supports: If the default compiler flags are fulfilling the requested compile feature, it will not add (verbose) extra flags. Since your CMake logic exposes itself as CXX
targets (HIP
is not yet a <LANG>
in CMake), it will query clang++
(-x c++
) and see it supports C++14. CMake does not know that your configs inject an -x hip
later on in a specific target's interface compile flags and that this is thus a different language.
One can of course build work-arounds in CMake, but the least confusing for all downstream would just be to keep the -std=...
defaults for -x hip
and -x c++
the same, imho.
Maybe @yxsamliu can provide feedback about upgrading llvm.
I think it is reasonable to take c++14 as default language standard for HIP. I will try making that change.
I think it is reasonable to take c++14 as default language standard for HIP. I will try making that change.
I've already done it for hipify-clang. So, the minimum GNU C/C++ supported version now is 6.1 (was 5.4).
Thanks! Just to clarify: With this issue, I am not suggesting to drop C++11 support. (That said, our projects are C++14 and newer anyway.)
I just would like to keep the -std=c++XX
default for the hip and c++ compiler frontend in sync.
understood
Xref: Upstream PR in https://reviews.llvm.org/D103221
cc: @kmaehashi @takagi
This is now fixed, thanks a lot!
Does this repo change the default of
-std=c++<...>
forclang++
? I am trying to transition to theclang++
+hip::device
target logic (#2275) with ECP AMReX & ECP WarpX.The compiler identifies as Clang 12 but it builds by default in C++11.
My targets set
and only with this
clang++
in hip 4.1.0 I see no flags getting added to the command line.Note that Clang 6+ already default to C++14: https://gist.github.com/ax3l/53db9fa8a4f4c21ecc5c4100c0d93c94
But
-xhip
does not it seems:Vs.:
My Workaround
before all CMake builds, because the target compile feature
cxx_std_14
is currently ignored for-xhip
objects.Alternative work-around:
CXX_STANDARD
always adds-std=c++XX
, even if the compiler default fulfills itThe reason for that is that
cxx_std_14
asks for feature support (at least a minimal version) whileCXX_STANDARD
is an exact request for a version.