[clang] [HIP] Claim `--offloading-compress` for `-M` (PR #133456)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 28 08:34:53 PDT 2025
https://github.com/yxsamliu created https://github.com/llvm/llvm-project/pull/133456
Cmake automatically generates dependency files with all compilation options provided by users. When users use `--offload-compress` for HIP compilation, it causes warnings when cmake generates dependency files. Claim this option to suppress warnings.
>From 674c4efc77503644e60b42c48ddc3d6f8e5b0df2 Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" <yaxun.liu at amd.com>
Date: Fri, 28 Mar 2025 11:30:39 -0400
Subject: [PATCH] [HIP] Claim --offloading-compress for -M
Cmake automatically generate dependency files with all compilation
options provided by users. When users use for
HIP compilation, it causes warnings when cmake generates dependency
files. Claim this option to supress warnings.
---
clang/lib/Driver/ToolChains/Clang.cpp | 6 ++++++
clang/test/Driver/hip-options.hip | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 40ecc0aee48b3..47c8bd31f0881 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1026,6 +1026,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-dependency-file");
CmdArgs.push_back(DepFile);
}
+ // Cmake generates dependency files using all compilation options specified
+ // by users. Claim those not used for dependency files.
+ if (JA.isOffloading(Action::OFK_HIP)) {
+ Args.ClaimAllArgs(options::OPT_offload_compress);
+ Args.ClaimAllArgs(options::OPT_no_offload_compress);
+ }
bool HasTarget = false;
for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {
diff --git a/clang/test/Driver/hip-options.hip b/clang/test/Driver/hip-options.hip
index 0aabc8ad41904..962676ada9497 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -242,3 +242,9 @@
// NO-WARN-ATOMIC: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-Werror=atomic-alignment" {{.*}} "-Wno-error=atomic-alignment"
// NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-Werror=atomic-alignment"
// NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-Wno-error=atomic-alignment"
+
+// Check --offload-compress does not cause warning.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN: --offload-arch=gfx1100 --offload-compress --offload-host-only -M %s \
+// RUN: 2>&1 | FileCheck -check-prefix=COMPRESS %s
+// COMPRESS-NOT: clang: warning: argument unused during compilation: '--offload-compress'
More information about the cfe-commits
mailing list