Skip to content

Commit 7712592

Browse files
committed
Replace -lgcc with -lunwind in linker argument @files. Fixes #89.
This applies the fix of #83 to linker argument @files. Linker argument files are used on (at least) Windows.
1 parent d5f693d commit 7712592

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

plugin/src/main/resources/com/nishtahir/linker-wrapper.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,30 @@
77

88
args = [os.environ['RUST_ANDROID_GRADLE_CC'], os.environ['RUST_ANDROID_GRADLE_CC_LINK_ARG']] + sys.argv[1:]
99

10-
# The `gcc` library is not included starting from NDK version 23.
11-
# Work around by using `unwind` replacement.
12-
ndk_major_version = os.environ['CARGO_NDK_MAJOR_VERSION']
13-
if ndk_major_version.isdigit():
14-
if 23 <= int(ndk_major_version):
15-
for i, arg in enumerate(args):
16-
if arg == "-lgcc":
17-
args[i] = "-lunwind"
10+
def update_in_place(arglist):
11+
# The `gcc` library is not included starting from NDK version 23.
12+
# Work around by using `unwind` replacement.
13+
ndk_major_version = os.environ['CARGO_NDK_MAJOR_VERSION']
14+
if ndk_major_version.isdigit():
15+
if 23 <= int(ndk_major_version):
16+
for i, arg in enumerate(arglist):
17+
if arg.startswith('-lgcc'):
18+
# This is one way to preserve line endings.
19+
arg[:len('-lgcc')] = '-lunwind'
20+
arglist[i] = arg
21+
22+
update_in_place(args)
23+
24+
for arg in args:
25+
if arg.startswith('@'):
26+
fileargs = open(arg[1:], 'r').read().splitlines(keepends=True)
27+
update_in_place(fileargs)
28+
open(arg[1:], 'w').write(''.join(args))
29+
30+
print('>>>')
31+
print(open(arg[1:], 'r').read())
32+
print('<<<')
33+
1834

1935
# This only appears when the subprocess call fails, but it's helpful then.
2036
printable_cmd = ' '.join(pipes.quote(arg) for arg in args)

0 commit comments

Comments
 (0)