From faea1fc77e9e6c59740747f7652ac7b5b8bbd755 Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Wed, 13 Mar 2024 21:20:38 +0530 Subject: [PATCH] Android: add the stdlib RPATH when natively building on Android with Termux This is the equivalent of the already-merged C++ Driver change in apple/swift#69538. --- .../Jobs/GenericUnixToolchain+LinkerSupport.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift index 1fcf6f362..3bf9bc323 100644 --- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift +++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift @@ -173,8 +173,16 @@ extension GenericUnixToolchain { isShared: hasRuntimeArgs ) - if hasRuntimeArgs && targetTriple.environment != .android && - toolchainStdlibRpath { + // An exception is made for native Android environments like the Termux + // app as they build and run natively like a Unix environment on Android, + // so add the stdlib RPATH by default there. + #if os(Android) + let addRpath = true + #else + let addRpath = targetTriple.environment != .android + #endif + + if hasRuntimeArgs && addRpath && toolchainStdlibRpath { // FIXME: We probably shouldn't be adding an rpath here unless we know // ahead of time the standard library won't be copied. for path in runtimePaths {