Skip to content

Commit 498ea1c

Browse files
authored
Merge pull request #323414 from obsidiansystems/openbsd-libc-minimal
openbsd.libc: Create from constituent pkgs not hack
2 parents 14adad6 + 56c2439 commit 498ea1c

File tree

16 files changed

+267
-74
lines changed

16 files changed

+267
-74
lines changed

pkgs/os-specific/bsd/netbsd/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ makeScopeWithSplicing' {
4040
stdenvLibcMinimal = crossLibcStdenv.override (old: {
4141
cc = old.cc.override {
4242
libc = self.libcMinimal;
43+
noLibc = false;
4344
bintools = old.cc.bintools.override {
4445
libc = self.libcMinimal;
46+
noLibc = false;
4547
sharedLibraryLoader = null;
4648
};
4749
};

pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
lib,
33
stdenvLibcMinimal,
44
mkDerivation,
5-
headers,
65
libcMinimal,
76
librt,
87
}:

pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
lorder,
1212
mandoc,
1313
statHook,
14-
headers,
1514
}:
1615

1716
mkDerivation {
Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
lib,
3+
crossLibcStdenv,
4+
stdenvNoCC,
35
makeScopeWithSplicing',
46
generateSplicesForMkScope,
57
buildPackages,
@@ -19,32 +21,71 @@ makeScopeWithSplicing' {
1921
directory = ./pkgs;
2022
}
2123
// {
22-
libc = self.callPackage ./pkgs/libc/package.nix {
24+
version = "7.5";
25+
26+
stdenvLibcMinimal = crossLibcStdenv.override (old: {
27+
cc = old.cc.override {
28+
libc = self.libcMinimal;
29+
noLibc = false;
30+
bintools = old.cc.bintools.override {
31+
libc = self.libcMinimal;
32+
noLibc = false;
33+
sharedLibraryLoader = null;
34+
};
35+
};
36+
});
37+
38+
makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; };
39+
40+
# The manual callPackages below should in principle be unnecessary, but are
41+
# necessary. See note in ../netbsd/default.nix
42+
43+
include = self.callPackage ./pkgs/include/package.nix {
44+
inherit (buildOpenbsd) makeMinimal;
45+
inherit (buildPackages.netbsd) install rpcgen mtree;
46+
};
47+
48+
csu = self.callPackage ./pkgs/csu.nix {
49+
inherit (self) include;
50+
inherit (buildOpenbsd) makeMinimal;
51+
inherit (buildPackages.netbsd) install;
52+
};
53+
54+
libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix {
2355
inherit (self) csu include;
2456
inherit (buildOpenbsd) makeMinimal;
2557
inherit (buildPackages.netbsd)
2658
install
2759
gencat
60+
tsort
2861
rpcgen
62+
;
63+
};
64+
65+
librpcsvc = self.callPackage ./pkgs/librpcsvc.nix {
66+
inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder;
67+
inherit (buildPackages.netbsd)
68+
install
2969
tsort
70+
statHook
71+
rpcgen
3072
;
3173
};
32-
makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; };
74+
75+
libutil = self.callPackage ./pkgs/libutil.nix {
76+
inherit (self) libcMinimal;
77+
inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder;
78+
inherit (buildPackages.netbsd) install tsort statHook;
79+
};
80+
81+
lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; };
82+
83+
make-rules = self.callPackage ./pkgs/make-rules/package.nix { };
84+
3385
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
34-
inherit (buildPackages.netbsd) install;
86+
inherit (buildPackages.netbsd) install tsort;
3587
inherit (buildPackages.buildPackages) rsync;
3688
};
37-
include = self.callPackage ./pkgs/include/package.nix {
38-
inherit (buildOpenbsd) makeMinimal;
39-
inherit (buildPackages.netbsd) install rpcgen mtree;
40-
};
41-
csu = self.callPackage ./pkgs/csu.nix {
42-
inherit (self) include;
43-
inherit (buildOpenbsd) makeMinimal;
44-
inherit (buildPackages.netbsd) install;
45-
};
46-
make-rules = self.callPackage ./pkgs/make-rules/package.nix { };
47-
lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; };
4889
}
4990
);
5091
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
lib,
3+
symlinkJoin,
4+
libcMinimal,
5+
librthread,
6+
libm,
7+
librpcsvc,
8+
libutil,
9+
version,
10+
}:
11+
12+
symlinkJoin rec {
13+
name = "${pname}-${version}";
14+
pname = "libc-openbsd";
15+
inherit version;
16+
17+
outputs = [
18+
"out"
19+
"dev"
20+
"man"
21+
];
22+
23+
paths =
24+
lib.concatMap
25+
(p: [
26+
(lib.getDev p)
27+
(lib.getLib p)
28+
(lib.getMan p)
29+
])
30+
[
31+
libcMinimal
32+
libm
33+
librthread
34+
librpcsvc
35+
libutil
36+
];
37+
38+
postBuild = ''
39+
rm -r "$out/nix-support"
40+
mkdir -p "$man/share/man"
41+
mv "$out/share"/man* "$man/share/man"
42+
rmdir "$out/share"
43+
fixupPhase
44+
'';
45+
46+
meta.platforms = lib.platforms.openbsd;
47+
}

