From 4c1d556d909e860392976cf411d312b1c0211988 Mon Sep 17 00:00:00 2001 From: Luca Di Grazia Date: Sun, 4 Sep 2022 18:25:35 +0200 Subject: [PATCH] Recognize CUDA and OpenCL file types (.cu, .cl, .inl, .cuh) and compile them with a C++ compiler. This will allow CUDA and OpenCL files to be compiled with clang, which supports both natively. Change taken from https://github.com/bazelbuild/bazel/issues/6578#issuecomment-463944092 RELNOTES: Treat .cu and .cl files as C++ source. CUDA or OpenCL are not natively supported and will require custom flags to compile with e.g. clang. PiperOrigin-RevId: 293200984 --- .../devtools/build/lib/rules/cpp/CppFileTypes.java | 9 +++++++-- .../devtools/coverageoutputgenerator/Constants.java | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java index 1bbd03bf617..701991fc076 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java @@ -24,7 +24,11 @@ * C++-related file type definitions. */ public final class CppFileTypes { - public static final FileType CPP_SOURCE = FileType.of(".cc", ".cpp", ".cxx", ".c++", ".C"); + // .cu and .cl are CUDA and OpenCL source extensions, respectively. They are expected to only be + // supported with clang. Bazel is not officially supporting these targets, and the extensions are + // listed only as long as they work with the existing C++ actions. + public static final FileType CPP_SOURCE = + FileType.of(".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl"); public static final FileType C_SOURCE = FileType.of(".c"); public static final FileType OBJC_SOURCE = FileType.of(".m"); public static final FileType OBJCPP_SOURCE = FileType.of(".mm"); @@ -45,7 +49,8 @@ public final class CppFileTypes { public static final FileType CPP_HEADER = FileType.of( - ".h", ".hh", ".hpp", ".ipp", ".hxx", ".h++", ".inc", ".inl", ".tlh", ".tli", ".H"); + ".h", ".hh", ".hpp", ".ipp", ".hxx", ".h++", ".inc", ".inl", ".tlh", ".tli", ".H", ".inl", + ".cuh"); public static final FileType PCH = FileType.of(".pch"); public static final FileTypeSet OBJC_HEADER = FileTypeSet.of(CPP_HEADER, PCH); diff --git a/dataset/GitHub_Java/bazelbuild.bazel/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/Constants.java b/dataset/GitHub_Java/bazelbuild.bazel/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/Constants.java index 2961382d1c0..50fb8c6dc00 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/Constants.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/Constants.java @@ -53,6 +53,6 @@ class Constants { // Please keep in sync with the extensions in CppFileTypes. static final ImmutableList CC_EXTENSIONS = ImmutableList.of( - ".cc", ".cpp", ".cxx", ".c++", ".C", ".c", ".h", ".hh", ".hpp", ".ipp", ".hxx", ".inc", - ".inl", ".tlh", ".tli", ".H"); + ".cc", ".cpp", ".cxx", ".c++", ".C", ".c", ".cu", ".cl", ".h", ".hh", ".hpp", ".ipp", + ".hxx", ".inc", ".inl", ".tlh", ".tli", ".H", ".cuh"); }