[clang] [PS5][Driver] Query `OPT_r`/`OPT_shared`/`OPT_static` just once (NFC) (PR #113452)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 06:00:16 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
Author: Edd Dawson (playstation-edd)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/113452.diff
1 Files Affected:
- (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+5-4)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 02b1e034c28789..a50333223ff5c4 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -230,6 +230,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
ArgStringList CmdArgs;
const bool Relocatable = Args.hasArg(options::OPT_r);
+ const bool Shared = Args.hasArg(options::OPT_shared);
+ const bool Static = Args.hasArg(options::OPT_static);
// Silence warning for "clang -g foo.o -o foo"
Args.ClaimAllArgs(options::OPT_g_Group);
@@ -243,8 +245,7 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.MakeArgString("--sysroot=" + TC.getSDKLibraryRootDir()));
// Default to PIE for non-static executables.
- const bool PIE =
- !Args.hasArg(options::OPT_r, options::OPT_shared, options::OPT_static);
+ const bool PIE = !Relocatable && !Shared && !Static;
if (Args.hasFlag(options::OPT_pie, options::OPT_no_pie, PIE))
CmdArgs.push_back("-pie");
@@ -270,11 +271,11 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe");
}
- if (Args.hasArg(options::OPT_static))
+ if (Static)
CmdArgs.push_back("-static");
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
- if (Args.hasArg(options::OPT_shared))
+ if (Shared)
CmdArgs.push_back("--shared");
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
``````````
</details>
https://github.com/llvm/llvm-project/pull/113452
More information about the cfe-commits
mailing list