Skip to content

Commit 0994fba

Browse files
navytuxmdavidsaver
authored andcommitted
Do not escape $ORIGIN at least on Android
Commit a83de88 ($ORIGIN escaping, 2018) added \$ORIGIN/... to built DSO/Extension with the reason that # Some versions of GCC will expand shell macros _internally_ when # passing arguments to 'ld', and need '\$ORIGIN'. And some versions don't, # and fail with '\$ORIGIN'. # Presumably this was a bug in gcc-wrapper which was fixed at some point. # # So what to do? # For lack of a better idea, give both versions and hope that the non-functional # one is really non-functional. That does not create issues on regular Linux, but on Android it leads to the following warnings issued by system dynamic linker: ((1.venv) ) poco:~/setuptools_dso/example/src$ python -m dsodemo.cli WARNING: linker: Warning: unable to normalize "\/data/data/com.termux/files/home/setuptools_dso/example/src/dsodemo/ext/../lib" (ignoring) WARNING: linker: Warning: unable to normalize "\/data/data/com.termux/files/home/setuptools_dso/example/src/dsodemo/ext/../lib" (ignoring) From foo.c From bar.cpp I would say the proper fix would be to drop that $ORIGIN escaping completely, but trying to preserve backward compatibility we can leave it on applied only selectively if the linker is indeed GCC. This fixes the issue on Android/Termux because there the compiler is CLang. After this patch the warnings are gone: ((1.venv) ) poco:~/setuptools_dso/example/src$ python -m dsodemo.cli From foo.c From bar.cpp /cc @mdavidsaver
1 parent e07b12f commit 0994fba

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/setuptools_dso/dsocmd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def dso2lib_pre(self, ext):
283283
# For lack of a better idea, give both versions and hope that the non-functional
284284
# one is really non-functional.
285285
soargs.add('-Wl,-rpath,$ORIGIN/%s'%os.path.relpath(dsopath, mypath))
286-
soargs.add(r'-Wl,-rpath,\$ORIGIN/%s'%os.path.relpath(dsopath, mypath))
286+
if 'gcc' in self.compiler.linker_so[0]:
287+
soargs.add(r'-Wl,-rpath,\$ORIGIN/%s'%os.path.relpath(dsopath, mypath))
287288

288289
# Do not append to extisting list as it may be shared
289290
# between multiple extensions

0 commit comments

Comments
 (0)