Skip to content

Commit f574b9c

Browse files
[PS4,PS5][Driver] Check for absent SDK when -nostdlib/-nodefaultlibs (#107112)
The PlayStation drivers emit warnings if it looks like SDK libraries are missing. Until this point, the check was skipped when either `-nostdlib` or `-nodefaultlibs` was supplied. I believe the idea is that if you aren't linking default libraries, you won't be in need of the SDK. However, in a situation where these switches are supplied, users may still want to pass `-lSomeSDKLib` to the driver/linker with the expectation that libSomeSDKLib.a will be sourced from the SDK. That is, `-nodefaultlibs` and `-nostdlib` affect the libraries passed to the linker, but not the library search paths. So this change removes `-nostdlib`/`-nodefaultlibs` from consideration when deciding whether or not to probe for the SDK's existence. N.B. complete behaviour for `-nostdlib` and `-nodefaultlibs` is yet to be added to the PlayStation compiler drivers. Coming soon. SIE tracker: TOOLCHAIN-16704
1 parent 0fffdeb commit f574b9c

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
354354

355355
SmallString<512> SDKLibDir(SDKRootDir);
356356
llvm::sys::path::append(SDKLibDir, "target/lib");
357-
if (!Args.hasArg(options::OPT_nostdlib) &&
358-
!Args.hasArg(options::OPT_nodefaultlibs) &&
359-
!Args.hasArg(options::OPT__sysroot_EQ) && !Args.hasArg(options::OPT_E) &&
357+
if (!Args.hasArg(options::OPT__sysroot_EQ) && !Args.hasArg(options::OPT_E) &&
360358
!Args.hasArg(options::OPT_c) && !Args.hasArg(options::OPT_S) &&
361359
!Args.hasArg(options::OPT_emit_ast) &&
362360
!llvm::sys::fs::exists(SDKLibDir)) {

clang/test/Driver/ps4-sdk-root.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
// Check that PS4 clang doesn't report a warning message when locating
88
// system libraries (either by looking at the value of SCE_ORBIS_SDK_DIR
9-
// or relative to the location of the compiler driver), if "-c", "-S", "-E",
10-
// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on
11-
// the command line.
9+
// or relative to the location of the compiler driver), if "-c", "-S", "-E"
10+
// or "--sysroot" option is specified on the command line.
1211
// Otherwise, check that PS4 clang reports a warning.
1312

1413
// Setting up SCE_ORBIS_SDK_DIR to existing location, which is not a PS4 SDK.
@@ -36,9 +35,6 @@
3635
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
3736
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### --sysroot=foo/ -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
3837

39-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nostdlib -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
40-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nodefaultlibs -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
41-
4238
// NO-WARN-NOT: {{warning:|error:}}
4339
// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory
4440
// WARN-ISYSROOT: warning: no such sysroot directory: 'foo'

clang/test/Driver/ps5-sdk-root.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
// Check that PS5 clang doesn't report a warning message when locating
1010
// system libraries (either by looking at the value of SCE_PROSPERO_SDK_DIR
11-
// or relative to the location of the compiler driver), if "-c", "-S", "-E",
12-
// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on
13-
// the command line.
11+
// or relative to the location of the compiler driver), if "-c", "-S", "-E"
12+
// or "--sysroot" option is specified on the command line.
1413
// Otherwise, check that PS5 clang reports a warning.
1514

16-
// Setting up SCE_PROSPERO_SDK_DIR to existing location, which is not a PS4 SDK.
15+
// Setting up SCE_PROSPERO_SDK_DIR to existing location, which is not a PS5 SDK.
1716
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
1817

1918
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
@@ -38,9 +37,6 @@
3837
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
3938
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### --sysroot=foo/ -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
4039

41-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nostdlib -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
42-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nodefaultlibs -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
43-
4440
// NO-WARN-NOT: {{warning:|error:}}
4541
// WARN-SYS-HEADERS: warning: unable to find PS5 system headers directory
4642
// WARN-ISYSROOT: warning: no such sysroot directory: 'foo'

0 commit comments

Comments
 (0)