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

openbsd: init at 7.5 #311836

Merged
merged 6 commits into from
May 29, 2024
Merged

openbsd: init at 7.5 #311836

merged 6 commits into from
May 29, 2024

Conversation

ali-abrar
Copy link
Contributor

@ali-abrar ali-abrar commented May 15, 2024

Description of changes

Add OpenBSD support similar to FreeBSD/NetBSD. We use some NetBSD tools to help bootstrap. Currently these are known o build:

nix-build -A pkgsCross.x86_64-openbsd.hello
nix-build -A pkgsCross.x86_64-openbsd.zlib

Actually running these OpenBSD executables on OpenBSD will take more work, but @Ericson2314 thinks that is fine for now, because it is easier to fix that after there is a building foundation.

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.05 Release Notes (or backporting 23.05 and 23.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.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label May 15, 2024
Copy link
Contributor

@rhelmot rhelmot left a comment

Choose a reason for hiding this comment

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

no showstoppers, just some questions and advice from the freebsd mines

pkgs/os-specific/bsd/openbsd/pkgs/include/package.nix Outdated Show resolved Hide resolved

make -C $BSDSRCDIR/lib/libutil $makeFlags
make -C $BSDSRCDIR/lib/libutil $makeFlags install
symlink_so util
Copy link
Contributor

Choose a reason for hiding this comment

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

What packages have you tried compiling with this libc? I found that there were actually a bunch more libraries on freebsd which were required pretty much constantly, once you got into more interesting applications, like rust packages and stuff built with meson.

Copy link
Member

Choose a reason for hiding this comment

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

Just the basics, we will also need to add more stuff

pkgs/os-specific/bsd/openbsd/pkgs/mkDerivation.nix Outdated Show resolved Hide resolved
@Ericson2314 Ericson2314 force-pushed the aa-openbsd-1 branch 2 times, most recently from 9315838 to eda41d7 Compare May 15, 2024 06:26
Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

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

First, thank you so much for splitting this into small, easily reviewable commits.

How come we're using NetBSD make and working around its differences instead of just building OpenBSD make?

pkgs/os-specific/bsd/netbsd/pkgs/make.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/llvm/17/default.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/llvm/17/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/openbsd/pkgs/make-rules/ar.patch Outdated Show resolved Hide resolved
@Ericson2314
Copy link
Member

@alyssais

How come we're using NetBSD make and working around its differences instead of just building OpenBSD make?

OpenBSD doesn't have any tools/compat or similar way to build its programs with host platform != OpenBSD. So rather than fight hard to build the nativeBuildInputs we'd need, we just cut the Gordian knot and used NetBSD ones.

I am still chuckling about this :)

@ali-abrar ali-abrar force-pushed the aa-openbsd-1 branch 9 times, most recently from 774a4b3 to 8fce018 Compare May 16, 2024 14:44
@ofborg ofborg bot requested review from sternenseemann and dtzWill May 16, 2024 15:27
@Ericson2314 Ericson2314 added the backport release-24.05 Backport PR automatically label May 26, 2024
Ericson2314 and others added 5 commits May 26, 2024 10:55
Co-authored-by: Rahul Butani <rrbutani@users.noreply.github.com>
See: https://github.com/NixOS/nixpkgs/pull/246577/files#r1600650238

This code was breaking some thing for me, and I believe it was a
mistake. I hink we *do* wanna link libc, since libc++ depends on it, but
*don't* want to link an already-existing C++ standard library
implementation. `-nostdlib++` without `-nostdlib` therefore seems
correct to me.

Without this change, we do indeed fail to link OpenBSD.
See the code comments for details

Also replace a bad hard-coded `freebsd` with a flexible `*` wildcard in
the `doFakeLibgcc` implementation.
@ofborg ofborg bot requested a review from alyssais May 26, 2024 16:01
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
@Ericson2314 Ericson2314 merged commit 61c678f into NixOS:master May 29, 2024
28 checks passed
@Ericson2314 Ericson2314 deleted the aa-openbsd-1 branch May 29, 2024 17:42
Copy link
Contributor

Successfully created backport PR for release-24.05:

@afh
Copy link
Member

afh commented May 29, 2024

Glad to see this PR has been merged, thank you for your work, @ali-abrar, can't wait to try it out! 💯

@foolnotion
Copy link
Contributor

Sorry but this seems to break clang-18.1.6 on linux:

❯ nix log /nix/store/synw5z7kjmp7gmg4knh4ikaffprbzr3m-clang-18.1.6.drv^\*
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/pkdznhza3cbgdixj2czjw6qi3v8wfpir-clang-src-18.1.6
source root is clang-src-18.1.6/clang
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/4qh1l55wx654v0ls51dg1wdi5xy93w9b-purity.patch
patching file lib/Driver/ToolChains/Gnu.cpp
applying patch /nix/store/fk8qk07cl9m7wkjb0xc0hphbh3vrxfqh-gnu-install-dirs.patch
patching file cmake/modules/AddClang.cmake
patching file lib/Headers/CMakeLists.txt
Hunk #1 succeeded at 498 (offset 25 lines).
patching file tools/libclang/CMakeLists.txt
Hunk #1 succeeded at 246 (offset 12 lines).
patching file tools/scan-build-py/CMakeLists.txt
applying patch /nix/store/gxqzh9x4wmiv4jpbvla3z7i26zkkacqd-add-nostdlibinc-flag.patch
patching file lib/Driver/Driver.cpp
Hunk #1 succeeded at 499 (offset 8 lines).
applying patch /nix/store/ycw68pzfjx00fm99rqlvfnn7hssnzakc-48c1364200b5649dda2f9ccbe382b0bd908b99de.patch
patching file lib/Driver/ToolChains/OpenBSD.cpp
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file lib/Driver/ToolChains/OpenBSD.cpp.rej

@alyssais
Copy link
Member

Ah I wonder if that's because we updated LLVM and now the patch is already there and doesn't need backporting any more.

@paparodeo
Copy link
Contributor

patches reverted in: #315790
patches were the last 2 changes applied before 18.1.6 was tagged.
https://github.com/llvm/llvm-project/commits/llvmorg-18.1.6/

@Ericson2314
Copy link
Member

Ericson2314 commented May 30, 2024

Sorry about that! Though it is nice LLVM 18 is already upgraded :)

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.

10 participants