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

lib.systems: add various has* flags useful for embedded systems #352629

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

kuruczgy
Copy link
Contributor

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Oct 31, 2024
lib/systems/default.nix Outdated Show resolved Hide resolved
Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

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

Should target staging

@kuruczgy kuruczgy changed the base branch from master to staging October 31, 2024 20:21
kuruczgy added a commit to kuruczgy/lean-esp32 that referenced this pull request Nov 1, 2024
This requires two main changes:
- An update to the nixpkgs patch. It is now based on this draft PR:
  NixOS/nixpkgs#352629
- An update to the Lean runtime, as Lean is updated to v4.10.0. The
  changes come from Lean commit
  0a1a855ba80e51515570439f3d73d3d9414ac053.
@kuruczgy
Copy link
Contributor Author

Thank you both for the feedback.

Before continuing with this, I would like some feedback from someone on the high level concept first. (E.g. the concept is fine, and we don't need to rethink and use some other approach.)

If it's confirmed that this is desirable change, I can update the PR to a non-draft quality one. (Split the two linunwind cases, fix the typos, fix the formatting, rebase onto latest master.)

@FliegendeWurst
Copy link
Member

I think the concept is fine. To convince more people I would suggest showing a use for each new condition.

@kuruczgy
Copy link
Contributor Author

kuruczgy commented Dec 7, 2024

Updated, the major new change is that I now have two separate hasSystemLibunwind and hasStackUnwinding flags. My assumption is that Darwin and FreeBSD want to use a libunwind that comes from "somewhere else" (I assume stdenv handles this for those platforms), though I still had to add some exceptions to match the previous behavior. If someone has knowledge of these platforms please weigh on whether these exceptions are actually needed or were just accidental inconsistencies of the previous logic.

If someone is interested in somewhat of a "real world" use-case for this code, here is my example which originally motivated these changes: https://github.com/kuruczgy/lean-esp32/blob/c912a815d079cd5a3d029771c247e692f5516b71/flake.nix

Notably, targeting embedded platforms using nixpkgs is still very rough, so I expect several more changes to be needed, for example support for picolibc or some saner defaults for the hardening flags (currently a lot of them can blow up code size).

@kuruczgy kuruczgy marked this pull request as ready for review December 7, 2024 17:04
@github-actions github-actions bot added 6.topic: python 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: vim 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Jan 28, 2025
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 28, 2025
@kuruczgy kuruczgy force-pushed the wip/embedded-cross-system branch from 379db2a to d6e71a3 Compare January 28, 2025 22:48
@github-actions github-actions bot removed 6.topic: python 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: vim 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Jan 28, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 28, 2025
@kuruczgy
Copy link
Contributor Author

I believe it should be good now, I changed all references to targetPlatform in the libcxx derivation to hostPlatform.

@kuruczgy kuruczgy marked this pull request as ready for review January 28, 2025 22:58
@alyssais
Copy link
Member

alyssais commented Feb 3, 2025

This looks great! I like how it's exposing all these Darwin/FreeBSD inconsistencies. I've reviewed the lib changes, and ack the package changes but haven't thoroughly reviewed them.

@reckenrode
Copy link
Contributor

reckenrode commented Feb 3, 2025

I need to look over the Darwin changes more closely, but some of the changes appear to be adding the libunwind package on Darwin, which doesn’t seem right. Darwin ships and links libunwind implicitly via libSystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants