aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2025-02-05 15:15:36 -0800
committerGitHub <noreply@github.com>2025-02-05 15:15:36 -0800
commit1901f4ac8eb1ddd8df822841a48b818c496aa2ad (patch)
tree7c462e9d509985d9484e002dc114a79ce8a1b9a0 /clang/lib/Frontend/CompilerInvocation.cpp
parent0d7ee520d3a9b8997adf8eaaa22b33db9659d94e (diff)
downloadllvm-1901f4ac8eb1ddd8df822841a48b818c496aa2ad.zip
llvm-1901f4ac8eb1ddd8df822841a48b818c496aa2ad.tar.gz
llvm-1901f4ac8eb1ddd8df822841a48b818c496aa2ad.tar.bz2
CodeGen: support static linking for libclosure (#125384)
When building on Windows, dealing with the BlocksRuntime is slightly more complicated. As we are not guaranteed a formward declaration for the blocks runtime ABI symbols, we may generate the declarations for them. In order to properly link against the well-known types, we always annotated them as `__declspec(dllimport)`. This would require the dynamic linking of the blocks runtime under all conditions. However, this is the only the only possible way to us the library. We may be building a fully sealed (static) executable. In such a case, the well known symbols should not be marked as `dllimport` as they are assumed to be statically available with the static linking to the BlocksRuntime. Introduce a new driver/cc1 option `-static-libclosure` which mirrors the myriad of similar options (`-static-libgcc`, `-static-libstdc++`, -static-libsan`, etc).
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 95d3eac7..8b1bbf1 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1843,6 +1843,9 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts,
GenerateArg(Consumer, OPT_fno_finite_loops);
break;
}
+
+ if (Opts.StaticClosure)
+ GenerateArg(Consumer, OPT_static_libclosure);
}
bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
@@ -2330,6 +2333,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
if (!Opts.EmitIEEENaNCompliantInsts && !LangOptsRef.NoHonorNaNs)
Diags.Report(diag::err_drv_amdgpu_ieee_without_no_honor_nans);
+ Opts.StaticClosure = Args.hasArg(options::OPT_static_libclosure);
+
return Diags.getNumErrors() == NumErrorsBefore;
}