Skip to content

Commit 014afb6

Browse files
authored
Remove code for automatically adding archive indexes (#21121)
Now that wasm-ld no longer requires and index this code is no longer needed.
1 parent 9f9d615 commit 014afb6

File tree

4 files changed

+2
-73
lines changed

4 files changed

+2
-73
lines changed

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,6 @@ Changes enabled by this:
14671467
- IGNORE_MISSING_MAIN is disabled.
14681468
- AUTO_JS_LIBRARIES is disabled.
14691469
- AUTO_NATIVE_LIBRARIES is disabled.
1470-
- AUTO_ARCHIVE_INDEXES is disabled.
14711470
- DEFAULT_TO_CXX is disabled.
14721471
- USE_GLFW is set to 0 rather than 2 by default.
14731472
- ALLOW_UNIMPLEMENTED_SYSCALLS is disabled.
@@ -1485,16 +1484,6 @@ If this is disabled then one must provide a ``main`` symbol or explicitly
14851484
opt out by passing ``--no-entry`` or an EXPORTED_FUNCTIONS list that doesn't
14861485
include ``_main``.
14871486

1488-
.. _auto_archive_indexes:
1489-
1490-
AUTO_ARCHIVE_INDEXES
1491-
====================
1492-
1493-
Automatically attempt to add archive indexes at link time to archives that
1494-
don't already have them. This can happen when GNU ar or GNU ranlib is used
1495-
rather than ``llvm-ar`` or ``emar`` since the former don't understand the wasm
1496-
object format.
1497-
14981487
.. _strict_js:
14991488

15001489
STRICT_JS

src/settings.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ var LINKABLE = false;
11531153
// - IGNORE_MISSING_MAIN is disabled.
11541154
// - AUTO_JS_LIBRARIES is disabled.
11551155
// - AUTO_NATIVE_LIBRARIES is disabled.
1156-
// - AUTO_ARCHIVE_INDEXES is disabled.
11571156
// - DEFAULT_TO_CXX is disabled.
11581157
// - USE_GLFW is set to 0 rather than 2 by default.
11591158
// - ALLOW_UNIMPLEMENTED_SYSCALLS is disabled.
@@ -1168,13 +1167,6 @@ var STRICT = false;
11681167
// [link]
11691168
var IGNORE_MISSING_MAIN = true;
11701169

1171-
// Automatically attempt to add archive indexes at link time to archives that
1172-
// don't already have them. This can happen when GNU ar or GNU ranlib is used
1173-
// rather than ``llvm-ar`` or ``emar`` since the former don't understand the wasm
1174-
// object format.
1175-
// [link]
1176-
var AUTO_ARCHIVE_INDEXES = true;
1177-
11781170
// Add ``"use strict;"`` to generated JS
11791171
// [link]
11801172
var STRICT_JS = false;
@@ -2188,4 +2180,5 @@ var LEGACY_SETTINGS = [
21882180
['MIN_EDGE_VERSION', [0x7FFFFFFF], 'No longer supported'],
21892181
['MIN_IE_VERSION', [0x7FFFFFFF], 'No longer supported'],
21902182
['WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG', [0], 'No longer supported'],
2183+
['AUTO_ARCHIVE_INDEXES', [0, 1], 'No longer needed'],
21912184
];

test/test_other.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9121,22 +9121,6 @@ def test_response_file_bom(self):
91219121
create_file('test.rsp', b'\xef\xbb\xbf--version', binary=True)
91229122
self.run_process([EMCC, '@test.rsp'])
91239123

9124-
def test_archive_empty(self):
9125-
# This test added because we had an issue with the AUTO_ARCHIVE_INDEXES failing on empty
9126-
# archives (which inherently don't have indexes).
9127-
self.run_process([EMAR, 'crS', 'libfoo.a'])
9128-
self.run_process([EMCC, '-Werror', 'libfoo.a', test_file('hello_world.c')])
9129-
9130-
def test_archive_no_index(self):
9131-
create_file('foo.c', 'int foo = 1;')
9132-
self.run_process([EMCC, '-c', 'foo.c'])
9133-
self.run_process([EMCC, '-c', test_file('hello_world.c')])
9134-
# The `S` flag means don't add an archive index
9135-
self.run_process([EMAR, 'crS', 'libfoo.a', 'foo.o'])
9136-
# wasm-ld supports archive files without an index (unlike GNU ld) as of
9137-
# https://github.com/llvm/llvm-project/pull/78821
9138-
self.run_process([EMCC, 'libfoo.a', 'hello_world.o'])
9139-
91409124
def test_archive_non_objects(self):
91419125
create_file('file.txt', 'test file')
91429126
self.run_process([EMCC, '-c', test_file('hello_world.c')])

tools/link.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from . import webassembly
3636
from .utils import read_file, read_binary, write_file, delete_file
3737
from .utils import removeprefix, exit_with_error
38-
from .shared import in_temp, safe_copy, do_replace, run_process, OFormat
38+
from .shared import in_temp, safe_copy, do_replace, OFormat
3939
from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS, STATICLIB_ENDINGS
4040
from .shared import unsuffixed, unsuffixed_basename, get_file_suffix
4141
from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS
@@ -201,38 +201,6 @@ def embed_memfile(options):
201201
not settings.GENERATE_SOURCE_MAP)))
202202

