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

qtbase: force to use bash in glibc system() and popen() calls #37082

Closed
wants to merge 2 commits into from

Conversation

YorikSar
Copy link
Contributor

Motivation for this change

Due to inherent impurity in qmake (actually, glibc), it depends on /bin/sh to provide certain non-POSIX commands (qmake uses command -v <tool> to find tools like moc, you can find details at #36903). I've decided that it should be better to remove this impurity by forcing qmake to use version of glibc that has all references to /bin/sh replaced with essentially ${pkgs.bash}/bin/sh.

I've build most of Qt stuff with this change with no problems.

This change should also help with some Qt package failures at #36453 (18.03 ZHF).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

At least qmake relies on popen using shell not as simple as our /bin/sh,
so use bash for it.
@Mic92
Copy link
Member

Mic92 commented Mar 15, 2018

cc @shlevy

@shlevy
Copy link
Member

shlevy commented Mar 15, 2018

👎 from me. I don't think we should have an entirely new glibc just for this case. I'd be in favor of an effort to make glibc by default use sh from PATH or even hard-code bash (this presents some bootstrapping problems, but not insurmountable), I'd even implement that myself if we had the goahead, but as long as glibc is as it is we should simply patch misbehaving tools not to use system etc, or do some ld trickery to give them a patched version of system etc. without rebuilding all glibc.

And, FWIW, while the impurity here is in glibc this is also a qmake bug, as usages of system should not expect anything more than POSIX shell. So patches here would be reasonable to submit upstream.

@7c6f434c
Copy link
Member

7c6f434c commented Mar 15, 2018 via email

@shlevy
Copy link
Member

shlevy commented Mar 15, 2018

Ah, OK, this is just another manifestation of the overly weak /bin/sh issue then. Still, IMO any nix tool depending on /bin/sh, especially during builds, is a bug, though admittedly one harder to get patched upstream.

@Mic92
Copy link
Member

Mic92 commented Mar 18, 2018

It is not relying on /bin/sh it is relying on glibc?

glibc_2_27 = callPackage ../development/libraries/glibc/2.27.nix {
installLocales = config.glibc.locales or false;
};
glibc = if hostPlatform.isRiscV then glibc_2_27 else glibc_2_26;
glibc_bash = glibc_2_26_bash;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shlevy why not making this the default glibc then?

@shlevy
Copy link
Member

shlevy commented Mar 18, 2018

@Mic92 system is relying on /bin/sh. Not strictly in the standard, but in every single actual implementation I know of.

As for "why not make it the default glibc", I don't know. I tried proposing it years ago and it was rejected. Note that it's not completely trivial, as there is a bootstrapping issue to fix, but certainly fixable. See e.g. #4998 (though the conversation spread across multiple threads)

@Mic92
Copy link
Member

Mic92 commented Mar 18, 2018

@shlevy then glibc with bash by default is not a good short-term solution either.

@shlevy
Copy link
Member

shlevy commented Mar 18, 2018

@Mic92 I never said it was. As I said, I'd be in favor of such an effort and even reimplement it myself if it were acceptable. Given that it's not, patching qmake (or wrapping it with some LD_PRELOAD or whatever) is the right way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants