Skip to content

Commit

Permalink
Merge pull request #12097 from ConnorBaker/feat/meson-O3-LTO
Browse files Browse the repository at this point in the history
packaging: use release builds and LTO by default
  • Loading branch information
Ericson2314 authored Jan 2, 2025
2 parents deb3533 + 359a084 commit 442a262
Show file tree
Hide file tree
Showing 24 changed files with 15 additions and 48 deletions.
4 changes: 0 additions & 4 deletions nix-meson-build-support/common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ add_project_arguments(
'-Wno-deprecated-declarations',
language : 'cpp',
)

if get_option('buildtype') not in ['debug']
add_project_arguments('-O3', language : 'cpp')
endif
15 changes: 15 additions & 0 deletions packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ let

mesonLayer = finalAttrs: prevAttrs:
{
# NOTE:
# As of https://github.com/NixOS/nixpkgs/blob/8baf8241cea0c7b30e0b8ae73474cb3de83c1a30/pkgs/by-name/me/meson/setup-hook.sh#L26,
# `mesonBuildType` defaults to `plain` if not specified. We want our Nix-built binaries to be optimized by default.
# More on build types here: https://mesonbuild.com/Builtin-options.html#details-for-buildtype.
mesonBuildType = "release";
# NOTE:
# Users who are debugging Nix builds are expected to set the environment variable `mesonBuildType`, per the
# guidance in https://github.com/NixOS/nix/blob/8a3fc27f1b63a08ac983ee46435a56cf49ebaf4a/doc/manual/source/development/debugging.md?plain=1#L10.
# For this reason, we don't want to refer to `finalAttrs.mesonBuildType` here, but rather use the environment variable.
preConfigure = prevAttrs.preConfigure or "" + ''
case "$mesonBuildType" in
release|minsize) appendToVar mesonFlags "-Db_lto=true" ;;
*) appendToVar mesonFlags "-Db_lto=false" ;;
esac
'';
nativeBuildInputs = [
pkgs.buildPackages.meson
pkgs.buildPackages.ninja
Expand Down
2 changes: 0 additions & 2 deletions src/libcmd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-cmd', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libexpr-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-expr-c', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libexpr-test-support/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-expr-test-support', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libexpr-tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-expr-tests', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libexpr/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-expr', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libfetchers-tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-fetchers-tests', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libfetchers/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-fetchers', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libflake-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-flake-c', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libflake-tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-flake-tests', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libflake/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-flake', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libmain-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-main-c', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libmain/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-main', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libstore-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-store-c', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libstore-test-support/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-store-test-support', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libstore-tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-store-tests', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libstore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-store', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
'localstatedir=/nix/var',
],
Expand Down
2 changes: 0 additions & 2 deletions src/libutil-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-util-c', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libutil-test-support/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-util-test-support', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libutil-tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-util-tests', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/libutil/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-util', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
Expand Down
2 changes: 0 additions & 2 deletions src/nix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix', 'cpp',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
'localstatedir=/nix/var',
],
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project('nix-functional-tests',
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.3',
Expand Down

0 comments on commit 442a262

Please sign in to comment.