While researching ThreadSanitizer, I noticed that clang passes -no_deduplicate to the linker on macOS for debug builds:
/// Pass -no_deduplicate to ld64 under certain conditions:
///
/// - Either -O0 or -O1 is explicitly specified
/// - No -O option is specified *and* this is a compile+link (implicit -O0)
///
/// Also do *not* add -no_deduplicate when no -O option is specified and this
/// is just a link (we can't imply -O0)
static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, const ArgList &Args) {
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
if (A->getOption().matches(options::OPT_O0))
return true;
if (A->getOption().matches(options::OPT_O))
return llvm::StringSwitch<bool>(A->getValue())
.Case("1", true)
.Default(false);
return false; // OPT_Ofast & OPT_O4
}
if (!IsLinkerOnlyAction) // Implicit -O0 for compile+linker only.
return true;
return false;
}
Someone care to test this on macOS with different programs and see if the flag has a big impact? If so: we should add something similar as clang is doing.
While researching ThreadSanitizer, I noticed that clang passes
-no_deduplicate
to the linker on macOS for debug builds:Passing the flag may speed up builds by quite a bit: https://jira.mongodb.org/browse/SERVER-31875
Someone care to test this on macOS with different programs and see if the flag has a big impact? If so: we should add something similar as clang is doing.