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

pkgsMusl.postgresql: fix build #228349

Merged
merged 1 commit into from
Jun 7, 2023
Merged

pkgsMusl.postgresql: fix build #228349

merged 1 commit into from
Jun 7, 2023

Conversation

yu-re-ka
Copy link
Contributor

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@@ -103,6 +103,25 @@ let
./patches/hardcode-pgxs-path.patch
./patches/specify_pkglibdir_at_runtime.patch
./patches/findstring.patch

# Fix required for musl libc, but it can be applied everywhere
(fetchpatch {
Copy link
Member

Choose a reason for hiding this comment

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

Since I don't know about darwin, I gotta ask: how does this behave there?

@yu-re-ka
Copy link
Contributor Author

yu-re-ka commented May 8, 2023

You're completely right, this would change the behavior on darwin in an unwanted way.

Also looking at the description of this patch more closely, we can do something better than this in Nix: The issue is the locale binary from the environment mismatching with what the libc that postgres was compiled against supports. We should simply patch postgres to use the locale binary from an absolute path.
This would also solve the issue of a glibc postgres binary running on a musl system and vice versa.

However this is more difficult because on Mac OS the locale binary is not actually available in the nix store, but only in the impure environment in /usr/bin/locale :/

I will try to come up with something.

@yu-re-ka
Copy link
Contributor Author

@Ma27 please review the patch I have pushed

@ofborg ofborg bot requested a review from Ma27 May 28, 2023 18:47
Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

After re-reading the message of https://git.alpinelinux.org/aports/plain/main/postgresql14/dont-use-locale-a-on-musl.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7, LGTM.

(tl;dr and for reference, if locale doesn't exist, it's fine, but on a musl system, locale from musl-locales may be called which breaks things, hence the absolute path which doesn't exist on musl)

@Ma27 Ma27 merged commit c92f3af into NixOS:staging Jun 7, 2023
Comment on lines +119 to +123
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/icu-collations-hack.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
hash = "sha256-Yb6lMBDqeVP/BLMyIr5rmR6OkaVzo68cV/+cL2LOe/M=";
})

Copy link
Contributor

Choose a reason for hiding this comment

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

@yu-re-ka @Ma27 could one of you explain why the "icu-collations-hack.patch" was introduced here?

This PR was supposed to fix pkgsMusl.postgresql building, because it was failing two tests. For this the other patch disable-test-collate.icu.utf8.patch was added. Understood.

But the lengthy text in icu-collations-hack.patch states:

Since full ICU data is very big (30 MiB), we have created a stripped down
variant
with only English locale (package icu-data-en, 2.6 MiB). It also
includes a subset of 18 collations that cover hundreds of languages.

When the cluster is initialized or pg_import_system_collations() is
called directly and only icu-data-en (default) is installed, the user
ends up with only und, en and en_GB ICU-based COLLATIONs. The user can
create missing COLLATIONs manually, but this a) is not expected nor
reasonable behaviour, b) it's not easy to find out for which locales
there's a collation available for.

(emphasis mine)

This is very specific to alpine trying to have a very small icu package. I don't think this applies for NixOS/nixpkgs at all.

I tested removing the icu-collations-hack.patch - all 5 versions still build just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right. I was quite afraid of adding some but not all collations-related patches, and getting weird runtime behavior regarding the collations, but there was no logical reason for requiring this patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for confirming! I added a commit remove it in #293996.

@yu-re-ka yu-re-ka deleted the musl-postgresql branch March 16, 2024 13:32
@wolfgangwalther wolfgangwalther mentioned this pull request Mar 16, 2024
13 tasks
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this pull request Apr 4, 2024
This was introduced in NixOS#228349, but doesn't seem necessary to build for pkgsMusl.

In fact the patch itself seems to be very specific about a stripped down icu
package in Alpine Linux, which does not apply to nixpkgs.
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this pull request Sep 15, 2024
/bin/locale doesn't exist on musl and was already effectively disabled
in NixOS#228349. However this still leaves the following warning for initdb:

  performing post-bootstrap initialization ... sh: locale: not found

By applying the alpine patch to disable locale -a entirely, this warning
will disappear. This will also make one more regression test pass when
testing "check-world" instead of "check", only.
wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this pull request Sep 26, 2024
/bin/locale doesn't exist on musl and was already effectively disabled
in NixOS#228349. However this still leaves the following warning for initdb:

  performing post-bootstrap initialization ... sh: locale: not found

By applying the alpine patch to disable locale -a entirely, this warning
will disappear. This will also make one more regression test pass when
testing "check-world" instead of "check", only.
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.

3 participants