@@ -97,9 +97,9 @@ std::string Linux::getMultiarchTriple(const Driver &D,
97
97
case llvm::Triple::mips64: {
98
98
std::string MT = std::string (IsMipsR6 ? " mipsisa64r6" : " mips64" ) +
99
99
" -linux-" + (IsMipsN32Abi ? " gnuabin32" : " gnuabi64" );
100
- if (D.getVFS ().exists (SysRoot + " /lib/ " + MT ))
100
+ if (D.getVFS ().exists (concat ( SysRoot, " /lib" , MT) ))
101
101
return MT;
102
- if (D.getVFS ().exists (SysRoot + " /lib/mips64-linux-gnu" ))
102
+ if (D.getVFS ().exists (concat ( SysRoot, " /lib/mips64-linux-gnu" ) ))
103
103
return " mips64-linux-gnu" ;
104
104
break ;
105
105
}
@@ -108,14 +108,14 @@ std::string Linux::getMultiarchTriple(const Driver &D,
108
108
return " mips64el-linux-android" ;
109
109
std::string MT = std::string (IsMipsR6 ? " mipsisa64r6el" : " mips64el" ) +
110
110
" -linux-" + (IsMipsN32Abi ? " gnuabin32" : " gnuabi64" );
111
- if (D.getVFS ().exists (SysRoot + " /lib/ " + MT ))
111
+ if (D.getVFS ().exists (concat ( SysRoot, " /lib" , MT) ))
112
112
return MT;
113
- if (D.getVFS ().exists (SysRoot + " /lib/mips64el-linux-gnu" ))
113
+ if (D.getVFS ().exists (concat ( SysRoot, " /lib/mips64el-linux-gnu" ) ))
114
114
return " mips64el-linux-gnu" ;
115
115
break ;
116
116
}
117
117
case llvm::Triple::ppc:
118
- if (D.getVFS ().exists (SysRoot + " /lib/powerpc-linux-gnuspe" ))
118
+ if (D.getVFS ().exists (concat ( SysRoot, " /lib/powerpc-linux-gnuspe" ) ))
119
119
return " powerpc-linux-gnuspe" ;
120
120
return " powerpc-linux-gnu" ;
121
121
case llvm::Triple::ppcle:
@@ -263,8 +263,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
263
263
264
264
Generic_GCC::AddMultilibPaths (D, SysRoot, OSLibDir, MultiarchTriple, Paths);
265
265
266
- addPathIfExists (D, SysRoot + " /lib/ " + MultiarchTriple, Paths);
267
- addPathIfExists (D, SysRoot + " /lib/../ " + OSLibDir, Paths);
266
+ addPathIfExists (D, concat ( SysRoot, " /lib" , MultiarchTriple) , Paths);
267
+ addPathIfExists (D, concat ( SysRoot, " /lib/.." , OSLibDir) , Paths);
268
268
269
269
if (IsAndroid) {
270
270
// Android sysroots contain a library directory for each supported OS
@@ -275,24 +275,24 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
275
275
unsigned Micro;
276
276
Triple.getEnvironmentVersion (Major, Minor, Micro);
277
277
addPathIfExists (D,
278
- SysRoot + " /usr/lib/ " + MultiarchTriple + " / " +
279
- llvm::to_string (Major),
278
+ concat ( SysRoot, " /usr/lib" , MultiarchTriple,
279
+ llvm::to_string (Major)) ,
280
280
Paths);
281
281
}
282
282
283
- addPathIfExists (D, SysRoot + " /usr/lib/ " + MultiarchTriple, Paths);
283
+ addPathIfExists (D, concat ( SysRoot, " /usr/lib" , MultiarchTriple) , Paths);
284
284
// 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot
285
285
// find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle
286
286
// this here.
287
287
if (Triple.getVendor () == llvm::Triple::OpenEmbedded &&
288
288
Triple.isArch64Bit ())
289
- addPathIfExists (D, SysRoot + " /usr/ " + OSLibDir, Paths);
289
+ addPathIfExists (D, concat ( SysRoot, " /usr" , OSLibDir) , Paths);
290
290
else
291
- addPathIfExists (D, SysRoot + " /usr/lib/../ " + OSLibDir, Paths);
291
+ addPathIfExists (D, concat ( SysRoot, " /usr/lib/.." , OSLibDir) , Paths);
292
292
if (IsRISCV) {
293
293
StringRef ABIName = tools::riscv::getRISCVABI (Args, Triple);
294
- addPathIfExists (D, SysRoot + " /" + OSLibDir + " / " + ABIName, Paths);
295
- addPathIfExists (D, SysRoot + " /usr/ " + OSLibDir + " / " + ABIName, Paths);
294
+ addPathIfExists (D, concat ( SysRoot, " /" , OSLibDir, ABIName) , Paths);
295
+ addPathIfExists (D, concat ( SysRoot, " /usr" , OSLibDir, ABIName) , Paths);
296
296
}
297
297
298
298
Generic_GCC::AddMultiarchPaths (D, SysRoot, OSLibDir, Paths);
@@ -310,8 +310,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
310
310
addPathIfExists (D, D.Dir + " /../" + OSLibDir, Paths);
311
311
}
312
312
313
- addPathIfExists (D, SysRoot + " /lib" , Paths);
314
- addPathIfExists (D, SysRoot + " /usr/lib" , Paths);
313
+ addPathIfExists (D, concat ( SysRoot, " /lib" ) , Paths);
314
+ addPathIfExists (D, concat ( SysRoot, " /usr/lib" ) , Paths);
315
315
}
316
316
317
317
ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType () const {
@@ -555,7 +555,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
555
555
return ;
556
556
557
557
// LOCAL_INCLUDE_DIR
558
- addSystemInclude (DriverArgs, CC1Args, SysRoot + " /usr/local/include" );
558
+ addSystemInclude (DriverArgs, CC1Args, concat ( SysRoot, " /usr/local/include" ) );
559
559
// TOOL_INCLUDE_DIR
560
560
AddMultilibIncludeArgs (DriverArgs, CC1Args);
561
561
@@ -576,19 +576,20 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
576
576
// /usr/include.
577
577
std::string MultiarchIncludeDir = getMultiarchTriple (D, getTriple (), SysRoot);
578
578
if (!MultiarchIncludeDir.empty () &&
579
- D.getVFS ().exists (SysRoot + " /usr/include/" + MultiarchIncludeDir))
580
- addExternCSystemInclude (DriverArgs, CC1Args,
581
- SysRoot + " /usr/include/" + MultiarchIncludeDir);
579
+ D.getVFS ().exists (concat (SysRoot, " /usr/include" , MultiarchIncludeDir)))
580
+ addExternCSystemInclude (
581
+ DriverArgs, CC1Args,
582
+ concat (SysRoot, " /usr/include" , MultiarchIncludeDir));
582
583
583
584
if (getTriple ().getOS () == llvm::Triple::RTEMS)
584
585
return ;
585
586
586
587
// Add an include of '/include' directly. This isn't provided by default by
587
588
// system GCCs, but is often used with cross-compiling GCCs, and harmless to
588
589
// add even when Clang is acting as-if it were a system compiler.
589
- addExternCSystemInclude (DriverArgs, CC1Args, SysRoot + " /include" );
590
+ addExternCSystemInclude (DriverArgs, CC1Args, concat ( SysRoot, " /include" ) );
590
591
591
- addExternCSystemInclude (DriverArgs, CC1Args, SysRoot + " /usr/include" );
592
+ addExternCSystemInclude (DriverArgs, CC1Args, concat ( SysRoot, " /usr/include" ) );
592
593
593
594
if (!DriverArgs.hasArg (options::OPT_nobuiltininc) && getTriple ().isMusl ())
594
595
addSystemInclude (DriverArgs, CC1Args, ResourceDirInclude);
0 commit comments