Skip to content

libxml2: use libiconv on Darwin - #137870

Merged
happysalada merged 1 commit into
NixOS:stagingfrom
emilazy:libxml2-libiconv-darwin
Oct 2, 2021
Merged

happysalada merged 1 commit into
NixOS:stagingfrom
emilazy:libxml2-libiconv-darwin

Conversation

@emilazy

@emilazy emilazy commented Sep 14, 2021

Copy link
Copy Markdown
Member
Motivation for this change

This fixes e.g. python3Packages.beautifulsoup4, which has tests relying on the wider encoding support enabled by libiconv. Not built locally because I don't have the resources to bootstrap stdenv, but I made python3Packages.lxml use this version of libxml2 and everything seemed to work fine. If it's not acceptable to include libiconv in the Darwin stdenv bootstrap, let me know and I can see about conditionalizing it.

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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 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.

@ofborg ofborg Bot added 6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. labels Sep 14, 2021
@ofborg
ofborg Bot requested review from andir, edolstra, lovek323 and np September 14, 2021 18:30
@ofborg ofborg Bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 14, 2021
@emilazy

emilazy commented Sep 14, 2021

Copy link
Copy Markdown
Member Author

One alternative would be to continue to omit libiconv and just disable the failing encoding-related BeautifulSoup tests.

@risicle

risicle commented Sep 14, 2021

Copy link
Copy Markdown
Contributor

Trying to reproduce your lxml-building and getting downstream packages themselves wanting iconv... e.g.

 /nix/store/mbqgykviliwg19bfajsz79bfbg344mlq-libxml2-2.9.12-dev/include/libxml2/libxml/encoding.h:28:10: fatal error: 'iconv.h' file not found
#include <iconv.h>
         ^~~~~~~~~
1 error generated.

When trying to build libxslt.

@risicle

risicle commented Sep 14, 2021 •

Copy link
Copy Markdown
Contributor

This is on macos 10.15. libiconv doesn't seem to get included in nix-support/propagated-build-inputs of libxml2.dev

@emilazy

emilazy commented Sep 15, 2021

Copy link
Copy Markdown
Member Author

I think what's going on here is that the aarch64-darwin SDK (which is based on a newer macOS SDK than the x86_64-darwin one) has an iconv.h header but no iconv library, so (a) this header issue "just works out" on aarch64, and (b) there's a bunch of other weird downstream issues of build systems detecting iconv.h and expecting an iconv library that isn't there.

I'm not sure what the correct resolution is; is propagatedBuildInputs usually used for header dependencies like this?

Comment thread pkgs/top-level/all-packages.nix Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
inherit (darwin) libiconv;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is fairly commonly used in all-packages.nix for cases where the dependency is only used on Darwin, I figured it's a little clearer this way rather than relying on the conditional/stubbed-out package (iconv is part of glibc). Maybe the other cases should be changed too though? I'm not aware of any particular standard one way or the other for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed a couple days ago, that we should maybe update the definition of libiconv: #138545 (comment)

Maybe something we can tackle in a separate PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, I'm a little confused; shouldn't !stdenv.isLinux imply stdenv.hostPlatform.libc != "glibc" in almost all cases to begin with? What's incorrect about the current libiconv/libintl definitions?

@newAM newAM mentioned this pull request Sep 20, 2021
3 of 12 tasks
@emilazy
emilazy force-pushed the libxml2-libiconv-darwin branch from 198e536 to d4a1816 Compare September 25, 2021 19:04
@emilazy

emilazy commented Sep 25, 2021

Copy link
Copy Markdown
Member Author

Uses propagatedBuildInputs now, which should hopefully fix the build issue on x86_64-darwin.

@emilazy
emilazy force-pushed the libxml2-libiconv-darwin branch from d4a1816 to 17f34d5 Compare September 25, 2021 19:23

@risicle risicle left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works for me now, macos 10.15 (and manages to build beautifulsoup4). Still wish we could figure out why it's not being picked up as it should.

@risicle

risicle commented Sep 28, 2021

Copy link
Copy Markdown
Contributor

Might it be possible to get this in staging-next given than the breakage is currently preventing thousands of packages being properly reviewed against darwin?

@emilazy

emilazy commented Sep 28, 2021

Copy link
Copy Markdown
Member Author

Going by ofborg, it seems like this would break stdenv:

building '/nix/store/7h383zwwz8k5vjr52qc0j1yjcqc39pig-bootstrap-stage3-stdenv-darwin.drv'...
output '/nix/store/jswbz9pynnfcn96p3j2q70j0x3s128nf-bootstrap-stage3-stdenv-darwin' is not allowed to refer to the following paths:
  /nix/store/dhkh15znvls5s4rnqk71pcmrrs95r7x9-libiconv-50

