From 118889add5d73d6cf40b73db93629441d1e77644 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Mon, 12 Jul 2021 13:45:26 +0700 Subject: [PATCH] [K/N] Fix mingw_x86 compilation It was broken in 9ed97a27f1ce0701bcddfd66109cfc7896c058fc. --- kotlin-native/konan/konan.properties | 2 +- .../kotlin/org/jetbrains/kotlin/konan/target/Linker.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kotlin-native/konan/konan.properties b/kotlin-native/konan/konan.properties index 014a00d01c5..b6145489289 100644 --- a/kotlin-native/konan/konan.properties +++ b/kotlin-native/konan/konan.properties @@ -928,7 +928,7 @@ linkerDynamicFlags.mingw_x86 = -shared linkerKonanFlags.mingw_x86 = -static-libgcc -static-libstdc++ \ -Wl,--dynamicbase \ -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic \ - -Wl,--defsym,__cxa_demangle=Konan_cxa_demangle + -Wl,--defsym,__cxa_demangle=_Konan_cxa_demangle mimallocLinkerDependencies.mingw_x86 = -lbcrypt linkerOptimizationFlags.mingw_x86 = -Wl,--gc-sections runtimeDefinitions.mingw_x86 = USE_GCC_UNWIND=1 USE_PE_COFF_SYMBOLS=1 KONAN_WINDOWS=1 \ diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt index 37247e0e099..b340d2cf40d 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt @@ -480,11 +480,16 @@ class MingwLinker(targetProperties: MingwConfigurables) if (HostManager.hostIsMingw) { lldCompatibilityChecker?.let { checkLldCompatibiity -> // -### flag allows to avoid actual linkage process. + val konanCxaDemangleSymbol = when (target) { + KonanTarget.MINGW_X64 -> "Konan_cxa_demangle" + KonanTarget.MINGW_X86 -> "_Konan_cxa_demangle" + else -> error("Unexpected target: $target") + } val lldCommand = Command(linker).constructLinkerArguments( // Add -fuse-ld to the end of the list to override previous appearances. additionalArguments = listOf("-fuse-ld=$absoluteLldLocation", "-Wl,-###"), // LLD doesn't support defsym. - skipDefaultArguments = listOf("-Wl,--defsym,__cxa_demangle=Konan_cxa_demangle") + skipDefaultArguments = listOf("-Wl,--defsym,__cxa_demangle=$konanCxaDemangleSymbol") ) checkLldCompatibiity(lldCommand) }