From 4c589549678d7542f0cc12c812580ab449d474ac Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Wed, 4 Aug 2021 21:16:16 +0700 Subject: [PATCH] [K/N] Don't perform --gc-sections when producing DLL Due to a bug, lld-link might be a bit too aggressive. Let's disable --gc-sections for DLL until we update LLD. Patches: https://reviews.llvm.org/D101522 https://reviews.llvm.org/D101615 https://reviews.llvm.org/D102138 --- .../kotlin/org/jetbrains/kotlin/konan/target/Linker.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 e91e7e1e2b8..b589587b453 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 @@ -466,7 +466,13 @@ class MingwLinker(targetProperties: MingwConfigurables) // --gc-sections flag may affect profiling. // See https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#drawbacks-and-limitations. // TODO: switching to lld may help. - if (optimize && !needsProfileLibrary) +linkerOptimizationFlags + if (optimize && !needsProfileLibrary) { + // TODO: Can be removed after LLD update. + // See KT-48085. + if (!dynamic) { + +linkerOptimizationFlags + } + } if (!debug) +linkerNoDebugFlags if (dynamic) +linkerDynamicFlags +libraries