Skip to content
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

meson: use optimization level 3 and LTO by default #12097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ConnorBaker
Copy link
Contributor

Motivation

Let Meson handle optimization arguments for us.

Additionally, enables building with LTO, which was lost in the transition to Meson.

Testing

I'm not sure what the state-of-the-art is for benchmarking Nix. Any pointers?


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority fetching Networking with the outside (non-Nix) world, input locking c api Nix as a C library with a stable interface labels Dec 21, 2024
@Ericson2314
Copy link
Member

Won't this slow down debug builds?

@ConnorBaker
Copy link
Contributor Author

Won't this slow down debug builds?

In which sense? Speed of compilation, speed of execution, or something else?

I guess it could slow down compilation depending on how costly the level three optimizations are. I don’t know that LTO is a bad idea, generally.

I could refactor this to conditionally set optimization level to three when it isn’t a debug build, similar to what I removed in the refactor.

I’d also really appreciate any pointers you can give on reliably benchmarking Nix!

@MagicRB
Copy link
Contributor

MagicRB commented Dec 21, 2024

This should be 100% disabled for debug builds, optimization can make chabnes to the code which make debugging really hard, inlining, the infamous "where did my code go? right it was optimized away/unrolled"

@ConnorBaker
Copy link
Contributor Author

Should debug builds be built without any optimization? Because that’s not what happens currently :/

@MagicRB
Copy link
Contributor

MagicRB commented Dec 21, 2024

I'm not part of the Nix dev team, but in my experience having all optimizations off greatly helps staring at code in gdb/lldb. Since the machine code is closer to what's actually written the source code

@Ericson2314
Copy link
Member

Yes for debug builds we like less optimization both because it means faster builds, and because it means the debug symbols are easier to understand / closer to the code.

@ConnorBaker
Copy link
Contributor Author

@Ericson2314 so should debug builds happen without any optimization, or with optimization level two (which is what happens prior to this PR)?

@Ericson2314
Copy link
Member

I think without any optimization, right @edolstra?

We could have the full nix builds instead specify more optimization with mesonFlags I think?

@Mic92
Copy link
Member

Mic92 commented Dec 25, 2024

@Ericson2314 so should debug builds happen without any optimization, or with optimization level two (which is what happens prior to this PR)?

We should use -Og rather than -O0. It's optimization with debugger in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c api Nix as a C library with a stable interface fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants