alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

0017-clang-use-as-needed-by-default.patch (1212B)


      1 From 28381edd19f49f3bbc9938a714782e0e92691953 Mon Sep 17 00:00:00 2001
      2 From: q66 <q66@chimera-linux.org>
      3 Date: Sun, 14 Apr 2024 14:48:51 +0200
      4 Subject: [PATCH 17/30] clang: use --as-needed by default
      5 
      6 ---
      7  clang/lib/Driver/ToolChains/Gnu.cpp | 7 +++++++
      8  1 file changed, 7 insertions(+)
      9 
     10 diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
     11 index 5e9a655ea..263c4632a 100644
     12 --- a/clang/lib/Driver/ToolChains/Gnu.cpp
     13 +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
     14 @@ -543,6 +543,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     15    bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
     16    bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
     17    addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
     18 +
     19 +  // Use --as-needed by default for all explicit linker inputs on Linux
     20 +  // We don't reset it afterwards because explicit argument does not
     21 +  // get reset either (and that is permitted, so it should be fine)
     22 +  if (Triple.isOSLinux())
     23 +    CmdArgs.push_back("--as-needed");
     24 +
     25    AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
     26  
     27    addHIPRuntimeLibArgs(ToolChain, C, Args, CmdArgs);
     28 -- 
     29 2.47.0
     30