pkgs/os-specific/bsd/openbsd/pkgs/libc/package.nix renamed to pkgs/os-specific/bsd/openbsd/pkgs/libcMinimal/package.nix

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@
2020

2121
mkDerivation {
2222
noLibc = true;
23-
pname = "libc";
2423
path = "lib/libc";
24+
pname = "libcMinimal-openbsd";
25+
outputs = [
26+
"out"
27+
"dev"
28+
"man"
29+
];
2530
extraPaths = [
2631
"lib/csu/os-note-elf.h"
2732
"sys/arch"
28-
29-
"lib/libm"
30-
"lib/libpthread"
31-
"lib/librpcsvc"
32-
"lib/librpcsvc"
33-
"lib/librthread"
34-
"lib/libutil"
3533
];
3634

3735
patches = [
@@ -48,12 +46,8 @@ mkDerivation {
4846
openbsdSetupHook
4947
makeMinimal
5048
install
51-
flex
52-
byacc
53-
gencat
54-
rpcgen
55-
ctags
5649
tsort
50+
gencat
5751
];
5852

5953
buildInputs = [
@@ -73,49 +67,22 @@ mkDerivation {
7367
) "--undefined-version";
7468

7569
makeFlags = [
76-
"STRIP=-s" # flag to install, not command
7770
"COMPILER_VERSION=clang"
7871
"LIBC_TAGS=no"
7972
];
8073

8174
postInstall = ''
82-
symlink_so () {
83-
pushd $out/lib
84-
ln -s "lib$1".so.* "lib$1.so"
85-
popd
86-
}
87-
88-
symlink_so c
89-
9075
pushd ${include}
91-
find . -type d -exec mkdir -p $out/\{} \;
92-
find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
76+
find include -type d -exec mkdir -p "$dev/{}" ';'
77+
find include '(' -type f -o -type l ')' -exec cp -pr "{}" "$dev/{}" ';'
9378
popd
94-
substituteInPlace $out/include/sys/time.h --replace "defined (_LIBC)" "true"
79+
substituteInPlace "$dev/include/sys/time.h" --replace "defined (_LIBC)" "true"
9580
9681
pushd ${csu}
97-
find . -type d -exec mkdir -p $out/\{} \;
98-
find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
82+
find lib -type d -exec mkdir -p "$out/{}" ';'
83+
find lib '(' -type f -o -type l ')' -exec cp -pr "{}" "$out/{}" ';'
9984
popd
100-
101-
NIX_CFLAGS_COMPILE+=" -B$out/lib"
102-
NIX_CFLAGS_COMPILE+=" -I$out/include"
103-
NIX_LDFLAGS+=" -L$out/lib"
104-
105-
make -C $BSDSRCDIR/lib/libm $makeFlags
106-
make -C $BSDSRCDIR/lib/libm $makeFlags install
107-
symlink_so m
108-
109-
make -C $BSDSRCDIR/lib/librthread $makeFlags
110-
make -C $BSDSRCDIR/lib/librthread $makeFlags install
111-
symlink_so pthread
112-
113-
make -C $BSDSRCDIR/lib/librpcsvc $makeFlags
114-
make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install
115-
symlink_so rpcsv
116-
117-
make -C $BSDSRCDIR/lib/libutil $makeFlags
118-
make -C $BSDSRCDIR/lib/libutil $makeFlags install
119-
symlink_so util
12085
'';
86+
87+
meta.platforms = lib.platforms.openbsd;
12188
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{ lib, mkDerivation }:
2+
3+
mkDerivation {
4+
path = "lib/libm";
5+
6+
libcMinimal = true;
7+
8+
outputs = [
9+
"out"
10+
"man"
11+
];
12+
13+
extraPaths = [ "sys" ];
14+
15+
meta.platforms = lib.platforms.openbsd;
16+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
lib,
3+
mkDerivation,
4+
bsdSetupHook,
5+
openbsdSetupHook,
6+
makeMinimal,
7+
install,
8+
tsort,
9+
lorder,
10+
rpcgen,
11+
statHook,
12+
}:
13+
14+
mkDerivation {
15+
path = "lib/librpcsvc";
16+
17+
libcMinimal = true;
18+
19+
outputs = [
20+
"out"
21+
"dev"
22+
];
23+
24+
nativeBuildInputs = [
25+
bsdSetupHook
26+
openbsdSetupHook
27+
makeMinimal
28+
install
29+
tsort
30+
lorder
31+
rpcgen
32+
statHook
33+
];
34+
35+
makeFlags = [ "INCSDIR=$(dev)/include/rpcsvc" ];
36+
37+
meta.platforms = lib.platforms.openbsd;
38+
}

0 commit comments

Comments
 (0)