Skip to content

ocamlPackages.findlib: Allow built-in libraries to clash#213577

Closed
ulrikstrid wants to merge 1 commit into
NixOS:masterfrom
ulrikstrid:ulrikstrid--ocaml-findlib-allow-x-compile
Closed

ocamlPackages.findlib: Allow built-in libraries to clash#213577
ulrikstrid wants to merge 1 commit into
NixOS:masterfrom
ulrikstrid:ulrikstrid--ocaml-findlib-allow-x-compile

Conversation

@ulrikstrid
Copy link
Copy Markdown
Member

@ulrikstrid ulrikstrid commented Jan 30, 2023

Description of changes

This change allows the builtin libraries in OCaml to clash which is the case when you cross-compile since you'll have both the target and system OCaml available

Follow-up on #205646

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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ulrikstrid ulrikstrid requested a review from symphorien January 30, 2023 12:58
@github-actions github-actions Bot added the 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. label Jan 30, 2023
@ulrikstrid
Copy link
Copy Markdown
Member Author

Added those involved in the last PR as reviwers

@ulrikstrid ulrikstrid changed the title findlib: Allow some libraries to clash ocamlPackages.findlib: Allow built-in libraries to clash Jan 30, 2023
This change allows the builtin libraries in OCaml to clash
which is the case when you cross-compile since you'll have
both the target and system OCaml available
@ulrikstrid ulrikstrid force-pushed the ulrikstrid--ocaml-findlib-allow-x-compile branch from 0eda23f to 739b269 Compare January 30, 2023 13:02
@Mindavi
Copy link
Copy Markdown
Contributor

Mindavi commented Jan 30, 2023

Seems like a good idea but I don't know anything about ocaml :)

@ofborg ofborg Bot added 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Jan 30, 2023
@ulrikstrid ulrikstrid requested a review from vbgl January 30, 2023 13:41
@symphorien
Copy link
Copy Markdown
Member

I cannot reproduce the issue, inside nix-shell -A pkgsStatic.ocamlPackages.batteries I get

[nix-shell:~/src/nixpkgs]$ ocamlfind list
bigarray            (version: [distributed with Ocaml])
bytes               (version: [distributed with OCaml 4.02 or above])
camlp-streams       (version: n/a)
compiler-libs       (version: [distributed with Ocaml])
compiler-libs.bytecomp (version: [distributed with Ocaml])
compiler-libs.common (version: [distributed with Ocaml])
compiler-libs.native-toplevel (version: [distributed with Ocaml])
compiler-libs.optcomp (version: [distributed with Ocaml])
compiler-libs.toplevel (version: [distributed with Ocaml])
dynlink             (version: [distributed with Ocaml])
findlib             (version: 1.9.6)
findlib.dynload     (version: 1.9.6)
findlib.internal    (version: 1.9.6)
findlib.top         (version: 1.9.6)
num                 (version: 1.0)
num-top             (version: 1.1)
num.core            (version: 1.0)
oUnit               (version: 2.2.6)
oUnit.advanced      (version: n/a)
oUnit.threads       (version: n/a)
ocamldoc            (version: [distributed with Ocaml])
ounit2              (version: 2.2.6)
ounit2.advanced     (version: 2.2.6)
ounit2.threads      (version: 2.2.6)
qcheck              (version: 0.20)
qcheck-core         (version: 0.20)
qcheck-core.runner  (version: 0.20)
qcheck-ounit        (version: 0.20)
seq                 (version: [distributed with OCaml 4.07 or above])
stdlib              (version: [distributed with Ocaml])
stdlib-shims        (version: 0.3.0)
str                 (version: [distributed with Ocaml])
threads             (version: [distributed with Ocaml])
threads.none        (version: [internal])
threads.posix       (version: [internal])
unix                (version: [distributed with Ocaml])

so no clash


An alternative to hard coding the list of builtins would be to run ocamlfind list with empty OCAMLPATH.

@ulrikstrid
Copy link
Copy Markdown
Member Author

@symphorien i think that's because you only have the musl compiler. We saw it in our OCaml overlays when compiling to arm64.

@symphorien
Copy link
Copy Markdown
Member

does cross x86 -> arm64 work at all with ocaml? I thought it only worked for platforms which can execute one-another

@anmonteiro
Copy link
Copy Markdown
Member

does cross x86 -> arm64 work at all with ocaml? I thought it only worked for platforms which can execute one-another

yup, a few patches are required but we set it up successfully in our ocaml-focused nix-overlays. Example working PR:

nix-ocaml/nix-overlays#621

@symphorien
Copy link
Copy Markdown
Member

cool!

However it would be nice to provide a way to reproduce the issue on vanilla nixpkgs so that I can review.

@Et7f3
Copy link
Copy Markdown
Contributor

Et7f3 commented Jan 30, 2023

Could we split ocaml compiler instead ? so that it has native stdlib when compiling native binary and cross stdlib to compile cross library ?

@ulrikstrid
Copy link
Copy Markdown
Member Author

Could we split ocaml compiler instead ? so that it has native stdlib when compiling native binary and cross stdlib to compile cross library ?

I think this is a bigger effort 😅

@symphorien I'm trying to find a way to repro in this repo.

@anmonteiro what would need to be upstreamed here to have good crosscompilation? The OCaml patches + what?

@Mindavi
Copy link
Copy Markdown
Contributor

Mindavi commented Feb 9, 2023

This doesn't seem that bad to merge anyway to me, but a comment might be warranted on the line above?

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@phanirithvij
Copy link
Copy Markdown
Member

bumping to know whether it is still relevant

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 25, 2025
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 26, 2025
@ulrikstrid ulrikstrid closed this Nov 10, 2025
@ulrikstrid ulrikstrid deleted the ulrikstrid--ocaml-findlib-allow-x-compile branch November 10, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants