-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Apply cpu-optimisation to Rust projects #15544
Merged
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c344a3f
Apply cpu-optimisation to Rust projects (hardcoded)
Tokarak a072508
Revert "Apply cpu-optimisation to Rust projects (hardcoded)"
Tokarak 066a888
Add rustflags_target_cpu method
Tokarak b4dd639
Use rustflags_target_cpu
Tokarak d4bfbb1
Remove FIXMEs
Tokarak 2bd20ea
Fix
Tokarak c698174
Fix error on empty target-cpu
Tokarak cccad3e
Line break
Tokarak 261f55a
Prepare to migrate to RUSTFLAGS
Tokarak 2133da8
Set target-cpu through RUSTFLAGS
Tokarak 9a99b93
Add RUSTFLAGS to ENV/super
Tokarak 9a19f5b
Refactor to use oldest_cpu
Tokarak 73c339d
Style changes
Tokarak 40aa419
More cpus in rust_optimisation_flags
Tokarak 87158ac
Improve logic (code review)
Tokarak 55bdbab
brew style --fix
Tokarak 521fdcb
Wording
Tokarak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,16 @@ def optimization_flags | |||||||||||||
end | ||||||||||||||
alias generic_optimization_flags optimization_flags | ||||||||||||||
|
||||||||||||||
# Only give values where it is an improvement over rust cpu defaults | ||||||||||||||
# Rust already defaults to the oldest supported cpu for each target-triple | ||||||||||||||
# Including apple-m1 since Rust 1.71 for aarch64-apple-darwin. | ||||||||||||||
def rust_optimisation_flags | ||||||||||||||
@rust_optimisation_flags ||= { | ||||||||||||||
native: "-Ctarget-cpu=native", | ||||||||||||||
nehalem: "-Ctarget-cpu=nehalem", | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please use the long flags for better readability. |
||||||||||||||
}.freeze | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
sig { returns(Symbol) } | ||||||||||||||
def arch_32_bit | ||||||||||||||
if arm? | ||||||||||||||
|
@@ -214,6 +224,13 @@ def oldest_cpu(_version = nil) | |||||||||||||
end | ||||||||||||||
end | ||||||||||||||
alias generic_oldest_cpu oldest_cpu | ||||||||||||||
|
||||||||||||||
# Returns a _full_ rustflag to set target cpu, if necessary; | ||||||||||||||
# Defaults to empty string | ||||||||||||||
sig { returns(String) } | ||||||||||||||
def rustflags_target_cpu | ||||||||||||||
CPU.rust_optimisation_flags.fetch(oldest_cpu, "") | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Also: we should try to support users doing something like brew install --build-bottle --bottle-arch=ivybridge which this doesn't currently do. |
||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really rather be explicit here rather than bake in assumptions about the behaviour of
rustc
. None of us track the development ofrustc
that carefully, so if they decide to bump the minimum ofcore2
before we do, then this method will no longer behave as expected, and that's likely to go unnoticed for some time.The reverse (i.e. if we decide to bump the minimum of
core2
before Rust does) is also an issue, albeit a smaller one.