pyodide/emsdk/patches/0004-Disable-whole-archive-...

34 lines
1.2 KiB
Diff

From c250eb29047c4341cdc1d13f3706eb6991cf0f9b Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Thu, 6 Jan 2022 09:40:39 -0800
Subject: [PATCH 4/4] Disable whole-archive when linking rust
Rust .rlib archives contain an extra metadata file called lib.rmeta.
Emscripten sets `--whole-archive` by default if LINKABLE is set.
But with `--whole-archive` the linker crashes with an error due to
the extra files. This disables the problematic `--whole-archive`
setting when we are linking rust.
See emscripten issue:
https://github.com/emscripten-core/emscripten/issues/17109
---
tools/building.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/building.py b/tools/building.py
index 24ddaa13f..cb015e18f 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -360,7 +360,7 @@ def link_lld(args, target, external_symbols=None):
# Emscripten currently expects linkable output (SIDE_MODULE/MAIN_MODULE) to
# include all archive contents.
- if settings.LINKABLE:
+ if settings.LINKABLE and not any(arg.endswith(".rlib") for arg in args):
args.insert(0, '--whole-archive')
args.append('--no-whole-archive')
--
2.25.1