Skip to content

Commit 1a1dbac

Browse files
[PS4/PS5][Driver] Observe <sysroot>/target/lib for libraries (#123350)
On PS5, if a custom --sysroot is supplied, `<sysroot>/target/lib` should be added to the library search paths (this already occurs if the default `--sysroot` is not overridden). Until now, this has been hardcoded as a downstream patch in lld. Add it to the driver so that the private patch can be removed. On PS4 the library search paths remain unchanged. The proprietary linker will continue to handle this aspect. On either platform, warn if `<sysroot>/target/lib` is absent. Previously, such warnings were emitted only when the default --sysroot was not overridden. SIE tracker: TOOLCHAIN-16704
1 parent 099fd01 commit 1a1dbac

File tree

4 files changed

+39
-36
lines changed

4 files changed

+39
-36
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
490490

491491
bool Linking = !Args.hasArg(options::OPT_E, options::OPT_c, options::OPT_S,
492492
options::OPT_emit_ast);
493-
if (!CustomSysroot && Linking) {
493+
if (Linking) {
494494
SmallString<128> Dir(SDKLibraryRootDir);
495495
llvm::sys::path::append(Dir, "target/lib");
496496
if (CheckSDKPartExists(Dir, "system libraries"))

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/// PS4 clang emits warnings when SDK headers (<SDKROOT>/target/include/) or
2-
/// libraries (<SDKROOT>/target/lib/) are missing, unless the user takes control
3-
/// of search paths, when corresponding existence checks are skipped.
2+
/// libraries (<SDKROOT>/target/lib/) are missing. If the the user takes control
3+
/// of header search paths, the existence check for <SDKROOT>/target/include is
4+
/// skipped.
45
///
56
/// User control of header search is assumed if `--sysroot`, `-isysroot`,
6-
/// `-nostdinc` or `-nostdlibinc` is supplied. User control of library search
7-
/// is assumed if `--sysroot` is supplied.
7+
/// `-nostdinc` or `-nostdlibinc` is supplied.
88
///
99
/// Warnings are emitted if a specified `-isysroot` or `--sysroot` does not
1010
/// exist.
@@ -46,22 +46,23 @@
4646
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c -isysroot . 2>&1 | FileCheck -check-prefixes=NO-WARN %s
4747
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c --sysroot=. 2>&1 | FileCheck -check-prefixes=NO-WARN %s
4848

49-
/// --sysroot disables the existence check for libraries and headers.
50-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | FileCheck -check-prefix=NO-WARN %s
49+
/// --sysroot disables the existence check for headers. The check for libraries
50+
/// remains.
51+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | FileCheck -check-prefixes=WARN-SYS-LIBS,NO-WARN %s
5152

5253
/// -isysroot overrides --sysroot for header search, but not library search.
53-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot . --sysroot=.. 2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
54-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=.. -isysroot . 2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
54+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot . --sysroot=%t.inconly 2>&1 | FileCheck -check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
55+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=%t.inconly -isysroot . 2>&1 | FileCheck -check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
5556

5657
/// Warnings are emitted if non-existent --sysroot/-isysroot are supplied.
57-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot . 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
58-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo --sysroot=. 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
59-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYSROOT2,NO-WARN %s
58+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot %t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYS-LIBS,NO-WARN %s
59+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo --sysroot=%t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
60+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYSROOT2,WARN-SYS-LIBS,NO-WARN %s
6061

6162
// NO-WARN-NOT: {{warning:|error:}}
62-
// WARN-SYS-LIBS: warning: unable to find PS4 system libraries directory
63-
// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory
6463
// WARN-SYSROOT: warning: no such sysroot directory: 'foo'
6564
// WARN-SYSROOT2: warning: no such sysroot directory: 'bar'
65+
// WARN-SYS-LIBS: warning: unable to find PS4 system libraries directory
66+
// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory
6667
// NO-WARN-NOT: {{warning:|error:}}
6768
// ISYSTEM: "-cc1"{{.*}}"-internal-externc-isystem" "./target/include"

clang/test/Driver/ps5-linker.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,26 @@
174174

175175
// Test implicit library search paths are supplied to the linker, after any
176176
// search paths specified by the user. <sdk-root>/target/lib is implicitly
177-
// added if it exists and no --sysroot is specified. CRT objects are found
178-
// there. "." is always implicitly added to library search paths. This is
179-
// long-standing behavior, unique to PlayStation toolchains.
177+
// added if it exists. CRT objects are found there. "." is always implicitly
178+
// added to library search paths. This is long-standing behavior, unique to
179+
// PlayStation toolchains.
180180

181181
// RUN: rm -rf %t.dir && mkdir %t.dir
182182
// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir %clang --target=x64_64-sie-ps5 %s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-NO-TARGETLIB %s
183-
// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir 2>&1 | FileCheck --check-prefixes=CHECK-NO-TARGETLIB %s
183+
// RUN: %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir 2>&1 | FileCheck --check-prefixes=CHECK-NO-TARGETLIB %s
184184

185185
// CHECK-NO-TARGETLIB: {{ld(\.exe)?}}"
186186
// CHECK-NO-TARGETLIB-SAME: "-Luser"
187187
// CHECK-NO-TARGETLIB-NOT: "-L{{.*[/\\]}}target/lib"
188188
// CHECK-NO-TARGETLIB-SAME: "-L."
189189

190-
// RUN: mkdir -p %t.dir/target/lib
191-
// RUN: touch %t.dir/target/lib/crti.o
192-
// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir %clang --target=x64_64-sie-ps5 %s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s
190+
// RUN: mkdir -p %t.dir/myroot/target/lib
191+
// RUN: touch %t.dir/myroot/target/lib/crti.o
192+
// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir/myroot %clang --target=x64_64-sie-ps5 %s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s
193+
// RUN: %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir/myroot 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s
193194

194195
// CHECK-TARGETLIB: {{ld(\.exe)?}}"
195196
// CHECK-TARGETLIB-SAME: "-Luser"
196-
// CHECK-TARGETLIB-SAME: "-L{{.*[/\\]}}target/lib"
197+
// CHECK-TARGETLIB-SAME: "-L{{.*}}myroot{{/|\\\\}}target{{/|\\\\}}lib"
197198
// CHECK-TARGETLIB-SAME: "-L."
198-
// CHECK-TARGETLIB-SAME: "{{.*[/\\]}}target{{/|\\\\}}lib{{/|\\\\}}crti.o"
199+
// CHECK-TARGETLIB-SAME: "{{.*}}myroot{{/|\\\\}}target{{/|\\\\}}lib{{/|\\\\}}crti.o"

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// (Essentially identical to ps4-sdk-root.c except for the target.)
22

33
/// PS5 clang emits warnings when SDK headers (<SDKROOT>/target/include/) or
4-
/// libraries (<SDKROOT>/target/lib/) are missing, unless the user takes control
5-
/// of search paths, when corresponding existence checks are skipped.
4+
/// libraries (<SDKROOT>/target/lib/) are missing. If the the user takes control
5+
/// of header search paths, the existence check for <SDKROOT>/target/include is
6+
/// skipped.
67
///
78
/// User control of header search is assumed if `--sysroot`, `-isysroot`,
8-
/// `-nostdinc` or `-nostdlibinc` is supplied. User control of library search
9-
/// is assumed if `--sysroot` is supplied.
9+
/// `-nostdinc` or `-nostdlibinc` is supplied.
1010
///
1111
/// Warnings are emitted if a specified `-isysroot` or `--sysroot` does not
1212
/// exist.
@@ -48,22 +48,23 @@
4848
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -c -isysroot . 2>&1 | FileCheck -check-prefixes=NO-WARN %s
4949
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -c --sysroot=. 2>&1 | FileCheck -check-prefixes=NO-WARN %s
5050

51-
/// --sysroot disables the existence check for libraries and headers.
52-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | FileCheck -check-prefix=NO-WARN %s
51+
/// --sysroot disables the existence check for headers. The check for libraries
52+
/// remains.
53+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | FileCheck -check-prefixes=WARN-SYS-LIBS,NO-WARN %s
5354

5455
/// -isysroot overrides --sysroot for header search, but not library search.
55-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -isysroot . --sysroot=.. 2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
56-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=.. -isysroot . 2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
56+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -isysroot . --sysroot=%t.inconly 2>&1 | FileCheck -check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
57+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=%t.inconly -isysroot . 2>&1 | FileCheck -check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
5758

5859
/// Warnings are emitted if non-existent --sysroot/-isysroot are supplied.
59-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot . 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
60-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo --sysroot=. 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
61-
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYSROOT2,NO-WARN %s
60+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot %t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYS-LIBS,NO-WARN %s
61+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo --sysroot=%t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
62+
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYSROOT2,WARN-SYS-LIBS,NO-WARN %s
6263

6364
// NO-WARN-NOT: {{warning:|error:}}
64-
// WARN-SYS-LIBS: warning: unable to find PS5 system libraries directory
65-
// WARN-SYS-HEADERS: warning: unable to find PS5 system headers directory
6665
// WARN-SYSROOT: warning: no such sysroot directory: 'foo'
6766
// WARN-SYSROOT2: warning: no such sysroot directory: 'bar'
67+
// WARN-SYS-LIBS: warning: unable to find PS5 system libraries directory
68+
// WARN-SYS-HEADERS: warning: unable to find PS5 system headers directory
6869
// NO-WARN-NOT: {{warning:|error:}}
6970
// ISYSTEM: "-cc1"{{.*}}"-internal-externc-isystem" "./target/include"

0 commit comments

Comments
 (0)