Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shrink-rpath renames global variable symbol name #169

Open
jtojnar opened this issue Apr 13, 2019 · 6 comments
Open

shrink-rpath renames global variable symbol name #169

jtojnar opened this issue Apr 13, 2019 · 6 comments
Labels

Comments

@jtojnar
Copy link
Member

jtojnar commented Apr 13, 2019

patchelf --shrink-rpath renames global variable symbol breaking DeaDBeeF’s wildmidi plug-in.

This is the variable in question:

https://github.com/DeaDBeeF-Player/deadbeef/blob/7ac83fb204fc3c8a35486ef8f9550cd98cec674e/plugins/wildmidi/src/wildmidi_lib.c#L399

Compare the patched and unpatched libraries:

$ nm -A -D -l result/wildmidi-patched.so | grep wildmidi_lib.c:399
result/wildmidi-patched.so:000000000001f2a0 B X	/build/source/plugins/wildmidi/src/wildmidi_lib.c:399
$ nm -A -D -l result/wildmidi.so | grep wildmidi_lib.c:399
result/wildmidi.so:000000000001f2a0 B b	/build/source/plugins/wildmidi/src/wildmidi_lib.c:399

Here is the reproducible:

with import <nixpkgs> { };
with pkgs;

let
  deadbeef = fetchFromGitHub {
    owner = "DeaDBeeF-Player";
    repo = "deadbeef";
    rev = "1.8.0";
    sha256 = "126i5qlkpv7pvi1mmc9y0jhqs6jjspsj7j615n2ddvsb2jsps81c";
  };

in runCommand "patchelf" {
    buildInputs = [ patchelf gcc ];
  } ''
    cp -r ${deadbeef} source
    chmod -R u+w -- source
    cd source/plugins/wildmidi
    gcc -ggdb -shared -Iinclude -DWILDMIDI_VERSION=\"0.2.2\" -DWILDMIDILIB_VERSION=\"0.2.2\" -DTIMIDITY_CFG=\"/etc/timidity.conf\" -fPIC wildmidiplug.c src/wildmidi_lib.c include/wildmidi_lib.h -o wildmidi.so -lm

    mkdir $out
    cp wildmidi.so $out/wildmidi-patched.so
    cp wildmidi.so $out/wildmidi.so
    patchelf --shrink-rpath $out/wildmidi-patched.so
  ''
@jtojnar
Copy link
Member Author

jtojnar commented Apr 13, 2019

Likely the same issue as #45

@solna86
Copy link

solna86 commented Apr 14, 2019

It does indeed look like #45, which arises for example in several Rpackages like Seurat. It'd be good to see if there are any similarities to narrow down what causes patchelf to output wrong binaries.

@domenkozar
Copy link
Member

@jtojnar could you try again with master (or patchelfUnstable in nixpkgs)?

@jtojnar
Copy link
Member Author

jtojnar commented Jun 3, 2020

Can still reproduce with /nix/store/xlkfqvahjpd2cm7kysy1g43gcw9pjgja-patchelf-2020-06-03 on NixOS/nixpkgs@fd9d37e:

with import ./. { };
with pkgs;

let
  deadbeef = fetchFromGitHub {
    owner = "DeaDBeeF-Player";
    repo = "deadbeef";
    rev = "1.8.0";
    sha256 = "126i5qlkpv7pvi1mmc9y0jhqs6jjspsj7j615n2ddvsb2jsps81c";
  };

in runCommand "patchelf" {
    buildInputs = [ patchelfUnstable gcc ];
  } ''
    cp -r ${deadbeef} source
    chmod -R u+w -- source
    cd source/plugins/wildmidi
    gcc -ggdb -shared -Iinclude -DWILDMIDI_VERSION=\"0.2.2\" -DWILDMIDILIB_VERSION=\"0.2.2\" -DTIMIDITY_CFG=\"/etc/timidity.conf\" -fPIC wildmidiplug.c src/wildmidi_lib.c include/wildmidi_lib.h -o wildmidi.so -lm

    mkdir $out
    cp wildmidi.so $out/wildmidi-patched.so
    cp wildmidi.so $out/wildmidi.so
    patchelf --shrink-rpath $out/wildmidi-patched.so

    echo "These should be the same:"
    nm -A -D -l $out/wildmidi.so | grep wildmidi_lib.c:399
    nm -A -D -l $out/wildmidi-patched.so | grep wildmidi_lib.c:399
    echo "^ The symbol should not have been renamed to X."
  ''

@domenkozar
Copy link
Member

It would be helpful if you can also try 0.9 as the linked issue says it used to work.

@jtojnar
Copy link
Member Author

jtojnar commented Jun 3, 2020

I originally reproduced this with 0.9. Just tried it again to be sure and replacing patchelfUnstable by patchelf in the example above indeed does not fix the issue.

@domenkozar domenkozar added the bug label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants