Skip to content

Commit

Permalink
Add -fPIC flag to fix relocation error
Browse files Browse the repository at this point in the history
Fix "relocation R_386_GOTOFF" type errors on x86
  • Loading branch information
rdbisme committed Apr 10, 2020
1 parent 5bd1465 commit e900d68
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions pythonforandroid/recipes/Pillow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
cflags += ' -I{}'.format(free_inc_dir)
cflags += ' -I{}'.format(jpeg_inc_dir)
cflags += ' -I{}'.format(ndk_include_dir)
cflags += ' -fPIC'

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

Expand Down
6 changes: 6 additions & 0 deletions pythonforandroid/recipes/android/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe):
def get_recipe_env(self, arch):
env = super().get_recipe_env(arch)
env.update(self.config_env)

cflags = " -fPIC"

if cflags not in env["CFLAGS"]:
env["CFLAGS"] += cflags

return env

def prebuild_arch(self, arch):
Expand Down
5 changes: 5 additions & 0 deletions pythonforandroid/recipes/kivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def get_recipe_env(self, arch):
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
])

cflags = " -fPIC"

if cflags not in env["CFLAGS"]:
env["CFLAGS"] += cflags

return env


Expand Down
10 changes: 10 additions & 0 deletions pythonforandroid/recipes/pyjnius/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ class PyjniusRecipe(CythonRecipe):
patches = [('sdl2_jnienv_getter.patch', will_build('sdl2')),
('genericndkbuild_jnienv_getter.patch', will_build('genericndkbuild'))]

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super().get_recipe_env(arch, with_flags_in_cc)

cflags = " -fPIC"

if cflags not in env["CFLAGS"]:
env["CFLAGS"] += cflags

return env

def postbuild_arch(self, arch):
super().postbuild_arch(arch)
info('Copying pyjnius java class to classes build dir')
Expand Down

0 comments on commit e900d68

Please sign in to comment.