Skip to content

Commit 7f8c96a

Browse files
authored
Make emranlib actually do something (emscripten-core#9714)
In this case we simply call directly through the llvm-ranlib. I'm not sure why this was initially create empty but it can be useful to run ranlib, for example if a build system doesn't by default create a symbol index for archive files.
1 parent 12653f1 commit 7f8c96a

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

emranlib

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
#!/usr/bin/env python
2+
# Copyright 2019 The Emscripten Authors. All rights reserved.
3+
# Emscripten is available under two separate licenses, the MIT license and the
4+
# University of Illinois/NCSA Open Source License. Both these licenses can be
5+
# found in the LICENSE file.
26

3-
'''
4-
emcc - ranlib helper script
7+
8+
"""emranlib - ranlib helper script
59
===========================
610
711
This script acts as a frontend replacement for ranlib. See emcc.
8-
'''
12+
"""
13+
14+
15+
from __future__ import print_function
16+
import sys
17+
from tools import shared
18+
19+
def run():
20+
newargs = [shared.LLVM_RANLIB] + sys.argv[1:]
21+
return shared.run_process(newargs, stdin=sys.stdin, check=False).returncode
922

23+
if __name__ == '__main__':
24+
sys.exit(run())

tests/test_other.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9853,3 +9853,18 @@ def test_werror_python(self):
98539853
stderr = self.expect_fail(cmd + ['-Werror'])
98549854
self.assertContained('WARNING: not_object.bc is not a valid input file', stderr)
98559855
self.assertContained('ERROR: treating warnings as errors (-Werror)', stderr)
9856+
9857+
def test_emranlib(self):
9858+
create_test_file('foo.c', 'int foo = 1;')
9859+
create_test_file('bar.c', 'int bar = 2;')
9860+
run_process([PYTHON, EMCC, '-c', 'foo.c', 'bar.c'])
9861+
9862+
# Create a library with no archive map
9863+
run_process([PYTHON, EMAR, 'crS', 'liba.a', 'foo.o', 'bar.o'])
9864+
output = run_process([shared.LLVM_NM, '--print-armap', 'liba.a'], stdout=PIPE).stdout
9865+
self.assertNotContained('Archive map', output)
9866+
9867+
# Add an archive map
9868+
run_process([PYTHON, EMRANLIB, 'liba.a'])
9869+
output = run_process([shared.LLVM_NM, '--print-armap', 'liba.a'], stdout=PIPE).stdout
9870+
self.assertContained('Archive map', output)

tools/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def exe_suffix(cmd):
796796
CLANG = CLANG_CPP
797797
LLVM_LINK = build_llvm_tool_path(exe_suffix('llvm-link'))
798798
LLVM_AR = build_llvm_tool_path(exe_suffix('llvm-ar'))
799+
LLVM_RANLIB = build_llvm_tool_path(exe_suffix('llvm-ranlib'))
799800
LLVM_OPT = os.path.expanduser(build_llvm_tool_path(exe_suffix('opt')))
800801
LLVM_AS = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-as')))
801802
LLVM_DIS = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-dis')))

0 commit comments

Comments
 (0)