Skip to content

Commit ec59646

Browse files
committed
Merge remote-tracking branch 'detsys/main' into provenance-detsys
2 parents 7f9efc6 + d69e6ae commit ec59646

43 files changed

Lines changed: 339 additions & 90 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
- uses: DeterminateSystems/flakehub-cache-action@main
5353
- run: nix build .#packages.${{ inputs.system }}.default .#packages.${{ inputs.system }}.binaryTarball --no-link -L
5454
- run: nix build .#packages.${{ inputs.system }}.binaryTarball --out-link tarball
55+
- run: nix build .#packages.${{ inputs.system }}.nix-cli-static --no-link -L
5556
- uses: actions/upload-artifact@v4
5657
with:
5758
name: ${{ inputs.system }}

doc/manual/source/development/building.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ For historic reasons and backward-compatibility, some CPU and OS identifiers are
143143
|-----------------------------|-------------------------|---------------------|
144144
| `x86` | | `i686` |
145145
| `arm` | | `host_machine.cpu()`|
146+
| `arm64` | | `host_machine.cpu()`|
146147
| `ppc` | `little` | `powerpcle` |
147148
| `ppc64` | `little` | `powerpc64le` |
148149
| `ppc` | `big` | `powerpc` |

flake.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@
470470
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents2.${pkgName};
471471
}
472472
)
473+
// {
474+
"${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName};
475+
}
473476
)
474477
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (
475478
stdenvName:
@@ -479,6 +482,10 @@
479482
"${pkgName}-${stdenvName}" =
480483
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName};
481484
}
485+
// lib.optionalAttrs supportsCross {
486+
"${pkgName}-${stdenvName}-static" =
487+
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.pkgsStatic.nixComponents2.${pkgName};
488+
}
482489
)
483490
)
484491
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {

nix-meson-build-support/common/meson.build

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,14 @@ endif
6565
# Darwin ld doesn't like "X.Y.ZpreABCD+W"
6666
nix_soversion = meson.project_version().split('+')[0].split('pre')[0]
6767

68+
cxx = meson.get_compiler('cpp')
69+
70+
# Clang does not support prelinking on static builds
71+
if cxx.get_id() == 'clang' and get_option('default_library') == 'static'
72+
prelink = false
73+
else
74+
prelink = true
75+
endif
76+
6877
subdir('assert-fail')
6978
subdir('asan-options')

nix-meson-build-support/default-system-cpu/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ if (host_machine.cpu_family() in [ 'ppc64', 'ppc' ]) and host_machine.endian() =
1414
nix_system_cpu += 'le'
1515
elif host_machine.cpu_family() in [ 'mips64', 'mips' ] and host_machine.endian() == 'little'
1616
nix_system_cpu += 'el'
17-
elif host_machine.cpu_family() == 'arm'
17+
elif host_machine.cpu_family() in [ 'arm', 'arm64' ]
1818
nix_system_cpu = host_machine.cpu()
1919
endif

packaging/dependencies.nix

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,41 @@ in
1616
scope: {
1717
inherit stdenv;
1818

19+
libblake3 =
20+
(pkgs.libblake3.override {
21+
inherit stdenv;
22+
# Nixpkgs disables tbb on static
23+
useTBB = !stdenv.hostPlatform.isStatic;
24+
})
25+
# For some reason that is not clear, it is wanting to use libgcc_eh which is not available.
26+
# Force this to be built with compiler-rt & libunwind over libgcc_eh works.
27+
# Issue: https://github.com/NixOS/nixpkgs/issues/177129
28+
.overrideAttrs
29+
(
30+
attrs:
31+
lib.optionalAttrs
32+
(
33+
stdenv.cc.isClang
34+
&& stdenv.hostPlatform.isStatic
35+
&& stdenv.cc.libcxx != null
36+
&& stdenv.cc.libcxx.isLLVM
37+
)
38+
{
39+
NIX_CFLAGS_COMPILE = [
40+
"-rtlib=compiler-rt"
41+
"-unwindlib=libunwind"
42+
];
43+
44+
buildInputs = [
45+
pkgs.llvmPackages.libunwind
46+
];
47+
}
48+
);
49+
1950
boehmgc =
2051
(pkgs.boehmgc.override {
2152
enableLargeConfig = true;
53+
inherit stdenv;
2254
}).overrideAttrs
2355
(attrs: {
2456
# Increase the initial mark stack size to avoid stack
@@ -27,7 +59,33 @@ scope: {
2759
# small, run Nix with GC_PRINT_STATS=1 and look for messages
2860
# such as `Mark stack overflow`, `No room to copy back mark
2961
# stack`, and `Grew mark stack to ... frames`.
30-
NIX_CFLAGS_COMPILE = "-DINITIAL_MARK_STACK_SIZE=1048576";
62+
NIX_CFLAGS_COMPILE = [
63+
"-DINITIAL_MARK_STACK_SIZE=1048576"
64+
]
65+
# For some reason that is not clear, it is wanting to use libgcc_eh which is not available.
66+
# Force this to be built with compiler-rt & libunwind over libgcc_eh works.
67+
# Issue: https://github.com/NixOS/nixpkgs/issues/177129
68+
++
69+
lib.optionals
70+
(
71+
stdenv.cc.isClang
72+
&& stdenv.hostPlatform.isStatic
73+
&& stdenv.cc.libcxx != null
74+
&& stdenv.cc.libcxx.isLLVM
75+
)
76+
[
77+
"-rtlib=compiler-rt"
78+
"-unwindlib=libunwind"
79+
];
80+
81+
buildInputs =
82+
(attrs.buildInputs or [ ])
83+
++ lib.optional (
84+
stdenv.cc.isClang
85+
&& stdenv.hostPlatform.isStatic
86+
&& stdenv.cc.libcxx != null
87+
&& stdenv.cc.libcxx.isLLVM
88+
) pkgs.llvmPackages.libunwind;
3189
});
3290

3391
lowdown =
@@ -74,6 +132,7 @@ scope: {
74132
"--with-thread"
75133
];
76134
enableIcu = false;
135+
inherit stdenv;
77136
}).overrideAttrs
78137
(old: {
79138
# Need to remove `--with-*` to use `--with-libraries=...`
@@ -82,4 +141,10 @@ scope: {
82141
});
83142

84143
wasmtime = pkgs.callPackage ./wasmtime.nix { };
144+
145+
curl = pkgs.curl.override {
146+
# libpsl uses a data file needed at runtime, not useful for nix.
147+
pslSupport = !stdenv.hostPlatform.isStatic;
148+
idnSupport = !stdenv.hostPlatform.isStatic;
149+
};
85150
}

src/libcmd/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ this_library = library(
9999
dependencies : deps_public + deps_private + deps_other,
100100
include_directories : include_dirs,
101101
link_args : linker_export_flags,
102-
prelink : true, # For C++ static initializers
102+
prelink : prelink, # For C++ static initializers
103103
install : true,
104104
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
105105
)

src/libexpr-c/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ this_library = library(
5454
dependencies : deps_public + deps_private + deps_other,
5555
include_directories : include_dirs,
5656
link_args : linker_export_flags,
57-
prelink : true, # For C++ static initializers
57+
prelink : prelink, # For C++ static initializers
5858
install : true,
5959
)
6060

src/libexpr-test-support/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ this_library = library(
5050
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
5151
# is available. See also ../libutil/build.meson
5252
link_args : linker_export_flags + [ '-lrapidcheck' ],
53-
prelink : true, # For C++ static initializers
53+
prelink : prelink, # For C++ static initializers
5454
install : true,
5555
)
5656

src/libexpr/meson.build

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ project(
77
# TODO(Qyriad): increase the warning level
88
'warning_level=1',
99
'errorlogs=true', # Please print logs for tests that fail
10+
'unity=on',
11+
'unity_size=1024',
1012
],
1113
meson_version : '>= 1.1',
1214
license : 'LGPL-2.1-or-later',
@@ -77,6 +79,17 @@ endif
7779
# Used in public header. Affects ABI!
7880
configdata_pub.set('NIX_USE_BOEHMGC', bdw_gc.found().to_int())
7981

82+
link_args = []
83+
84+
wasmtime_required = get_option('wasm').disable_if(
85+
get_option('default_library') == 'static',
86+
error_message : 'Building with wasmtime and static linking is not supported',
87+
)
88+
89+
if wasmtime_required.enabled()
90+
link_args += '-lwasmtime'
91+
endif
92+
8093
toml11 = dependency(
8194
'toml11',
8295
version : '>=3.7.0',
@@ -156,14 +169,12 @@ sources = files(
156169
'eval-cache.cc',
157170
'eval-error.cc',
158171
'eval-gc.cc',
159-
'eval-profiler-settings.cc',
160172
'eval-profiler.cc',
161173
'eval-settings.cc',
162174
'eval.cc',
163175
'function-trace.cc',
164176
'get-drvs.cc',
165177
'json-to-value.cc',
166-
'lexer-helpers.cc',
167178
'nixexpr.cc',
168179
'parallel-eval.cc',
169180
'paths.cc',
@@ -216,6 +227,8 @@ parser_library = static_library(
216227
'nixexpr-parser',
217228
parser_tab,
218229
lexer_tab,
230+
# Putting eval-profiler-settings.cc here to work around an inscrutable gcc compiler error when doing a unity build.
231+
files('eval-profiler-settings.cc', 'lexer-helpers.cc'),
219232
cpp_args : parser_library_cpp_args,
220233
dependencies : deps_public + deps_private + deps_other,
221234
include_directories : include_dirs,
@@ -226,6 +239,7 @@ parser_library = static_library(
226239
override_options : [
227240
'b_ndebug=@0@'.format(not get_option('debug')),
228241
'b_lto=@0@'.format(get_option('b_lto') and cxx.get_id() != 'gcc'),
242+
'unity=off',
229243
],
230244
)
231245

@@ -239,9 +253,9 @@ this_library = library(
239253
soversion : nix_soversion,
240254
dependencies : deps_public + deps_private + deps_other,
241255
include_directories : include_dirs,
242-
link_args : linker_export_flags + [ '-lwasmtime' ],
256+
link_args : linker_export_flags + link_args,
243257
link_whole : [ parser_library ],
244-
prelink : true, # For C++ static initializers
258+
prelink : prelink, # For C++ static initializers
245259
install : true,
246260
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
247261
)

0 commit comments

Comments
 (0)