Git Product home page Git Product logo

linuxdeploy-plugin-checkrt's Introduction

linuxdeploy-plugin-checkrt

This linuxdeploy plugin allows you to deploy libstdc++.so.6 and libgcc_s.so.1 without breaking compatibility. The installed AppRun hook script will compare the symbol version numbers between the deployed libraries and those on your system and only add the deployed ones to LD_LIBRARY_PATH if they're newer.

Additionally the library exec.so is deployed and will be preloaded by AppRun if it's found. This library is intended to restore the environment of the AppImage's parent process in order to avoid library clashing of bundled libraries with external processes called from within the AppImage (i.e. when a webbrowser is opened or a terminal emulator is started). If you don't want exec.so then simply delete it before creating your final AppImage.

Requirements

C compiler (GCC or Clang)

Usage

# get linuxdeploy and linuxdeploy-plugin-checkrt and make them executable
wget -c "https://github.com/darealshinji/linuxdeploy-plugin-checkrt/releases/download/continuous/linuxdeploy-plugin-checkrt.sh"
wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
chmod a+x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-checkrt.sh

# add GCC's libraries to the search path
# and call through linuxdeploy using the `--plugin checkrt` option
LD_LIBRARY_PATH="/path/to/my/gcc-snapshot/lib64" \
  ./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin checkrt --output appimage --icon-file mypackage.png --desktop-file mypackage.desktop

Why?

libstdc++.so.6 and libgcc_s.so.1 are part of GCC and if you compile code it will be linked against these libraries if required. If you use a newer version of GCC than normally available on your system these libraries will also be newer and chances are high that your program - linked against these newer versions - is no longer compatible to those installed by default on your system.

Starting your program would get you an error message like this:

./myApp: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./myApp)

However you cannot simply bundle these libraries as usual. If the AppImage is started on a different system and an unbundled system library depends on a newer version than available from the AppImage it won't work either.

This linuxdeploy plugin will install a hook script that quickly checks and compares the internal version number of the libraries and only adds them to the search path if they're newer.

Hacking

The file linuxdeploy-plugin-checkrt.sh is created from generate.sh. To add changes to the plugin you must edit the other files and then run ./generate.sh.

linuxdeploy-plugin-checkrt's People

Contributors

darealshinji avatar jlskuz avatar theassassin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

linuxdeploy-plugin-checkrt's Issues

exec.soA from LD_PRELOAD cannot be preloaded

On xubuntu-16.04.1-desktop-amd64.iso with https://github.com/probonopd/audacity/releases/download/checkrt/Audacity-63de7f0-x86_64.AppImage:

ERROR: ld.so: object '/tmp/.mount_AudaciivUspk/usr/optional/exec.soA' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/tmp/.mount_AudaciivUspk/usr/optional/exec.soA' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/tmp/.mount_AudaciivUspk/usr/optional/exec.soA' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/tmp/.mount_AudaciivUspk/usr/optional/exec.soA' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/tmp/.mount_AudaciivUspk/usr/optional/exec.soA' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Where is the extra "A" coming from?

Interesting: If I run

./Audacity-63de7f0-x86_64.AppImage --appimage-extract
./squashfs-root/AppRun

then I do not see these messages.

Use `$BASH_SOURCE` to fix path issues when `source`d by scripts other than `AppRun`

Related to #24. When source-ing the script from any other location than AppRun, the script cannot properly determine the path to its auxiliary files.

Now this is obviously just a problem with linuxdeploy-plugin-native_packages which cannot use AppRun technically at this point. It should be possible to implement a chain that first attempts to calculate a path based on $APPDIR (if available), then fall back to $BASH_SOURCE and finally $0.

Be less aggressive in substituting libraries

Per default, AppRun.sh compares the symbols of the system libstdc++ and the packaged one.
I'm not sure how portable and/or correct this is, especially with script-based applications, but isn't it enough to compare the symbols of the application?
e.g.

  sym_app=$(tr '\0' '\n' < "$exec" | grep -e '^GLIBCXX_3\.4' | sort -V | tail -n1)

This could partially solve e.g. mesa issues like sgsaenger/vipster#30

Fantastic software!

Not a bug, but wanted to say thanks for this.
I recently implemented it in my build, and now the software works without the users having to upgrade their gcc. It doesn't break modern Linux either.

Extremely clean, extremely effective. Thanks so much!

[bug] getcwd return worry path

Using c/c++ on ubuntu, getcwd should return the path where AppImage is called. But the return is always FUSE mounted.

Bundled libstdc++ should NOT be loaded for binaries outside of the AppImage

Ob Xubuntu 16.04 using https://github.com/probonopd/audacity/releases/download/continuous/Audacity-8724a5a-x86_64.AppImage:

me@host:~$ export APPIMAGE_CHECKRT_DEBUG=1
me@host:~$ '/home/me/Downloads/Audacity-8724a5a-x86_64(1).AppImage' 
APPIMAGE_CHECKRT>> /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ==> GLIBCXX_3.4.21 (21)
APPIMAGE_CHECKRT>> ./optional/libstdc++/libstdc++.so.6 ==> GLIBCXX_3.4.24 (24)

APPIMAGE_CHECKRT>> optional_ld_library_path: /tmp/.mount_Audacin3QZoY/usr/optional/libstdc++:
optional_ld_preload: LD_PRELOAD=/tmp/.mount_Audacin3QZoY/usr/optional/exec.so

But then, when I want to select Help -> Quick Help, I get:

(...)
APPIMAGE_CHECKRT>> >>> custom execve()!
APPIMAGE_CHECKRT>> >>> custom execve()!
APPIMAGE_CHECKRT>> >>> custom execve()!
/usr/lib/firefox/firefox: relocation error: /usr/lib/firefox/firefox: symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4copyEPcmm, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

Note that /usr/lib/firefox/firefox is outside of the AppImage, hence our private libstdc++ should not be used for it.

[feature request] Remove the need for AppRun

Would it be possible to make a dummy library that gets loaded instead of libstdc++, then determines whether the system or bundled libstdc++ should be loaded, and then would load that one in turn? This would greatly simplify using this, as it would remove the need for a custom AppRun, bash script or similar wrapper.

Background: In linuxdeployqt we have moved away from AppRun binaries or scripts and just use a symlink to the main executable, as we think this is a much cleaner solution.

checkrt might segfault if a library contains both dynstr and strtab sections

As discovered investigating issue #20 , there seems to be a bug in the way checkrt searches for the addresses of the .strtab and .dynstr sections.

Reading lines 147-165, it seems that finding either the .strtab section or the .dynstr section stops the search loop with a break statement.
This means that if a library contains both .strtab and .dynstr, only one of the addresses will be set, while the other address will stay at the value set at lines 143-144 .

I discovered this by accident by making checkrt check libstdc++.so.6 before libgcc_s.so.1, swapping lines 374-378 with lines 380-384 (and moving the int var).
Doing that makes checkrt segfault at the strncmp at line 194.

Deleting the two breaks at line 157 and line 163 fixes the segfault and checkrt runs successfully.

How to use this?

It's not immediately obvious how to actually use this in conjunction with linuxdeployqt.AppImage to make an AppImage that works with a newer libstdc++ version.

Built files should not be located inside `apprun-hooks` directory

I recently helped debug a problem that occurred with https://github.com/linuxdeploy/linuxdeploy-plugin-native_packages/. This output plugin deploys autogenerated helper scripts in /usr/bin for every desktop entry in the AppImage to imitate classic packaging.

There is no technical need for the files this plugin generates during build time to be located within that hooks directory. We should move the files outside of there, e.g., one level up.

Of course, the output plugin will receive some improvements to filter out seemingly incompatible files. But I'd also like to narrow the plugin specification to limit the directory to source-able shell scripts.

Please consider making releases

Please consider making some kind of releases. linuxdeploy for instance uses point releases based on the current date. This allows users to use a known-working state. Also, it allows for a/b testing of changes.

Your GitHub actions CI pipeline already supports this use case because it uses pyuploadtool to upload the binaries. All you need to do is push a tag, the CI handles the creation of the release on GitHub along with a binary built from this tag.

ldconfig not found on Debian

I am testing this to make a C++14 application run on Debian Jessie. Trying to run my AppImage displays sh: 1: ldconfig: not found error. The script then fails to load the bundled libstdc++.so and the application stops with a CXXABI error.

ldconfig is located in /sbin which is not in the path of regular users. With a PATH including /sbin, the AppImage starts correctly.

Optional libraries must not affect binaries loaded from outside the AppImage

Using xubuntu-16.04.1-desktop-amd64.iso and Audacity-dc63bfe-x86_64.AppImage from https://github.com/probonopd/audacity/releases, when I select Help -> "Check for updates", it fails:

"Failed to execute default Web Browser.
input/output error"

On the command line I get:

/usr/lib/firefox/firefox: relocation error: /usr/lib/firefox/firefox:
symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4copyEPcmm,
version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

I suspect this to be a side effect of using AppImageKit-checkrt.

This is a workaround:

./Audacity-dc63bfe-x86_64.AppImage --appimage-extract
rm squashfs-root/usr/optional/libstdc++/libstdc++.so.6
./squashfs-root/AppRun

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.