Skip to content

Commit 442a262

Browse files
authored
Merge pull request #12097 from ConnorBaker/feat/meson-O3-LTO
packaging: use release builds and LTO by default
2 parents deb3533 + 359a084 commit 442a262

File tree

24 files changed

+15
-48
lines changed

24 files changed

+15
-48
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@ add_project_arguments(
1616
'-Wno-deprecated-declarations',
1717
language : 'cpp',
1818
)
19-
20-
if get_option('buildtype') not in ['debug']
21-
add_project_arguments('-O3', language : 'cpp')
22-
endif

packaging/dependencies.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ let
6666

6767
mesonLayer = finalAttrs: prevAttrs:
6868
{
69+
# NOTE:
70+
# As of https://github.com/NixOS/nixpkgs/blob/8baf8241cea0c7b30e0b8ae73474cb3de83c1a30/pkgs/by-name/me/meson/setup-hook.sh#L26,
71+
# `mesonBuildType` defaults to `plain` if not specified. We want our Nix-built binaries to be optimized by default.
72+
# More on build types here: https://mesonbuild.com/Builtin-options.html#details-for-buildtype.
73+
mesonBuildType = "release";
74+
# NOTE:
75+
# Users who are debugging Nix builds are expected to set the environment variable `mesonBuildType`, per the
76+
# guidance in https://github.com/NixOS/nix/blob/8a3fc27f1b63a08ac983ee46435a56cf49ebaf4a/doc/manual/source/development/debugging.md?plain=1#L10.
77+
# For this reason, we don't want to refer to `finalAttrs.mesonBuildType` here, but rather use the environment variable.
78+
preConfigure = prevAttrs.preConfigure or "" + ''
79+
case "$mesonBuildType" in
80+
release|minsize) appendToVar mesonFlags "-Db_lto=true" ;;
81+
*) appendToVar mesonFlags "-Db_lto=false" ;;
82+
esac
83+
'';
6984
nativeBuildInputs = [
7085
pkgs.buildPackages.meson
7186
pkgs.buildPackages.ninja

src/libcmd/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-cmd', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libexpr-c/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-expr-c', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libexpr-test-support/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-expr-test-support', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libexpr-tests/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-expr-tests', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libexpr/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-expr', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libfetchers-tests/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-fetchers-tests', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libfetchers/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-fetchers', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

src/libflake-c/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project('nix-flake-c', 'cpp',
44
'cpp_std=c++2a',
55
# TODO(Qyriad): increase the warning level
66
'warning_level=1',
7-
'debug=true',
8-
'optimization=2',
97
'errorlogs=true', # Please print logs for tests that fail
108
],
119
meson_version : '>= 1.1',

0 commit comments

Comments
 (0)