Skip to content

RPATHs of grafted libraries should ALWAYS be overridden to $ORIGIN #617

@VinayVi

Description

@VinayVi

I just ran into a weird edge case. I have a library which was built on another machine, and has a single entry for its rpath: /path/that/only/exists/on/other/machine/. I'm using this on my machine and I can get this library to function because I have the LD_LIBRARY_PATH environment variable set to the proper paths.

What I noticed though is that when this library gets grafted into the wheel, we run through this codepath:

    if any(itertools.chain(rpaths["rpaths"], rpaths["runpaths"])):
        patcher.set_rpath(dest_path, "$ORIGIN")

The rpaths dictionary is setup so that it parses out any RPATH entries that don't exist on the current machine, so at the time this code is executed, the if statement is false the RPATH is never forced to $ORIGIN.

I think this logic should change to one of the following:

  1. Always set rpath to $ORIGIN; get rid of the if check here. If a library has no dependencies, then this is safe because no dependencies are loaded. If the library does have dependencies, then it should be getting it from the current flattened directory anyways. I think this is what we should do.

  2. If we don't want to do that, then we should check if it has anything in the rpath or runpath entries, without checking if that directory exists first.

I think getting rid of the if statement is the easiest way to fix this edge case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions