Skip to content

Commit e900d68

Browse files
committed
Add -fPIC flag to fix relocation error
Fix "relocation R_386_GOTOFF" type errors on x86
1 parent 5bd1465 commit e900d68

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

pythonforandroid/recipes/Pillow/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
4545
cflags += ' -I{}'.format(free_inc_dir)
4646
cflags += ' -I{}'.format(jpeg_inc_dir)
4747
cflags += ' -I{}'.format(ndk_include_dir)
48+
cflags += ' -fPIC'
4849

4950
env['LIBS'] = ' -lpng -lfreetype -lharfbuzz -ljpeg -lturbojpeg'
5051

pythonforandroid/recipes/android/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe):
1919
def get_recipe_env(self, arch):
2020
env = super().get_recipe_env(arch)
2121
env.update(self.config_env)
22+
23+
cflags = " -fPIC"
24+
25+
if cflags not in env["CFLAGS"]:
26+
env["CFLAGS"] += cflags
27+
2228
return env
2329

2430
def prebuild_arch(self, arch):

pythonforandroid/recipes/kivy/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def get_recipe_env(self, arch):
4949
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
5050
])
5151

52+
cflags = " -fPIC"
53+
54+
if cflags not in env["CFLAGS"]:
55+
env["CFLAGS"] += cflags
56+
5257
return env
5358

5459

pythonforandroid/recipes/pyjnius/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ class PyjniusRecipe(CythonRecipe):
1717
patches = [('sdl2_jnienv_getter.patch', will_build('sdl2')),
1818
('genericndkbuild_jnienv_getter.patch', will_build('genericndkbuild'))]
1919

20+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
21+
env = super().get_recipe_env(arch, with_flags_in_cc)
22+
23+
cflags = " -fPIC"
24+
25+
if cflags not in env["CFLAGS"]:
26+
env["CFLAGS"] += cflags
27+
28+
return env
29+
2030
def postbuild_arch(self, arch):
2131
super().postbuild_arch(arch)
2232
info('Copying pyjnius java class to classes build dir')

0 commit comments

Comments
 (0)