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

Ubuntu 20.04 - onefile produces a shared object instead of executable #5361

Closed
padremayi opened this issue Dec 2, 2020 · 10 comments
Closed

Comments

@padremayi
Copy link

On Ubuntu 20.04 it's impossible to launch an application with double click, only from terminal the program starts. Operating system informs that there is no application for launching shared object.

Is there a way to avoid this? Is it related with bootloader? Is there a way to pass -no-pie when bootloader is being build?

PyInstaller 4.1, Python 3.8.5

@rokm
Copy link
Member

rokm commented Dec 2, 2020

Yes, the pre-built bootloaders are built with PIE. And it seems in 20.04, gcc has PIE enabled by default (so if you compile a hello world C example, it will also be mis-identified as a "shared library" and won't launch via double-click...).

You can pass -no-pie to gcc while building bootloader like this:

CC="gcc -no-pie" python waf configure all

@padremayi
Copy link
Author

padremayi commented Dec 2, 2020

It doesn't work, test_application is LSB shared object, output with file:

test_application: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=3507aa01d32c34dc8e8c6462b764adb90a82768d, stripped

Bootloader compiled with these step:

git clone https://github.com/pyinstaller/pyinstaller
cd pyinstaller/bootloader
CC="gcc -no-pie" python3 ./waf distclean all
cd ..
sudo python3 setup.py install

Output with file on run:

run: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0bed608e13054c9ca0fb6179100d9431bcca2d33, for GNU/Linux 3.2.0, stripped

@rokm
Copy link
Member

rokm commented Dec 2, 2020

Output with file on run:

run: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0bed608e13054c9ca0fb6179100d9431bcca2d33, for GNU/Linux 3.2.0, stripped

So the bootloader is non-pie executable now.

If test_application remains a PIE executable, that means that the new bootloader is not used. Do you have another installation of pyinstaller (e.g., user's site-packages, venv, etc) that is shadowing the newly-installed one?

@padremayi
Copy link
Author

Ok, you hit the problem, there was PyInstaller 4.1 that was overriding git version.

Maybe it is better to add this problem (gcc has PIE enabled by default) on documentation, isn't it?

@rokm
Copy link
Member

rokm commented Dec 2, 2020

Maybe it is better to add this problem (gcc has PIE enabled by default) on documentation, isn't it?

Perhaps, but we (or at least I) only became aware of it once people started to ask about it, following the 4.1 release. I think the pre-compiled bootloaders that are shipped with 4.1 were not intentionally built as PIE executables (but rather, that was the default on the build machine)...

Also, the problem is not directly related to pyinstaller. The PIE executables seem to be the modern executable format, which is probably why the new Ubuntu defaults to it (as a side note, the latest Fedora seems to be still using the old executable format by default).

So the issue with PIE executables being recognized as shared libraries / user not being able to run them via double-click from the desktop environment is something that needs to be addressed by the desktop environment (or the component used for identification), as it affects all executables built with default parameters on distributions that enable PIE by default...

@padremayi
Copy link
Author

I understand the point

@DotBow
Copy link

DotBow commented Feb 13, 2021

Hi!
The issue happens to me with PyInstaller 4.1-4.2 and Ubuntu 18.04
So the only way to fix it is build your own bootloader?

@rokm
Copy link
Member

rokm commented Feb 13, 2021

Hi!
The issue happens to me with PyInstaller 4.1-4.2 and Ubuntu 18.04
So the only way to fix it is build your own bootloader?

There is nothing to "fix" really, but yes, if you want non-PIE bootloader, you need to rebuild it yourself.

@DotBow
Copy link

DotBow commented Feb 13, 2021

Hi!
The issue happens to me with PyInstaller 4.1-4.2 and Ubuntu 18.04
So the only way to fix it is build your own bootloader?

There is nothing to "fix" really, but yes, if you want non-PIE bootloader, you need to rebuild it yourself.

As far as I understand it is also environment depended so probably on other distros there is no such issue.
But for now I'm OK with using 4.0 on linux for building my executables.

@rokm
Copy link
Member

rokm commented Mar 20, 2021

Closing this as bootloader and consequently frozen applications being PIE is not an issue per-se. The side effects (mis-identification of executable as a shared library, not being able to run it via double-click in DE, etc.) should be resolved elsewhere as they are not specific to PyInstaller but to all PIE executables.

@rokm rokm closed this as completed Mar 20, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants