Skip to content

Commit

Permalink
Do not run strip on files that contain rpath starting with $
Browse files Browse the repository at this point in the history
Workaround for NixOS/patchelf#10?
  • Loading branch information
probonopd committed Feb 14, 2017
1 parent e567ec5 commit c643d6a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions shared/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,36 @@ void runStrip(const QString &binaryPath)
// Since we might have a symlink, we need to find its target first
QString resolvedPath = QFileInfo(binaryPath).canonicalFilePath();

LogDebug() << "Determining whether to run strip:";
LogDebug() << " checking whether" << resolvedPath << "has an rpath set";
LogDebug() << "patchelf" << "--print-rpath" << resolvedPath;
QProcess patchelfread;
patchelfread.start("patchelf", QStringList() << "--print-rpath" << resolvedPath);
if (!patchelfread.waitForStarted()) {
if(patchelfread.errorString().contains("execvp: No such file or directory")){
LogError() << "Could not start patchelf.";
LogError() << "Make sure it is installed on your $PATH.";
} else {
LogError() << "Could not start patchelf. Process error is" << patchelfread.errorString();
}
exit(1);
}
patchelfread.waitForFinished();

if (patchelfread.exitCode() != 0){
LogError() << "Error reading rpath with patchelf" << QFileInfo(resolvedPath).completeBaseName() << ":" << patchelfread.readAllStandardError();
LogError() << "Error reading rpath with patchelf" << QFileInfo(resolvedPath).completeBaseName() << ":" << patchelfread.readAllStandardOutput();
exit(1);
}

QString rpath = patchelfread.readAllStandardOutput();

if (rpath.startsWith("$")){
LogDebug() << "Already contains rpath starting with $, hence not stripping";
LogDebug() << patchelfread.readAllStandardOutput();
return;
}

LogDebug() << "Using strip:";
LogDebug() << " stripping" << resolvedPath;
QProcess strip;
Expand Down

0 comments on commit c643d6a

Please sign in to comment.