Skip to content

Commit 56a92b1

Browse files
committed
Fixes gevent recipe on arm64-v8a arch
Adding `libm.so` to the `arm64-v8a` build fixes undefined reference errors. The (truncated) config.log errors were: ``` ... libpython3.7m.so: undefined reference to `hypot@LIBC' libpython3.7m.so: undefined reference to `frexp@LIBC' libpython3.7m.so: undefined reference to `cos@LIBC' libpython3.7m.so: undefined reference to `pow@LIBC' libpython3.7m.so: undefined reference to `atan2@LIBC' libpython3.7m.so: undefined reference to `modf@LIBC' libpython3.7m.so: undefined reference to `exp@LIBC' libpython3.7m.so: undefined reference to `sin@LIBC' libpython3.7m.so: undefined reference to `log@LIBC' libpython3.7m.so: undefined reference to `fmod@LIBC' clang: error: linker command failed with exit code 1 (use -v to see invocation) ... ``` Refs: kivy#1722 (comment)
1 parent 22eb6c9 commit 56a92b1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pythonforandroid/recipes/gevent/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
1313
"""
1414
- Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
1515
- Moves all -l<lib> from LDFLAGS to LIBS environment.
16+
- Copies all -l<lib> from LDLIBS to LIBS environment.
1617
- Fixes linker name (use cross compiler) and flags (appends LIBS)
1718
"""
18-
env = super(GeventRecipe, self).get_recipe_env(arch, with_flags_in_cc)
19+
env = super().get_recipe_env(arch, with_flags_in_cc)
1920
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
2021
regex = re.compile(r'(?:\s|^)-[DI][\S]+')
2122
env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip()
@@ -24,6 +25,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
2425
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS
2526
regex = re.compile(r'(?:\s|^)-l[\w\.]+')
2627
env['LIBS'] = ''.join(re.findall(regex, env['LDFLAGS'])).strip()
28+
env['LIBS'] += ' {}'.format(''.join(re.findall(regex, env['LDLIBS'])).strip())
2729
env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS'])
2830
info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS']))
2931
return env

tests/recipes/test_gevent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ def test_get_recipe_env(self):
2929
# checks the regex doesn't parse `python3-libffi-openssl` as a `-libffi`
3030
'-L/path/to/python3-libffi-openssl/library3 '
3131
)
32+
mocked_ldlibs = ' -lm'
3233
mocked_env = {
3334
'CFLAGS': mocked_cflags,
3435
'LDFLAGS': mocked_ldflags,
36+
'LDLIBS': mocked_ldlibs,
3537
}
3638
with patch('pythonforandroid.recipe.CythonRecipe.get_recipe_env') as m_get_recipe_env:
3739
m_get_recipe_env.return_value = mocked_env
@@ -53,11 +55,13 @@ def test_get_recipe_env(self):
5355
' -L/path/to/library2'
5456
' -L/path/to/python3-libffi-openssl/library3 '
5557
)
56-
expected_libs = '-lm -lpython3.7m'
58+
expected_ldlibs = mocked_ldlibs
59+
expected_libs = '-lm -lpython3.7m -lm'
5760
expected_env = {
5861
'CFLAGS': expected_cflags,
5962
'CPPFLAGS': expected_cppflags,
6063
'LDFLAGS': expected_ldflags,
64+
'LDLIBS': expected_ldlibs,
6165
'LIBS': expected_libs,
6266
}
6367
self.assertEqual(expected_env, env)

0 commit comments

Comments
 (0)