llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Artem Belevich (Artem-B) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/176301.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4-4) - (modified) clang/test/Driver/cuda-arch-list.cu (+14) ``````````diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 4ca98600d6e93..18933cb8ad7c2 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1065,10 +1065,6 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, A->render(Args, CmdArgs); } - Args.addAllArgs(CmdArgs, - {options::OPT_D, options::OPT_U, options::OPT_I_Group, - options::OPT_F, options::OPT_embed_dir_EQ}); - if (C.isOffloadingHostKind(Action::OFK_Cuda) || JA.isDeviceOffloading(Action::OFK_Cuda)) { // Collect all enabled NVPTX architectures. @@ -1091,6 +1087,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, } } + Args.addAllArgs(CmdArgs, + {options::OPT_D, options::OPT_U, options::OPT_I_Group, + options::OPT_F, options::OPT_embed_dir_EQ}); + // Add -Wp, and -Xpreprocessor if using the preprocessor. // FIXME: There is a very unfortunate problem here, some troubled diff --git a/clang/test/Driver/cuda-arch-list.cu b/clang/test/Driver/cuda-arch-list.cu index 84efeb1499708..d4825f202d733 100644 --- a/clang/test/Driver/cuda-arch-list.cu +++ b/clang/test/Driver/cuda-arch-list.cu @@ -23,6 +23,11 @@ // RUN: --offload-arch=sm_60 --offload-arch=sm_70 --no-offload-arch=sm_60 %s 2>&1 \ // RUN: | FileCheck -check-prefixes=DEVICE70-ONLY,HOST70-ONLY %s +// Verify that user-specified -D__CUDA_ARCH_LIST__ overrides the driver-generated one +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nocudainc -nocudalib \ +// RUN: --offload-arch=sm_60 -D__CUDA_ARCH_LIST__=999 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=DEVICE-OVERRIDE,HOST-OVERRIDE %s + // DEVICE60: "-cc1" "-triple" "nvptx64-nvidia-cuda" // DEVICE60-SAME: "-target-cpu" "sm_60" // DEVICE60-SAME: "-D__CUDA_ARCH_LIST__=600" @@ -54,3 +59,12 @@ // HOST70-ONLY: "-cc1" "-triple" "x86_64-unknown-linux-gnu" // HOST70-ONLY-SAME: "-D__CUDA_ARCH_LIST__=700" + +// DEVICE-OVERRIDE: "-cc1" "-triple" "nvptx64-nvidia-cuda" +// DEVICE-OVERRIDE-SAME: "-target-cpu" "sm_60" +// DEVICE-OVERRIDE-SAME: "-D__CUDA_ARCH_LIST__=600" +// DEVICE-OVERRIDE-SAME: "-D" "__CUDA_ARCH_LIST__=999" + +// HOST-OVERRIDE: "-cc1" "-triple" "x86_64-unknown-linux-gnu" +// HOST-OVERRIDE-SAME: "-D__CUDA_ARCH_LIST__=600" +// HOST-OVERRIDE-SAME: "-D" "__CUDA_ARCH_LIST__=999" `````````` </details> https://github.com/llvm/llvm-project/pull/176301 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
