https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/100607
>From 0cc36f8aa42c1b673b1d239bf1518990582c5479 Mon Sep 17 00:00:00 2001 From: Joseph Huber <hube...@outlook.com> Date: Thu, 25 Jul 2024 12:31:09 -0500 Subject: [PATCH] [NVPTX] Correctly forward the PTX feature to the nvlink wrapper Summary: This is necessary for LTO when the user specifies it or has a CUDA version that supports a sufficiently high version. Previously it would default. --- clang/lib/Driver/ToolChains/Cuda.cpp | 7 +++++++ clang/test/Driver/cuda-cross-compiling.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index ffe5f4a6f4a25..e98e574d6cc2b 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -625,6 +625,13 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA, addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], C.getDriver().getLTOMode() == LTOK_Thin); + // Forward the PTX features if the nvlink-wrapper needs it. + std::vector<StringRef> Features; + getNVPTXTargetFeatures(C.getDriver(), getToolChain().getTriple(), Args, + Features); + for (StringRef Feature : Features) + CmdArgs.append({"--feature", Args.MakeArgString(Feature)}); + addGPULibraries(getToolChain(), Args, CmdArgs); // Add paths for the default clang library path. diff --git a/clang/test/Driver/cuda-cross-compiling.c b/clang/test/Driver/cuda-cross-compiling.c index 42d56cbfcc321..c2e538c25329e 100644 --- a/clang/test/Driver/cuda-cross-compiling.c +++ b/clang/test/Driver/cuda-cross-compiling.c @@ -90,3 +90,11 @@ // RUN: | FileCheck -check-prefix=GENERIC %s // GENERIC-NOT: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-target-cpu" + +// +// Test forwarding the necessary +ptx feature. +// +// RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \ +// RUN: | FileCheck -check-prefix=FEATURE %s + +// FEATURE: clang-nvlink-wrapper{{.*}}"--feature" "+ptx63" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits