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
extend/ENV/super: allow O{1,0}
to accept a block
#11666
Conversation
Review period will end on 2021-07-07 at 23:59:03 UTC. |
Library/Homebrew/extend/ENV/super.rb
Outdated
|
||
if block | ||
begin | ||
block.call |
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.
Not sure why yield
doesn't work, but I don't really get Ruby metaprogramming.
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.
Makes sense to me. I'd love to see more of these methods take block forms to be used in a more finely-grained manner (and perhaps even deprecate the non-block for of deparallelize
). with_env
may be a cleaner solution to this?
|
I was thinking maybe just for the block case? |
So you mean something like %w[O1 O0].each do |opt|
define_method opt do |&block|
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: opt) { block.call }
else
send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt)
end
end
end ? |
Review period ended. |
@carlocab Yeh, that looks nice to me 👍🏻 |
This makes `ENV.O{1,0}` behave like `ENV.deparallelize`. This should also allow us to build libgcrypt's jitter entropy collector, which we currently disable because it interacts poorly with our compiler shims. See Homebrew#11201.
Oops. Sorbet really does not like the new version:
|
@carlocab Given there's now only two of these methods: I'd suggest avoiding |
Ah, just saw your comment. Convincing Sorbet that |
@carlocab Sorry, yeh, I think it'd be nicer. |
Sure, that's fine. I've pushed the changes. |
%w[O1 O0].each do |opt| | ||
define_method opt do | ||
send(:[]=, "HOMEBREW_OPTIMIZATION_LEVEL", opt) | ||
# rubocop: disable Naming/MethodName |
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.
Can you add a comment here explaining why? Thanks!
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.
Thanks, sorry for all the back and forth 🙇🏻
The apology is appreciated but very much unnecessary 🙂 |
This enables the jent module, which is included in the default build configuration. The jent module provides an additional source of entropy generated from CPU time jitter [1] and should help increase the security of users who make use of `libgcrypt` particularly in virtualised environments, server systems, or modern computers which lack spinning hard disks that can be used as an entropy source. We previously disabled this because the jent module must be built without optimisations [2], but our compiler shims provided limited support for selectively relaxing the optimisation level. This was resolved by Homebrew/brew#11666. [1] https://www.chronox.de/jent/doc/CPU-Jitter-NPTRNG.html [2] Homebrew#15750
This enables the jent module, which is included in the default build configuration. The jent module provides an additional source of entropy generated from CPU time jitter [1] and should help increase the security of users who make use of `libgcrypt` particularly in virtualised environments, server systems, or modern computers which lack spinning hard disks that can be used as an entropy source. We previously disabled this because the jent module must be built without optimisations [2], but our compiler shims provided limited support for selectively relaxing the optimisation level. This was resolved by Homebrew/brew#11666. [1] https://www.chronox.de/jent/doc/CPU-Jitter-NPTRNG.html [2] #15750 Closes #80839. Signed-off-by: Nanda H Krishna <me@nandahkrishna.com> Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This makes
ENV.O{1,0}
behave likeENV.deparallelize
.This should also allow us to build libgcrypt's jitter entropy collector,
which we currently disable because it interacts poorly with our compiler
shims. See #11201 for a previous attempt at this.