Either the restriction needs loosening (and I'm not sure how), or we need a libxml2Minimal to use in stdenv bootstrap, or we should go with an alternate approach like selectively disabling the Beautiful Soup XML encoding tests on Darwin.

@SuperSandro2000

Copy link
Copy Markdown
Member

Either the restriction needs loosening (and I'm not sure how)

see https://github.com/NixOS/nixpkgs/pull/115498/files

@emilazy
emilazy force-pushed the libxml2-libiconv-darwin branch from 17f34d5 to 91130c5 Compare September 28, 2021 21:28
@github-actions github-actions Bot added the 6.topic: stdenv Standard environment label Sep 28, 2021
@emilazy

emilazy commented Sep 28, 2021

Copy link
Copy Markdown
Member Author

Thanks. Strangely it was already present in most of those locations, but I added it to the remaining ones and hopefully that'll fix things.

@emilazy
emilazy force-pushed the libxml2-libiconv-darwin branch from 91130c5 to 9c49f49 Compare September 28, 2021 21:32
This fixes e.g. python3Packages.beautifulsoup4, which has tests relying
on the wider encoding support enabled by libiconv.

Fixes NixOS#137678.
@emilazy
emilazy force-pushed the libxml2-libiconv-darwin branch from 9c49f49 to 577cd74 Compare September 28, 2021 21:33
@emilazy

emilazy commented Sep 28, 2021

Copy link
Copy Markdown
Member Author

I'm not sure why this is still failing. libiconv is present in all the lists libxml2 is in the Darwin stdenv file, as far as I can tell. Is it something about needing .out, maybe?

@risicle

risicle commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Afraid was only able to test through hackiness to avoid the bootstrap loop :(

@risicle

risicle commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Would it be helpful if I prepared a PR aimed at staging-next skipping the bs4 test in question, just to get darwin's python ecosystem back sooner rather than later? (it's not like I'd be leaving anything more broken than it was before, right?)

Or might reliving the pressure in that way also relieve the pressure to get it fixed properly?

@happysalada

Copy link
Copy Markdown
Contributor

It looks like the ofborg failure was with stage3 and it seems you added the file to the persistent list of stage 2.
I'm not sure why it's failing like this, since libiconv is in the allowedRequisites of stage3. I had to modify this part once, and for me just adding the missing derivation to allowed requisites fixed that particular error.
I should have some time to test this further tonight.

@happysalada

Copy link
Copy Markdown
Contributor

I tried building bash and pcre on that PR and it all went fine. I didn't see the failure before with stage3.
I'm going to test quickly without adding libiconv to stage2

@happysalada

Copy link
Copy Markdown
Contributor

Removing that from stage2 makes it fail.
I've tried modifying the allowedRequisites to add the .out at the end, but no matter what I do, I couldn't get it to work.
It looks that stage2 reference is needed.

@happysalada

Copy link
Copy Markdown
Contributor

The latest ofborg failure https://github.com/NixOS/nixpkgs/pull/137870/checks?check_run_id=3748738841 just says time out.
I'm going to go ahead and merge this, since it looks correct.

@happysalada
happysalada merged commit 20a6d8a into NixOS:staging Oct 2, 2021
YorikSar added a commit to YorikSar/dotfiles that referenced this pull request Oct 11, 2021
@SergeyPoznyakAkvelon

SergeyPoznyakAkvelon commented Oct 21, 2021 •

Copy link
Copy Markdown

Hello, I'm pretty new with nix and this issue is currently preventing me from updating my packages because one of them depends on beautifulsoup. Is there any workaround I can use right now for this error?

Package that breaks for me is neovim-nightly (from the unofficial community overlay)

I don't want to switch nix channels if possible.

Thank you!

Edit:

Never mind, this commit helped YorikSar/dotfiles@8a70172

Include this overlay and everything seems to work.
Thanks @YorikSar!

@risicle

risicle commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

Yeah sorry this is stuck in our staging branch and should make its way to master in #141684

nixypanda added a commit to nixypanda/dotfiles that referenced this pull request Oct 29, 2021
- beautifulsoup's test case are failing and shit is stuck in staging
  hell so have to do a workaround.
  Workaround: Add beautifulsoup4 overlay until NixOS/nixpkgs#137870
  fixing NixOS/nixpkgs#137678 lands in nixpkgs-unstable.
- git_protocol config name was changed in programs.gh
- Updated neovim plugins (still not in nixpkgs-unstable)
- lsp_saga's CodeAction list view feature stopped working. Switched over
  to Telescope's CodeAction preview
- NvimTree saw a few changes had to change that

(Note: Not a fun day)
@happysalada

Copy link
Copy Markdown
Contributor

Unless I'm wrong, I think this update breaks asciidoctor on darwin.
asciidoctor relies on nokogiri that itself relies on libxml2.
Upon compilation of nokogiri, the following errors occurs

In file included from /nix/store/1vpjj9aza91r164sfmcyjjnjfnczlps5-libxml2-2.9.12-dev/include/libxml2/libxm
l/parser.h:812:
/nix/store/1vpjj9aza91r164sfmcyjjnjfnczlps5-libxml2-2.9.12-dev/include/libxml2/libxml/encoding.h:28:10: fa
tal error: 'iconv.h' file not found
#include <iconv.h>

Nokogiri itself is including libiconv, however the flag passed to the compilation for nokogiri is not being taken in account when looking for the header in the libxml2 file.
Here is where nokogiri itself requires iconv https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix#L440

It took me a while to find the fix, so I'm just documenting here in case something similar happens to another dependent of libxml2
Basically you have to add a flag to tell it where to look for additional header.
See #144582

@emilazy
emilazy deleted the libxml2-libiconv-darwin branch August 26, 2024 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: stdenv Standard environment 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants