Builds on Darwin (MacOS) create .a files containing debug symbols
for certain shared objects. By default, they are referenced with
absolute paths, which makes the binary non-portable for debugging.
Generally this is resolved by rewriting to relative paths.
Passing -oso_prefix . to the linker results in all paths
prefixed with the current directory being rewritten to be
relative. Similarly, using -oso_prefix /a/b/ will remove
the prefix /a/b/ from matching paths, making them relative.
(Note: that trailing prefix is important! It is a literal
match, not a semantic one. Leaving it off will result in
incorrect absolute paths.)
PatchOSO was made for more powerful substitutions. It can rewrite any prefix to any other prefix, and can perform multiple substitutions in one invocation. It also operates semantically, so trailing slashes are irrelevant.
It was made in particular for Nix builds, which are performed in sandboxed temporary directories (thus making absolute paths useless once the build completes). Instead, files with extra symbols can be exported to another output depended on by the binary, which is thus guaranteed to exist wherever the binary exists.
Run uv run main.py --help for usage.