[clang] [PS5][Driver] Query `OPT_r`/`OPT_shared`/`OPT_static` just once (NFC) (PR #113452)
Edd Dawson via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 05:59:36 PDT 2024
https://github.com/playstation-edd created https://github.com/llvm/llvm-project/pull/113452
None
>From 3552f590214267e5f81719d94c43be545e474cb3 Mon Sep 17 00:00:00 2001
From: Edd Dawson <edd.dawson at sony.com>
Date: Wed, 23 Oct 2024 13:42:49 +0100
Subject: [PATCH] [PS5][Driver] Query `OPT_r`/`OPT_shared`/`OPT_static` just
once (NFC)
---
clang/lib/Driver/ToolChains/PS4CPU.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
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.");
More information about the cfe-commits
mailing list