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

glibc: fix cross builds on Darwin #56417

Merged
merged 1 commit into from Feb 26, 2019
Merged

glibc: fix cross builds on Darwin #56417

merged 1 commit into from Feb 26, 2019

Conversation

mroi
Copy link
Contributor

@mroi mroi commented Feb 26, 2019

When cross-compiling glibc, the postInstall attribute will use the build-platform version of localedef to generate locale information. This does not work when cross-compiling glibc on Darwin machines, because evaluating buildPackages.glibc will correctly lead to an unsupported platform error. Darwin machines cannot host glibc and thus cannot run the binaries.

My suggested fix ensures that the postInstall snippet which uses buildPackages.glibc is only included, when the build platform is Linux. On other platforms, the locale information will not be generated. This appears to be no problem in my cross compilation tool chain.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

evaluate buildPackages.glibc exclusively on Linux,
evaluating it on Darwin will lead to an unsupported platform error
@GrahamcOfBorg GrahamcOfBorg added the 6.topic: darwin Running or building packages on Darwin label Feb 26, 2019
mroi referenced this pull request Feb 26, 2019
glibc's buildsystem uses its own executables to generate locales.
This does not work for cross-compilation so instead we use localedef
from buildPackages.
@Mic92
Copy link
Member

Mic92 commented Feb 26, 2019

Should be ok to do so that for now. Eventually however we want to depend on LC_LANG=C.UTF-8 in more and more places, also we probably will start at the build time in which case the macOS stdenv would provide the locale. Long-term it might be possible to compile a cross-platform localedef as a proper fix: http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/glibc/cross-localedef-native_2.29.bb?h=master

@Mic92 Mic92 merged commit 2642e15 into NixOS:master Feb 26, 2019
@mroi
Copy link
Contributor Author

mroi commented Feb 26, 2019

Thanks for your thoughts on the future goals, I will keep this in mind for later cross-toolchain work.

Also, I’ll just leave this here as a reference for later: macOS natively ships with a /usr/bin/localedef tool. Its arguments are not fully compatible with glibc’s version, but from the manpage, it appears to fulfil a similar purpose. But it may be the better option to properly cross-compile glibc’s own localedef.

@angerman
Copy link
Contributor

angerman commented Aug 25, 2019

This should be merged in release-19.03 as well; see #67433

@matthewbauer
Copy link
Member

Cheryy picked in 3924b34

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

Successfully merging this pull request may close these issues.

None yet

5 participants