================
@@ -1609,7 +1609,12 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList
&Args,
if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
- // Libfuzzer is written in C++ and requires libcxx.
+ // Libfuzzer is written in C++ and requires libcxx.
+ // Since darwin::Linker::ConstructJob already adds -l++ for clang++
+ // by default (checked via ShouldLinkCXXStdlib), we only link if
+ // we are not invoked as CXX. This avoids duplicate library errors
+ // on Darwin.
+ if (!getDriver().CCCIsCXX())
----------------
DanBlackwell wrote:
It looks like there are some more conditions to the `ShouldLinkCXXStdlib`
check:
https://github.com/ndrewh/llvm-project/blob/4096bc5f104537a993db036b02d90ece37e2c6fd/clang/lib/Driver/ToolChain.cpp#L1529
```
!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_nostdlibxx);
```
Is it possible that this evaluates to false and then we end up failing to link
libc++ because we assumed that we'd have it due to invoking clang++? Perhaps
this would be better:
```
if (!CmdArgs.contains("-lc++")) // pseudocode
AddCXXStdlibLibArgs(Args, CmdArgs);
```
https://github.com/llvm/llvm-project/pull/161304
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits