Author: Leonard Chan Date: 2022-02-08T10:53:22-08:00 New Revision: 4ac58b61022d128d60ffea06c20611b8eaf8601a
URL: https://github.com/llvm/llvm-project/commit/4ac58b61022d128d60ffea06c20611b8eaf8601a DIFF: https://github.com/llvm/llvm-project/commit/4ac58b61022d128d60ffea06c20611b8eaf8601a.diff LOG: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check Differential Revision: https://reviews.llvm.org/D119201 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 8addee22a2bd..40364d23c559 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -771,11 +771,6 @@ static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) { void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) { - // Fuchsia never needs these. Any sanitizer runtimes with system - // dependencies use the `.deplibs` feature instead. - if (TC.getTriple().isOSFuchsia()) - return; - // Force linking against the system libraries sanitizers depends on // (see PR15823 why this is necessary). CmdArgs.push_back(getAsNeededOption(TC, false)); diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index bd1600d060c8..9e0b259dfcae 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -127,10 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA, D.getLTOMode() == LTOK_Thin); } - bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); - bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); - ToolChain.addProfileRTLibs(Args, CmdArgs); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_r)) { @@ -153,11 +150,14 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } - if (NeedsSanitizerDeps) - linkSanitizerRuntimeDeps(ToolChain, CmdArgs); + // Note that Fuchsia never needs to link in sanitizer runtime deps. Any + // sanitizer runtimes with system dependencies use the `.deplibs` feature + // instead. + addSanitizerRuntimes(ToolChain, Args, CmdArgs); - if (NeedsXRayDeps) - linkXRayRuntimeDeps(ToolChain, CmdArgs); + addXRayRuntime(ToolChain, Args, CmdArgs); + + ToolChain.addProfileRTLibs(Args, CmdArgs); AddRunTimeLibs(ToolChain, D, CmdArgs, Args); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits