Skip to content

Commit 1e23a61

Browse files
[PS4,PS5][Driver] Detangle --sysroot and -isysroot (#107410)
The following discrepancies concerning `-isysroot` and `--sysroot` motivated this change: - The SDK directory can be specified via `-isysroot`, but `--sysroot` has no influence over this. Yet, we check for the presence of either switch to determine whether we ought to warn about a missing SDK *headers*. - The presence of `-isysroot` is ignored when deciding whether to warn about missing SDK *libraries*, depsite it being the only switch capable of specifying a non-default SDK location. - The `--sysroot`s passed to the PlayStation linkers by the driver are unrelated to the SDK directory resolved in the PS4PS5Base constructor. Following this change, we attempt to derive an SDK root from a platform- specific environment variable. Failing that, we derive it from the location of the driver. This then becomes the default root directory for both header and library search. `--sysroot` overrides both search roots. `-isysroot` overrides only the header search root. If both are specified, `--sysroot` specifies the library search root and `-isysroot` specifies the header search root. For each search root that was not overridden, a warning is emitted if expected header/library search paths are missing inside that root. The test updates to ps{4,5}-sdk-root.c were of the scale of a rewrite so I also took the opportunity to clarify the purpose of each part, eliminate some redundancy and add some missing coverage. SIE tracker: TOOLCHAIN-16704
1 parent b3a2208 commit 1e23a61

File tree

7 files changed

+204
-116
lines changed

7 files changed

+204
-116
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ void tools::PS4cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
135135
// handled somewhere else.
136136
Args.ClaimAllArgs(options::OPT_w);
137137

138-
if (!D.SysRoot.empty())
139-
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
138+
CmdArgs.push_back(
139+
Args.MakeArgString("--sysroot=" + TC.getSDKLibraryRootDir()));
140140

141141
if (Args.hasArg(options::OPT_pie))
142142
CmdArgs.push_back("-pie");
@@ -234,8 +234,8 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
234234
// handled somewhere else.
235235
Args.ClaimAllArgs(options::OPT_w);
236236

237-
if (!D.SysRoot.empty())
238-
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
237+
CmdArgs.push_back(
238+
Args.MakeArgString("--sysroot=" + TC.getSDKLibraryRootDir()));
239239

240240
// Default to PIE for non-static executables.
241241
const bool PIE =
@@ -325,46 +325,63 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
325325
const ArgList &Args, StringRef Platform,
326326
const char *EnvVar)
327327
: Generic_ELF(D, Triple, Args) {
328-
// Determine where to find the PS4/PS5 libraries.
329-
// If -isysroot was passed, use that as the SDK base path.
330-
// If not, we use the EnvVar if it exists; otherwise use the driver's
331-
// installation path, which should be <SDK_DIR>/host_tools/bin.
328+
// Determine the baseline SDK directory from the environment, else
329+
// the driver's location, which should be <SDK_DIR>/host_tools/bin.
330+
SmallString<128> SDKRootDir;
332331
SmallString<80> Whence;
333-
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
334-
SDKRootDir = A->getValue();
335-
if (!llvm::sys::fs::exists(SDKRootDir))
336-
D.Diag(clang::diag::warn_missing_sysroot) << SDKRootDir;
337-
Whence = A->getSpelling();
338-
} else if (const char *EnvValue = getenv(EnvVar)) {
332+
if (const char *EnvValue = getenv(EnvVar)) {
339333
SDKRootDir = EnvValue;
340-
Whence = { "environment variable '", EnvVar, "'" };
334+
Whence = {"environment variable '", EnvVar, "'"};
341335
} else {
342336
SDKRootDir = D.Dir + "/../../";
343337
Whence = "compiler's location";
344338
}
345339

346-
SmallString<512> SDKIncludeDir(SDKRootDir);
347-
llvm::sys::path::append(SDKIncludeDir, "target/include");
348-
if (!Args.hasArg(options::OPT_nostdinc) &&
349-
!Args.hasArg(options::OPT_nostdlibinc) &&
350-
!Args.hasArg(options::OPT_isysroot) &&
351-
!Args.hasArg(options::OPT__sysroot_EQ) &&
352-
!llvm::sys::fs::exists(SDKIncludeDir)) {
353-
D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
354-
<< Twine(Platform, " system headers").str() << SDKIncludeDir << Whence;
355-
}
340+
// Allow --sysroot= to override the root directory for header and library
341+
// search, and -sysroot to override header search. If both are specified,
342+
// -isysroot overrides --sysroot for header search.
343+
auto OverrideRoot = [&](const options::ID &Opt, std::string &Root,
344+
StringRef Default) {
345+
if (const Arg *A = Args.getLastArg(Opt)) {
346+
Root = A->getValue();
347+
if (!llvm::sys::fs::exists(Root))
348+
D.Diag(clang::diag::warn_missing_sysroot) << Root;
349+
return true;
350+
}
351+
Root = Default.str();
352+
return false;
353+
};
356354

357-
SmallString<512> SDKLibDir(SDKRootDir);
358-
llvm::sys::path::append(SDKLibDir, "target/lib");
359-
if (!Args.hasArg(options::OPT__sysroot_EQ) && !Args.hasArg(options::OPT_E) &&
360-
!Args.hasArg(options::OPT_c) && !Args.hasArg(options::OPT_S) &&
361-
!Args.hasArg(options::OPT_emit_ast) &&
362-
!llvm::sys::fs::exists(SDKLibDir)) {
355+
bool CustomSysroot =
356+
OverrideRoot(options::OPT__sysroot_EQ, SDKLibraryRootDir, SDKRootDir);
357+
bool CustomISysroot =
358+
OverrideRoot(options::OPT_isysroot, SDKHeaderRootDir, SDKLibraryRootDir);
359+
360+
// Emit warnings if parts of the SDK are missing, unless the user has taken
361+
// control of header or library search. If we're not linking, don't check
362+
// for missing libraries.
363+
auto CheckSDKPartExists = [&](StringRef Dir, StringRef Desc) {
364+
if (llvm::sys::fs::exists(Dir))
365+
return true;
363366
D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
364-
<< Twine(Platform, " system libraries").str() << SDKLibDir << Whence;
365-
return;
367+
<< (Twine(Platform) + " " + Desc).str() << Dir << Whence;
368+
return false;
369+
};
370+
371+
bool Linking = !Args.hasArg(options::OPT_E, options::OPT_c, options::OPT_S,
372+
options::OPT_emit_ast);
373+
if (!CustomSysroot && Linking) {
374+
SmallString<128> Dir(SDKLibraryRootDir);
375+
llvm::sys::path::append(Dir, "target/lib");
376+
if (CheckSDKPartExists(Dir, "system libraries"))
377+
getFilePaths().push_back(std::string(Dir));
378+
}
379+
if (!CustomSysroot && !CustomISysroot &&
380+
!Args.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc)) {
381+
SmallString<128> Dir(SDKHeaderRootDir);
382+
llvm::sys::path::append(Dir, "target/include");
383+
CheckSDKPartExists(Dir, "system headers");
366384
}
367-
getFilePaths().push_back(std::string(SDKLibDir));
368385
}
369386

370387
void toolchains::PS4PS5Base::AddClangSystemIncludeArgs(
@@ -385,9 +402,9 @@ void toolchains::PS4PS5Base::AddClangSystemIncludeArgs(
385402
return;
386403

387404
addExternCSystemInclude(DriverArgs, CC1Args,
388-
SDKRootDir + "/target/include");
405+
SDKHeaderRootDir + "/target/include");
389406
addExternCSystemInclude(DriverArgs, CC1Args,
390-
SDKRootDir + "/target/include_common");
407+
SDKHeaderRootDir + "/target/include_common");
391408
}
392409

393410
Tool *toolchains::PS4CPU::buildAssembler() const {

clang/lib/Driver/ToolChains/PS4CPU.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,12 @@ class LLVM_LIBRARY_VISIBILITY PS4PS5Base : public Generic_ELF {
128128
const char *Suffix) const = 0;
129129
virtual const char *getProfileRTLibName() const = 0;
130130

131+
StringRef getSDKLibraryRootDir() const { return SDKLibraryRootDir; }
132+
131133
private:
132-
// We compute the SDK root dir in the ctor, and use it later.
133-
std::string SDKRootDir;
134+
// We compute the SDK locations in the ctor, and use them later.
135+
std::string SDKHeaderRootDir;
136+
std::string SDKLibraryRootDir;
134137
};
135138

136139
// PS4-specific Toolchain class.

clang/test/Driver/ps4-linker.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@
2828

2929
// RUN: %clang --target=x86_64-scei-ps4 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-LTO %s
3030
// CHECK-NO-LTO-NOT: -lto-debug-options
31+
32+
// Test the driver passes a sysroot to the linker. Without --sysroot, its value
33+
// is sourced from the SDK environment variable.
34+
35+
// RUN: env SCE_ORBIS_SDK_DIR=mysdk %clang --target=x64_64-scei-ps4 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s
36+
// RUN: env SCE_ORBIS_SDK_DIR=other %clang --target=x64_64-scei-ps4 %s -### --sysroot=mysdk 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s
37+
38+
// CHECK-SYSROOT: {{ld(\.exe)?}}"
39+
// CHECK-SYSROOT-SAME: "--sysroot=mysdk"

clang/test/Driver/ps4-ps5-header-search.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// PS4 and PS5 use the same SDK layout, so use the same tree for both.
2-
// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
3-
// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-sie-ps5 --sysroot="" -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
2+
// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
3+
// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-sie-ps5 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
44
// ENVPS4: Inputs/scei-ps4_tree/target/include
55
// ENVPS4: Inputs/scei-ps4_tree/target/include_common
66
// ENVPS4-NOT: /usr/include

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

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,67 @@
1-
// Check that PS4 clang doesn't report a warning message when locating
2-
// system header files (either by looking at the value of SCE_ORBIS_SDK_DIR
3-
// or relative to the location of the compiler driver), if "-nostdinc",
4-
// "--sysroot" or "-isysroot" option is specified on the command line.
5-
// Otherwise, check that PS4 clang reports a warning.
6-
7-
// Check that PS4 clang doesn't report a warning message when locating
8-
// 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-
// or "--sysroot" option is specified on the command line.
11-
// Otherwise, check that PS4 clang reports a warning.
12-
13-
// Setting up SCE_ORBIS_SDK_DIR to existing location, which is not a PS4 SDK.
14-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
15-
16-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
17-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
18-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
19-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
20-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
21-
22-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
23-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
24-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
25-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
26-
27-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
28-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
29-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
30-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
31-
32-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
33-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
34-
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
35-
// 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
36-
// 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
1+
/// 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.
4+
///
5+
/// 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.
8+
///
9+
/// Warnings are emitted if a specified `-isysroot` or `--sysroot` does not
10+
/// exist.
11+
///
12+
/// The default <SDKROOT> for both headers and libraries is taken from the
13+
/// SCE_ORBIS_SDK_DIR environment variable.
14+
15+
// RUN: echo "-### -Winvalid-or-nonexistent-directory -target x86_64-scei-ps4" > %t.rsp
16+
17+
/// If SDK headers and/or libraries are found, associated warnings are absent.
18+
// RUN: rm -rf %t.inconly && mkdir -p %t.inconly/target/include
19+
// RUN: env SCE_ORBIS_SDK_DIR=%t.inconly %clang @%t.rsp %s 2>&1 | FileCheck -check-prefixes=WARN-SYS-LIBS,NO-WARN %s
20+
21+
// RUN: rm -rf %t.libonly && mkdir -p %t.libonly/target/lib
22+
// RUN: env SCE_ORBIS_SDK_DIR=%t.libonly %clang @%t.rsp %s 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,NO-WARN %s
23+
24+
// RUN: rm -rf %t.both && mkdir -p %t.both/target/lib && mkdir %t.both/target/include
25+
// RUN: env SCE_ORBIS_SDK_DIR=%t.both %clang @%t.rsp %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
26+
27+
/// In the following invocations, SCE_ORBIS_SDK_DIR is set to an existing
28+
/// location where SDK headers and libraries are absent.
29+
30+
/// When compiling and linking, we should see a warnings about both missing
31+
/// headers and libraries.
32+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,WARN-SYS-LIBS,NO-WARN %s
33+
34+
/// If `-c`, `-S`, `-E` or `-emit-ast` is supplied, the existence check for SDK
35+
/// libraries is skipped because no linking will be performed. We only expect
36+
/// warnings about missing headers.
37+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,NO-WARN %s
38+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -S 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,NO-WARN %s
39+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -E 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,NO-WARN %s
40+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -emit-ast 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,NO-WARN %s
41+
42+
/// If the user takes control of include paths, the existence check for headers
43+
/// is not performed.
44+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c -nostdinc 2>&1 | FileCheck -check-prefix=NO-WARN %s
45+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c -nostdlibinc 2>&1 | FileCheck -check-prefix=NO-WARN %s
46+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c -isysroot . 2>&1 | FileCheck -check-prefixes=NO-WARN %s
47+
// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c --sysroot=. 2>&1 | FileCheck -check-prefixes=NO-WARN %s
48+
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
51+
52+
/// -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
55+
56+
/// 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
3760

3861
// NO-WARN-NOT: {{warning:|error:}}
39-
// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory
40-
// WARN-ISYSROOT: warning: no such sysroot directory: 'foo'
4162
// WARN-SYS-LIBS: warning: unable to find PS4 system libraries directory
63+
// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory
64+
// WARN-SYSROOT: warning: no such sysroot directory: 'foo'
65+
// WARN-SYSROOT2: warning: no such sysroot directory: 'bar'
4266
// NO-WARN-NOT: {{warning:|error:}}
67+
// ISYSTEM: "-cc1"{{.*}}"-internal-externc-isystem" "./target/include"

clang/test/Driver/ps5-linker.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@
3737
// RUN: %clang --target=x86_64-sie-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG %s
3838

3939
// CHECK-DIAG: -plugin-opt=-crash-diagnostics-dir=mydumps
40+
41+
// Test the driver passes a sysroot to the linker. Without --sysroot, its value
42+
// is sourced from the SDK environment variable.
43+
44+
// RUN: env SCE_PROSPERO_SDK_DIR=mysdk %clang --target=x64_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s
45+
// RUN: env SCE_PROSPERO_SDK_DIR=other %clang --target=x64_64-sie-ps5 %s -### --sysroot=mysdk 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s
46+
47+
// CHECK-SYSROOT: {{ld(\.exe)?}}"
48+
// CHECK-SYSROOT-SAME: "--sysroot=mysdk"

0 commit comments

Comments
 (0)