203203

204-
def is_ar_file_with_missing_index(archive_file):
205-
# We parse the archive header outselves because llvm-nm --print-armap is slower and less
206-
# reliable.
207-
# See: https://github.com/emscripten-core/emscripten/issues/10195
208-
archive_header = b'!<arch>\n'
209-
file_header_size = 60
210-
211-
with open(archive_file, 'rb') as f:
212-
header = f.read(len(archive_header))
213-
if header != archive_header:
214-
# This is not even an ar file
215-
return False
216-
file_header = f.read(file_header_size)
217-
if len(file_header) != file_header_size:
218-
# We don't have any file entires at all so we don't consider the index missing
219-
return False
220-
221-
name = file_header[:16].strip()
222-
# If '/' is the name of the first file we have an index
223-
return name != b'/'
224-
225-
226-
def ensure_archive_index(archive_file):
227-
# Fastcomp linking works without archive indexes.
228-
if not settings.AUTO_ARCHIVE_INDEXES:
229-
return
230-
if is_ar_file_with_missing_index(archive_file):
231-
diagnostics.warning('emcc', '%s: archive is missing an index; Use emar when creating libraries to ensure an index is created', archive_file)
232-
diagnostics.warning('emcc', '%s: adding index', archive_file)
233-
run_process([shared.LLVM_RANLIB, archive_file])
234-
235-
236204
def generate_js_sym_info():
237205
# Runs the js compiler to generate a list of all symbols available in the JS
238206
# libraries. This must be done separately for each linker invokation since the
@@ -903,7 +871,6 @@ def phase_linker_setup(options, state, newargs):
903871
default_setting('DEFAULT_TO_CXX', 0)
904872
default_setting('AUTO_JS_LIBRARIES', 0)
905873
default_setting('AUTO_NATIVE_LIBRARIES', 0)
906-
default_setting('AUTO_ARCHIVE_INDEXES', 0)
907874
default_setting('IGNORE_MISSING_MAIN', 0)
908875
default_setting('ALLOW_UNIMPLEMENTED_SYSCALLS', 0)
909876
if options.oformat == OFormat.HTML and options.shell_path == DEFAULT_SHELL_HTML:
@@ -2696,10 +2663,6 @@ def process_libraries(state, linker_inputs):
26962663
settings.JS_LIBRARIES = [lib[1] for lib in settings.JS_LIBRARIES]
26972664
state.link_flags = new_flags
26982665

2699-
for _, f in linker_inputs:
2700-
if building.is_ar(f):
2701-
ensure_archive_index(f)
2702-
27032666

27042667
class ScriptSource:
27052668
def __init__(self):

0 commit comments

Comments
 (0)