[K/N] Consolidate toolchain paths between platforms
The compiler had some code that looked for the same tools and files in toolchains at different relative paths depending on the platform. This commit improves that code by including `usr/` into the path to the toolchain on macOS, which allows to unify the relative paths inside the toolchains. Co-authored-by: Johan Bay <jobay@google.com>
This commit is contained in:
+1
-5
@@ -35,11 +35,7 @@ internal class BitcodeCompiler(
|
||||
.execute()
|
||||
|
||||
private fun targetTool(tool: String, vararg arg: String) {
|
||||
val absoluteToolName = if (platform.configurables is AppleConfigurables) {
|
||||
"${platform.absoluteTargetToolchain}/usr/bin/$tool"
|
||||
} else {
|
||||
"${platform.absoluteTargetToolchain}/bin/$tool"
|
||||
}
|
||||
val absoluteToolName = "${platform.absoluteTargetToolchain}/bin/$tool"
|
||||
runTool(absoluteToolName, *arg)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class AppleConfigurablesImpl(
|
||||
|
||||
override val absoluteTargetToolchain: String get() = when (val provider = xcodePartsProvider) {
|
||||
is XcodePartsProvider.Local -> provider.xcode.toolchain
|
||||
XcodePartsProvider.InternalServer -> absolute(toolchainDependency)
|
||||
XcodePartsProvider.InternalServer -> "${absolute(toolchainDependency)}/usr"
|
||||
}
|
||||
|
||||
override val absoluteAdditionalToolsDir: String get() = when (val provider = xcodePartsProvider) {
|
||||
|
||||
@@ -71,13 +71,7 @@ sealed class ClangArgs(
|
||||
return (konanOptions + otherOptions).map { "-D$it" }
|
||||
}
|
||||
|
||||
private val binDir = when (HostManager.host) {
|
||||
KonanTarget.LINUX_X64 -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MINGW_X64 -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.MACOS_ARM64 -> "$absoluteTargetToolchain/usr/bin"
|
||||
else -> throw TargetSupportException("Unexpected host platform")
|
||||
}
|
||||
private val binDir = "$absoluteTargetToolchain/bin"
|
||||
// TODO: Use buildList
|
||||
private val commonClangArgs: List<String> = mutableListOf<List<String>>().apply {
|
||||
// Currently, MinGW toolchain contains old LLVM 8, and -fuse-ld=lld picks linker from there.
|
||||
|
||||
@@ -169,13 +169,13 @@ class AndroidLinker(targetProperties: AndroidConfigurables)
|
||||
class MacOSBasedLinker(targetProperties: AppleConfigurables)
|
||||
: LinkerFlags(targetProperties), AppleConfigurables by targetProperties {
|
||||
|
||||
private val libtool = "$absoluteTargetToolchain/usr/bin/libtool"
|
||||
private val linker = "$absoluteTargetToolchain/usr/bin/ld"
|
||||
private val strip = "$absoluteTargetToolchain/usr/bin/strip"
|
||||
private val dsymutil = "$absoluteTargetToolchain/usr/bin/dsymutil"
|
||||
private val libtool = "$absoluteTargetToolchain/bin/libtool"
|
||||
private val linker = "$absoluteTargetToolchain/bin/ld"
|
||||
private val strip = "$absoluteTargetToolchain/bin/strip"
|
||||
private val dsymutil = "$absoluteTargetToolchain/bin/dsymutil"
|
||||
|
||||
private val compilerRtDir: String? by lazy {
|
||||
val dir = File("$absoluteTargetToolchain/usr/lib/clang/").listFiles.firstOrNull()?.absolutePath
|
||||
val dir = File("$absoluteTargetToolchain/lib/clang/").listFiles.firstOrNull()?.absolutePath
|
||||
if (dir != null) "$dir/lib/darwin/" else null
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ internal class CurrentXcode : Xcode {
|
||||
|
||||
override val toolchain by lazy {
|
||||
val ldPath = xcrun("-f", "ld") // = $toolchain/usr/bin/ld
|
||||
File(ldPath).parentFile.parentFile.parentFile.absolutePath
|
||||
File(ldPath).parentFile.parentFile.absolutePath
|
||||
}
|
||||
|
||||
override val additionalTools: String by lazy {
|
||||
|
||||
Reference in New Issue
Block a user