Skip to content

Commit b60d931

Browse files
authored
Link libstdc++ dynamically on linux (#1133)
[SKIKO-1069](https://youtrack.jetbrains.com/issue/SKIKO-1069) [libstdc++.so.6+0xdf9b4] std::__codecvt_utf8_utf16_base::do_unshift It introduces symbol references to `GLIBCXX_3.4.22` (GCC 6.1.0 per [doc](https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html)), which should be fine Binary size of binary is reduced by ~3MB
1 parent 723f52d commit b60d931

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

skiko/buildSrc/src/main/kotlin/tasks/configuration/JvmTasksConfiguration.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,14 @@ fun SkikoProjectContext.createLinkJvmBindings(
273273
OS.Linux -> {
274274
osFlags = arrayOf(
275275
"-shared",
276-
"-static-libstdc++",
276+
// `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+,
277+
// so do not use `-static-libstdc++` to avoid issues with complex setup.
277278
"-static-libgcc",
278279
"-lGL",
279280
"-lX11",
280281
"-lfontconfig",
281-
// A fix for https://github.com/JetBrains/compose-jb/issues/413.
282-
// Dynamic position independent linking uses PLT thunks relying on jump targets in GOT (Global Offsets Table).
283-
// GOT entries marked as (for example) R_X86_64_JUMP_SLOT in the relocation table. So, if there's code loading
284-
// platform libstdc++.so, lazy resolve code will resolve GOT entries to platform libstdc++.so on first invocation,
285-
// and so further execution will break, as those two libstdc++ are not compatible.
286-
// To fix it we enforce resolve of all GOT entries at library load time, and make it read-only afterwards.
282+
// Enforce immediate symbol resolution at library load time to prevent
283+
// lazy-binding issues and make GOT read-only afterwards.
287284
"-Wl,-z,relro,-z,now",
288285
// Hack to fix problem with linker not always finding certain declarations.
289286
"$skiaBinDir/libsksg.a",

0 commit comments

Comments
 (0)