llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) <details> <summary>Changes</summary> Summary: Right now we have `--no-hip-rt` to suppress the implicit linking of the HIP runtime. However, we already have a flag for `--no-offloadlib` which seems to imply this. However, this one currently only applies to the device-side library. More targets will likely use this soon, so it would be nice to unify the behavior here. The impact of this change is that `-nogpulib` which is commonly used to suppress the ROCm device libraries will now also suppress this, and `--no-hip-rt` will suppress the ROCm device libraries. This is a functional change, but I'm not sure if anyone truly relies on this distinction in the wild. Functionally, one turns off the host runtime, the other the device. This PR makes both do both at the same time. Since these are libraries we should be able to just get users to pass them manually if needed. --- Full diff: https://github.com/llvm/llvm-project/pull/177677.diff 5 Files Affected: - (modified) clang/include/clang/Options/Options.td (+2-2) - (modified) clang/lib/Driver/ToolChains/Linux.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/MSVC.cpp (+1-1) - (modified) clang/test/Driver/hip-runtime-libs-linux.hip (+2-2) - (modified) clang/test/Driver/hip-runtime-libs-msvc.hip (+4-4) ``````````diff diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 43727236ed5a4..af3ecb8a38d6c 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -1347,8 +1347,6 @@ def mprintf_kind_EQ : Joined<["-"], "mprintf-kind=">, Group<m_Group>, let Group = hip_Group in { def hip_link : Flag<["--"], "hip-link">, Group<opencl_Group>, HelpText<"Link clang-offload-bundler bundles for HIP">; -def no_hip_rt: Flag<["-"], "no-hip-rt">, Group<hip_Group>, - HelpText<"Do not link against HIP runtime libraries">; def rocm_path_EQ : Joined<["--"], "rocm-path=">, Visibility<[FlangOption]>, Group<hip_Group>, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; @@ -6121,6 +6119,8 @@ def no_offloadlib MarshallingInfoFlag<LangOpts<"NoGPULib">>, Visibility<[ClangOption, CC1Option, CLOption, FlangOption, FC1Option]>, HelpText<"Do not link device library for CUDA/HIP/SYCL device compilation">; +def no_hip_rt: Flag<["-"], "no-hip-rt">, Group<hip_Group>, + HelpText<"Do not link against HIP runtime libraries">, Alias<no_offloadlib>; def offloadlib : Flag<["--"], "offloadlib">, Visibility<[ClangOption, CC1Option, CLOption, FlangOption, FC1Option]>, HelpText<"Link device libraries for GPU device compilation">; diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index cb12b2455f035..6bd277dc97091 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -848,7 +848,7 @@ void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs, void Linux::addOffloadRTLibs(unsigned ActiveKinds, const ArgList &Args, ArgStringList &CmdArgs) const { if (Args.hasArg(options::OPT_nostdlib) || - Args.hasArg(options::OPT_no_hip_rt) || Args.hasArg(options::OPT_r)) + Args.hasArg(options::OPT_no_offloadlib) || Args.hasArg(options::OPT_r)) return; llvm::SmallVector<std::pair<StringRef, StringRef>> Libraries; diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 229be08ea7a5c..8638c58093e59 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -518,7 +518,7 @@ void MSVCToolChain::addSYCLIncludeArgs(const ArgList &DriverArgs, void MSVCToolChain::addOffloadRTLibs(unsigned ActiveKinds, const ArgList &Args, ArgStringList &CmdArgs) const { - if (Args.hasArg(options::OPT_no_hip_rt) || Args.hasArg(options::OPT_r)) + if (Args.hasArg(options::OPT_no_offloadlib) || Args.hasArg(options::OPT_r)) return; if (ActiveKinds & Action::OFK_HIP) { diff --git a/clang/test/Driver/hip-runtime-libs-linux.hip b/clang/test/Driver/hip-runtime-libs-linux.hip index d814cae241813..8be0690e42b8f 100644 --- a/clang/test/Driver/hip-runtime-libs-linux.hip +++ b/clang/test/Driver/hip-runtime-libs-linux.hip @@ -54,8 +54,8 @@ // RUN: | FileCheck -check-prefixes=NOHIPRT %s // Test HIP runtime lib is linked without hip-link if there is HIP input file. -// RUN: %clang -### --target=x86_64-linux-gnu -nogpuinc -nogpulib \ -// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: %clang -### --target=x86_64-linux-gnu -nogpuinc \ +// RUN: --offload-arch=gfx908 --rocm-path=%S/Inputs/rocm %s 2>&1 \ // RUN: | FileCheck -check-prefixes=ROCM-PATH %s // ROCM-PATH: "{{.*/Inputs/rocm/lib/libamdhip64.so}}" diff --git a/clang/test/Driver/hip-runtime-libs-msvc.hip b/clang/test/Driver/hip-runtime-libs-msvc.hip index d282a2646342a..af10afebbe499 100644 --- a/clang/test/Driver/hip-runtime-libs-msvc.hip +++ b/clang/test/Driver/hip-runtime-libs-msvc.hip @@ -6,15 +6,15 @@ // RUN: | FileCheck %s // Test HIP runtime lib is linked without --hip-link when there is HIP input file. -// RUN: %clang -### --target=x86_64-pc-windows-msvc -nogpuinc -nogpulib \ -// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: %clang -### --target=x86_64-pc-windows-msvc -nogpuinc \ +// RUN: --offload-arch=gfx908 --rocm-path=%S/Inputs/rocm %s 2>&1 \ // RUN: | FileCheck %s // Test HIP runtime lib is linked even if -nostdlib is specified when the input // is a HIP file. This is important when composing with e.g. the UCRT or other // non glibc-like implementations of the C standard library. -// RUN: %clang -### --target=x86_64-pc-windows-msvc -nogpuinc -nogpulib \ -// RUN: -nostdlib --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: %clang -### --target=x86_64-pc-windows-msvc -nogpuinc \ +// RUN: --offload-arch=gfx908 -nostdlib --rocm-path=%S/Inputs/rocm %s 2>&1 \ // RUN: | FileCheck %s // CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib" `````````` </details> https://github.com/llvm/llvm-project/pull/177677 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
