llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Nikita Kornev (KornevNikita) <details> <summary>Changes</summary> add_llvm_library ignores STATIC, so with BUILD_SHARED_LIBS=ON the library was built as a shared object and failed to link because Verbose is defined in the tool. Build it with llvm_add_library STATIC and move Verbose and OffloadArchCategory into the library. Fixes build failures after #<!-- -->226552 (e.g. https://lab.llvm.org/buildbot/#/builders/226/builds/23094). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Full diff: https://github.com/llvm/llvm-project/pull/229075.diff 4 Files Affected: - (modified) clang/tools/offload-arch/OffloadArch.cpp (+2-5) - (modified) clang/tools/offload-arch/lib/CMakeLists.txt (+5-4) - (added) clang/tools/offload-arch/lib/OffloadArchOptions.cpp (+22) - (modified) clang/unittests/tools/offload-arch/OffloadArchTest.cpp (-3) ``````````diff diff --git a/clang/tools/offload-arch/OffloadArch.cpp b/clang/tools/offload-arch/OffloadArch.cpp index 934d20fd95f72..68404c0da1aba 100644 --- a/clang/tools/offload-arch/OffloadArch.cpp +++ b/clang/tools/offload-arch/OffloadArch.cpp @@ -12,8 +12,8 @@ using namespace llvm; -// Mark all our options with this category. -static cl::OptionCategory OffloadArchCategory("offload-arch options"); +// Defined in lib/OffloadArchOptions.cpp. +extern cl::OptionCategory OffloadArchCategory; extern cl::OptionCategory AMDGPUArchByHIPCategory; @@ -32,9 +32,6 @@ static cl::opt<VendorName> clEnumVal(nvptx, "Only print NVIDIA GPUs"), clEnumVal(intel, "Only print Intel GPUs"))); -cl::opt<bool> Verbose("verbose", cl::desc("Enable verbose output"), - cl::init(false), cl::cat(OffloadArchCategory)); - static void PrintVersion(raw_ostream &OS) { OS << clang::getClangToolFullVersion("offload-arch") << '\n'; } diff --git a/clang/tools/offload-arch/lib/CMakeLists.txt b/clang/tools/offload-arch/lib/CMakeLists.txt index 2692229dc675b..26c88ad701001 100644 --- a/clang/tools/offload-arch/lib/CMakeLists.txt +++ b/clang/tools/offload-arch/lib/CMakeLists.txt @@ -1,12 +1,13 @@ # Not add_clang_library: this is not part of clang's public library interface, -# the sources are shared between offload-arch and its unit tests. -add_llvm_library(clangOffloadArch STATIC +# the sources are shared between offload-arch and its unit tests. Use +# llvm_add_library directly, because add_llvm_library ignores STATIC and builds +# a shared library with BUILD_SHARED_LIBS=ON, which is never installed. +llvm_add_library(clangOffloadArch STATIC AMDGPUArchByHIP.cpp AMDGPUArchByKFD.cpp LevelZeroArch.cpp NVPTXArch.cpp - - BUILDTREE_ONLY + OffloadArchOptions.cpp LINK_COMPONENTS Support diff --git a/clang/tools/offload-arch/lib/OffloadArchOptions.cpp b/clang/tools/offload-arch/lib/OffloadArchOptions.cpp new file mode 100644 index 0000000000000..5f6d334d7ddfe --- /dev/null +++ b/clang/tools/offload-arch/lib/OffloadArchOptions.cpp @@ -0,0 +1,22 @@ +//===- OffloadArchOptions.cpp - options shared by offload-arch -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the command line options used by both the offload-arch +// tool and the vendor-specific GPU detection code. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" + +using namespace llvm; + +// Mark all our options with this category. +cl::OptionCategory OffloadArchCategory("offload-arch options"); + +cl::opt<bool> Verbose("verbose", cl::desc("Enable verbose output"), + cl::init(false), cl::cat(OffloadArchCategory)); diff --git a/clang/unittests/tools/offload-arch/OffloadArchTest.cpp b/clang/unittests/tools/offload-arch/OffloadArchTest.cpp index 7de00610bd189..1c14209a537e5 100644 --- a/clang/unittests/tools/offload-arch/OffloadArchTest.cpp +++ b/clang/unittests/tools/offload-arch/OffloadArchTest.cpp @@ -8,7 +8,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" @@ -35,8 +34,6 @@ std::string getIntelGPUArchName(uint32_t IPVersion); using namespace llvm; -cl::opt<bool> Verbose("offload-arch-test-verbose", cl::Hidden, cl::init(false)); - #ifdef _WIN32 // --- compareVersions --- `````````` </details> https://github.com/llvm/llvm-project/pull/229075 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
