aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorAndrew Rogers <andrurogerz@gmail.com>2025-06-24 16:23:00 -0700
committerGitHub <noreply@github.com>2025-06-24 16:23:00 -0700
commita451fff1ad43fe2f49fb8029055baa31d504487c (patch)
treeb51c52ef913a673fb787399eda5e56280d4c924b /clang/lib/CodeGen/BackendUtil.cpp
parente93a0d0d1ed790173e23247fa2833cdac30b8268 (diff)
downloadllvm-a451fff1ad43fe2f49fb8029055baa31d504487c.zip
llvm-a451fff1ad43fe2f49fb8029055baa31d504487c.tar.gz
llvm-a451fff1ad43fe2f49fb8029055baa31d504487c.tar.bz2
[llvm] fix extern cl::opt definitions for DLL export (#145374)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch ensures a few `cl::opt` declarations are properly annotated with `LLVM_ABI`. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Overview - Remove local `extern` declarations of `llvm::PrintPipelinePasses` because it is already correctly declared with an `LLVM_ABI` annotation in `llvm\Passes\PassBuilder.h`. Leaving these declarations results in a gcc compile warning unless they are also annotated with `LLVM_ABI`. - Similarly, remove local `extern` declarations of `ProfileSummaryCutoffHot` and `UseContextLessSummary` from `llvm/tools/llvm-profgen/ProfileGenerator.cpp` since they are declared with `LLVM_ABI` in `llvm\ProfileData\ProfileCommon.h`. - Explicitly annotate the extern declaration of `ProfileCorrelate` in `clang/lib/CodeGen/BackendUtil.cpp` since it is not declared in a header. The definition of `ProfileCorrelate` in `llvm\lib\Transforms\Instrumentation\InstrProfiling.cpp` is already annotated with `LLVM_ABI`. ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 7e0a3cf..97bc063 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -43,6 +43,7 @@
#include "llvm/ProfileData/InstrProfCorrelator.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Program.h"
@@ -96,8 +97,6 @@ using namespace llvm;
#include "llvm/Support/Extension.def"
namespace llvm {
-extern cl::opt<bool> PrintPipelinePasses;
-
// Experiment to move sanitizers earlier.
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
"sanitizer-early-opt-ep", cl::Optional,
@@ -118,7 +117,8 @@ static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
"Mark cold functions with optnone.")));
-extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;
+LLVM_ABI extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind>
+ ProfileCorrelate;
} // namespace llvm
namespace clang {
extern llvm::cl::opt<bool> ClSanitizeGuardChecks;