aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorValentin Clement (バレンタイン クレメン) <clementval@gmail.com>2025-08-28 14:44:46 -0700
committerGitHub <noreply@github.com>2025-08-28 21:44:46 +0000
commit1277a1111d420b244a0e595ad9b74827841b723a (patch)
tree46fdb2d643b3120f3e8c8e028056efecf52df85f /flang/lib/Frontend/CompilerInvocation.cpp
parent11e796dee2c59d0e2382578eb79404218b74772e (diff)
downloadllvm-1277a1111d420b244a0e595ad9b74827841b723a.zip
llvm-1277a1111d420b244a0e595ad9b74827841b723a.tar.gz
llvm-1277a1111d420b244a0e595ad9b74827841b723a.tar.bz2
[flang][cuda] Define _CUDA only when preprocessor is enabled (#155913)
From the CUDA Fortran programming guide: > If CUDA Fortran is enabled in compilation, either by specifying -⁠cuda on the command line, and pre-processing is enabled by either the -⁠Mpreprocess compiler option or by using capital letters in the filename extension (.CUF, .F90, etc.) then the _CUDA macro is defined. Move the definition of `_CUDA` to the compiler invocation.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 4719a24..fb3a132 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1754,6 +1754,11 @@ void CompilerInvocation::setDefaultPredefinitions() {
fortranOptions.predefinitions);
}
+ if (frontendOptions.features.IsEnabled(
+ Fortran::common::LanguageFeature::CUDA)) {
+ fortranOptions.predefinitions.emplace_back("_CUDA", "1");
+ }
+
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
if (targetTriple.isOSLinux()) {
fortranOptions.predefinitions.emplace_back("__linux__", "1");