Skip to content

Do not escape $ORIGIN at least on Android#44

Merged
mdavidsaver merged 1 commit intoepics-base:masterfrom
navytux:y/ORIGIN-no-escape
Mar 2, 2026
Merged

Do not escape $ORIGIN at least on Android#44
mdavidsaver merged 1 commit intoepics-base:masterfrom
navytux:y/ORIGIN-no-escape

Conversation

@navytux
Copy link
Contributor

@navytux navytux commented Mar 2, 2026

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

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
Copy link
Member

@mdavidsaver mdavidsaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a reasonable way to handle a situation which should be increasingly historical.

@mdavidsaver mdavidsaver merged commit 0994fba into epics-base:master Mar 2, 2026
52 checks passed
@navytux navytux deleted the y/ORIGIN-no-escape branch March 3, 2026 06:38
@navytux
Copy link
Contributor Author

navytux commented Mar 3, 2026

Thanks, Michael.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants