2019-03-28 02:42:04 +01:00
|
|
|
--- tools/clang/lib/Driver/ToolChains/Linux.cpp.orig 2019-03-28 00:40:14.508554643 +0000
|
|
|
|
+++ ./tools/clang/lib/Driver/ToolChains/Linux.cpp 2019-03-28 00:46:12.983564436 +0000
|
2019-09-06 18:03:46 +02:00
|
|
|
@@ -314,6 +314,41 @@
|
2019-03-28 02:42:04 +01:00
|
|
|
|
|
|
|
const std::string OSLibDir = getOSLibDir(Triple, Args);
|
|
|
|
const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
|
2019-09-06 18:03:46 +02:00
|
|
|
+ bool NativeBuild = true;
|
|
|
|
+
|
2019-03-14 04:46:10 +01:00
|
|
|
+ if(IsAndroid) {
|
2019-09-06 18:03:46 +02:00
|
|
|
+ if (MultiarchTriple == llvm::sys::getDefaultTargetTriple())
|
2019-03-28 02:42:04 +01:00
|
|
|
+ addPathIfExists(D, SysRoot + "@TERMUX_PREFIX@/lib", Paths);
|
2019-09-06 18:03:46 +02:00
|
|
|
+ else
|
|
|
|
+ NativeBuild = false;
|
|
|
|
+
|
|
|
|
+ if (Arch == llvm::Triple::aarch64) {
|
|
|
|
+ addPathIfExists(D, SysRoot + "@TERMUX_PREFIX@/aarch64-linux-android/lib", Paths);
|
|
|
|
+ addPathIfExists(D, SysRoot + "/system/lib64", Paths);
|
|
|
|
+ if (!NativeBuild)
|
|
|
|
+ ExtraOpts.push_back("-rpath=@TERMUX_PREFIX@/aarch64-linux-android/lib");
|
2019-03-28 02:42:04 +01:00
|
|
|
+ }
|
2019-09-06 18:03:46 +02:00
|
|
|
+ else if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {
|
2019-03-16 23:43:26 +01:00
|
|
|
+ addPathIfExists(D, SysRoot + "@TERMUX_PREFIX@/arm-linux-androideabi/lib", Paths);
|
|
|
|
+ addPathIfExists(D, SysRoot + "/system/lib", Paths);
|
2019-09-06 18:03:46 +02:00
|
|
|
+ if (!NativeBuild)
|
|
|
|
+ ExtraOpts.push_back("-rpath=@TERMUX_PREFIX@/arm-linux-androideabi/lib");
|
2019-03-16 23:43:26 +01:00
|
|
|
+ }
|
2019-09-06 18:03:46 +02:00
|
|
|
+ else if (Arch == llvm::Triple::x86_64) {
|
2019-03-16 23:43:26 +01:00
|
|
|
+ addPathIfExists(D, SysRoot + "@TERMUX_PREFIX@/x86_64-linux-android/lib", Paths);
|
|
|
|
+ addPathIfExists(D, SysRoot + "/system/lib64", Paths);
|
2019-09-06 18:03:46 +02:00
|
|
|
+ if (!NativeBuild)
|
|
|
|
+ ExtraOpts.push_back("-rpath=@TERMUX_PREFIX@/x86_64-linux-android/lib");
|
2019-03-16 23:43:26 +01:00
|
|
|
+ }
|
2019-09-06 18:03:46 +02:00
|
|
|
+ else if (Arch == llvm::Triple::x86) {
|
|
|
|
+ addPathIfExists(D, SysRoot + "@TERMUX_PREFIX@/i686-linux-android/lib", Paths);
|
|
|
|
+ addPathIfExists(D, SysRoot + "/system/lib", Paths);
|
|
|
|
+ if (!NativeBuild)
|
|
|
|
+ ExtraOpts.push_back("-rpath=@TERMUX_PREFIX@/i686-linux-android/lib");
|
2019-03-16 23:43:26 +01:00
|
|
|
+ }
|
2019-09-06 18:03:46 +02:00
|
|
|
+
|
2019-03-16 23:43:26 +01:00
|
|
|
+ ExtraOpts.push_back("-rpath=@TERMUX_PREFIX@/lib");
|
2019-03-14 04:46:10 +01:00
|
|
|
+ }
|
|
|
|
|
2019-03-28 02:42:04 +01:00
|
|
|
// Add the multilib suffixed paths where they are available.
|
|
|
|
if (GCCInstallation.isValid()) {
|
|
|
|
@@ -652,8 +679,27 @@
|
2019-02-17 01:34:52 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
+ if (getTriple().isAndroid()) {
|
|
|
|
+ switch (getTriple().getArch()) {
|
|
|
|
+ case llvm::Triple::x86_64:
|
|
|
|
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "@TERMUX_PREFIX@/include/x86_64-linux-android");
|
|
|
|
+ break;
|
|
|
|
+ case llvm::Triple::x86:
|
|
|
|
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "@TERMUX_PREFIX@/include/i686-linux-android");
|
|
|
|
+ break;
|
|
|
|
+ case llvm::Triple::aarch64:
|
|
|
|
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "@TERMUX_PREFIX@/include/aarch64-linux-android");
|
|
|
|
+ break;
|
|
|
|
+ case llvm::Triple::arm:
|
|
|
|
+ case llvm::Triple::thumb:
|
|
|
|
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "@TERMUX_PREFIX@/include/arm-linux-androideabi");
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
|
|
|
|
-
|
|
|
|
+ }
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
|
|
|
SmallString<128> P(D.ResourceDir);
|
|
|
|
llvm::sys::path::append(P, "include");
|
2019-03-28 02:42:04 +01:00
|
|
|
@@ -968,7 +1014,7 @@
|
2018-03-20 23:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Linux::isPIEDefault() const {
|
|
|
|
- return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
|
2019-02-17 01:34:52 +01:00
|
|
|
+ return getTriple().isAndroid() ||
|
2018-03-20 23:10:53 +01:00
|
|
|
getTriple().isMusl() || getSanitizerArgs().requiresPIE();
|
|
|
|
}
|
|
|
|
|