Skip to content

openbsd: init at 7.5 #311836

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

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ let
else if final.isAndroid then "bionic"
else if final.isLinux /* default */ then "glibc"
else if final.isFreeBSD then "fblibc"
else if final.isOpenBSD then "oblibc"
else if final.isNetBSD then "nblibc"
else if final.isAvr then "avrlibc"
else if final.isGhcjs then null
Expand Down
5 changes: 5 additions & 0 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ rec {
useLLVM = true;
};

x86_64-openbsd = {
config = "x86_64-unknown-openbsd";
useLLVM = true;
};

#
# WASM
#
Expand Down
1 change: 1 addition & 0 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ rec {
elem (elemAt l 2) [ "wasi" "redox" "mmixware" "ghcjs" "mingw32" ] ||
hasPrefix "freebsd" (elemAt l 2) ||
hasPrefix "netbsd" (elemAt l 2) ||
hasPrefix "openbsd" (elemAt l 2) ||
hasPrefix "genode" (elemAt l 2)
then {
cpu = elemAt l 0;
Expand Down
14 changes: 12 additions & 2 deletions pkgs/development/compilers/llvm/18/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja
, preLibcCrossHeaders
, libxml2, python3, fetchFromGitHub, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith
, libxml2, python3, fetchFromGitHub, fetchpatch, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
, targetLlvm
Expand Down Expand Up @@ -146,6 +146,11 @@ in let
# https://reviews.llvm.org/D51899
./clang/gnu-install-dirs.patch
../common/clang/add-nostdlibinc-flag.patch
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/48c1364200b5649dda2f9ccbe382b0bd908b99de.patch";
sha256 = "sha256-beSydky0P/06YDLk0GJDtcREpMcU2FspxuYU6EnQGfA=";
stripLen = 1;
})
(substituteAll {
src = ../common/clang/clang-at-least-16-LLVMgold-path.patch;
libllvmLibdir = "${tools.libllvm.lib}/lib";
Expand Down Expand Up @@ -391,7 +396,12 @@ in let
# so: we use the clang from this LLVM package set instead of the regular
# stdenv's compiler.
libcxx = callPackage ../common/libcxx {
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
patches = [
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/1118c2e05e67a36ed8ca250524525cdb66a55256.patch";
sha256 = "sha256-2lDO9UsglvYAxDG3/iTXqGVHn1Hq3O7wtkCUb9I/Buc=";
})
] ++ lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
# https://github.com/llvm/llvm-project/issues/64226
./libcxx/0001-darwin-10.12-mbstate_t-fix.patch
];
Expand Down
15 changes: 14 additions & 1 deletion pkgs/development/compilers/llvm/common/compiler-rt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
, libllvm
, linuxHeaders
, libxcrypt

# Some platforms have switched to using compiler-rt, but still want a
# libgcc.a for ABI compat purposes. The use case would be old code that
# expects to link `-lgcc` but doesn't care exactly what its contents
# are, so long as it provides some builtins.
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD

# In recent releases, the compiler-rt build seems to produce
# many `libclang_rt*` libraries, but not a single unified
# `libcompiler_rt` library, at least under certain configurations. Some
# platforms stil expect this, however, so we symlink one into place.
, forceLinkCompilerRt ? stdenv.hostPlatform.isOpenBSD
}:

let
Expand Down Expand Up @@ -149,7 +160,9 @@ stdenv.mkDerivation ({
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'' + lib.optionalString doFakeLibgcc ''
ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
ln -s $out/lib/*/libclang_rt.builtins-*.a $out/lib/libgcc.a
'' + lib.optionalString forceLinkCompilerRt ''
ln -s $out/lib/*/libclang_rt.builtins-*.a $out/lib/libcompiler_rt.a
'';

meta = llvm_meta // {
Expand Down
6 changes: 0 additions & 6 deletions pkgs/development/compilers/llvm/common/libcxx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ let

cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
# but that does not appear to be the case for example when building
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/bsd/freebsd/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
}
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;

install-wrapper = builtins.readFile ./install-wrapper.sh;
install-wrapper = builtins.readFile ../../lib/install-wrapper.sh;
}
12 changes: 6 additions & 6 deletions pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# HACK: to ensure parent directories exist. This emulates GNU
# install’s -D option. No alternative seems to exist in BSD install.
let
binstall = writeShellScript "binstall" ''
set -eu
for last in "$@"; do true; done
mkdir -p $(dirname $last)
@out@/bin/xinstall "$@"
'';
binstall = writeShellScript "binstall" (
builtins.readFile ../../../lib/install-wrapper.sh
+ ''
@out@/bin/xinstall "''${args[@]}"
''
);
in
mkDerivation {
path = "usr.bin/xinstall";
Expand Down
75 changes: 75 additions & 0 deletions pkgs/os-specific/bsd/netbsd/pkgs/make-rules.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
lib,
mkDerivation,
fetchNetBSD,
stdenv,
bsdSetupHook,
netbsdSetupHook,
rsync,
}:

mkDerivation {
path = "share/mk";
sha256 = "0w9x77cfnm6zwy40slradzi0ip9gz80x6lk7pvnlxzsr2m5ra5sy";
version = "9.2";
noCC = true;

buildInputs = [ ];
nativeBuildInputs = [
bsdSetupHook
netbsdSetupHook
rsync
];

dontBuild = true;

postPatch =
''
substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
--replace '-o ''${DOCOWN}' "" \
--replace '-g ''${DOCGRP}' ""
for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
substituteInPlace $mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' ""
done
substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
--replace '-o ''${KMODULEOWN}' "" \
--replace '-g ''${KMODULEGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
--replace '-o ''${MANOWN}' "" \
--replace '-g ''${MANGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
--replace '-o ''${NLSOWN}' "" \
--replace '-g ''${NLSGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' "" \
--replace '-o ''${RUMPBINOWN}' "" \
--replace '-g ''${RUMPBINGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""

substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
--replace /bin/rm rm
''
+ lib.optionalString stdenv.targetPlatform.isDarwin ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Was changing this from stdenv.isDarwin to stdenv.targetPlatform.isDarwin intentional?

Copy link
Member

Choose a reason for hiding this comment

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

The make rules are always a build-time input to something, so I don't really get the sense of getting in the host platform of the rules themselves (i.e. the build platform of the thing to be built).

Copy link
Member

Choose a reason for hiding this comment

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

I don't know the purpose of this bit though, which doesn't help either.

substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
--replace '-Wl,--fatal-warnings' "" \
--replace '-Wl,--warn-shared-textrel' ""
'';

installPhase = ''
cp -r . $out
'';
}
52 changes: 6 additions & 46 deletions pkgs/os-specific/bsd/netbsd/pkgs/make.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mkDerivation,
fetchNetBSD,
stdenv,
make-rules,
}:

mkDerivation {
Expand All @@ -11,53 +12,12 @@ mkDerivation {
version = "9.2";

postPatch =
''
substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
--replace '-o ''${DOCOWN}' "" \
--replace '-g ''${DOCGRP}' ""
for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
substituteInPlace $mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' ""
done
substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
--replace '-o ''${KMODULEOWN}' "" \
--replace '-g ''${KMODULEGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
--replace '-o ''${MANOWN}' "" \
--replace '-g ''${MANGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
--replace '-o ''${NLSOWN}' "" \
--replace '-g ''${NLSGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' "" \
--replace '-o ''${RUMPBINOWN}' "" \
--replace '-g ''${RUMPBINGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""

# make needs this to pick up our sys make files
export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""

substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
--replace /bin/rm rm
''
+ lib.optionalString stdenv.isDarwin ''
substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
--replace '-Wl,--fatal-warnings' "" \
--replace '-Wl,--warn-shared-textrel' ""
make-rules.postPatch
+ ''
# make needs this to pick up our sys make files
appendToVar NIX_CFLAGS_COMPILE "-D_PATH_DEFSYSPATH=\"$out/share/mk\""
'';

postInstall = ''
make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install
'';
Expand Down
9 changes: 6 additions & 3 deletions pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
netbsdSetupHook,
rsync,
make,
make-rules,
}:

mkDerivation {
Expand All @@ -22,7 +23,9 @@ mkDerivation {

postPatch = ''
patchShebangs $COMPONENT_PATH/configure
${make.postPatch}

# make needs this to pick up our sys make files
appendToVar NIX_CFLAGS_COMPILE "-D_PATH_DEFSYSPATH=\"$out/share/mk\""
'';

buildPhase = ''
Expand All @@ -39,10 +42,10 @@ mkDerivation {
install -D nbmake $out/bin/nbmake
ln -s $out/bin/nbmake $out/bin/make
mkdir -p $out/share
cp -r $BSDSRCDIR/share/mk $out/share/mk
cp -r ${make-rules} $out/share/mk

runHook postInstall
'';

extraPaths = [ make.src ] ++ make.extraPaths;
extraPaths = [ make.src ];
}
49 changes: 49 additions & 0 deletions pkgs/os-specific/bsd/openbsd/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
stdenv,
lib,
stdenvNoCC,
makeScopeWithSplicing',
generateSplicesForMkScope,
pkgs,
buildPackages,
netbsd,
}:

makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope "openbsd";
f = (
self:
lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
}
// {
libc = self.callPackage ./pkgs/libc/package.nix {
inherit (self) csu include lorder;
inherit (buildPackages.openbsd) makeMinimal;
inherit (buildPackages.netbsd)
install
gencat
rpcgen
tsort
;
};
makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; };
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildPackages.netbsd) install;
};
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildPackages.openbsd) makeMinimal;
inherit (buildPackages.netbsd) install rpcgen mtree;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (self) include;
inherit (buildPackages.openbsd) makeMinimal;
inherit (buildPackages.netbsd) install;
};
make-rules = self.callPackage ./pkgs/make-rules/package.nix { };
lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; };
}
);
}
22 changes: 22 additions & 0 deletions pkgs/os-specific/bsd/openbsd/pkgs/csu.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
lib,
mkDerivation,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
include,
}:

mkDerivation {
path = "lib/csu";
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
];
buildInputs = [ include ];
meta.platforms = lib.platforms.openbsd;
extraPaths = [ "libexec/ld.so" ];
}
Loading