-
Notifications
You must be signed in to change notification settings - Fork 140
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
Disable GNU make
implicit variables and Quiet ar
with ARFLAGS
rather than > null
#2711
base: main
Are you sure you want to change the base?
Conversation
Makefile
Outdated
@@ -12,7 +12,7 @@ SOEXT ?= $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]') | |||
|
|||
CPPFLAGS := -Iinclude $(CPPFLAGS) | |||
CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden $(CFLAGS) | |||
CC ?= cc | |||
ARFLAGS := -r |
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 introduced ?=
in #2705 to be explicit that the variable may be overwritten by env vars sent from extconf.rb
.
But a quick test shows that <implicit variable> ?= <anything>
doesn’t do anything because the variable was already set – implicitly by GNU make
! 😅
This is why this assignment must be either =
or :=
but not ?=
. It shouldn’t affect receiving the rbconfig
ARFLAGS
through the aforementioned env vars.
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.
- TODO: circument only for
ar -rv
; do not change forlibtool
(such as used in that one failing CI)
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.
Switched to --no-builtin-variables
. Explicit is better than implicit anyways.
@@ -36,7 +36,7 @@ build/libprism.$(SOEXT): $(SHARED_OBJECTS) | |||
|
|||
build/libprism.a: $(STATIC_OBJECTS) | |||
$(ECHO) "building $@" | |||
$(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null) | |||
$(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) |
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.
A quick text find shows that this was the only recipe where Q1
is used, and the only other use of Q1
is
Line 6 in 17762fa
Q = $(Q1:0=@) |
(I’m a novice in C-land; if the entire set of
V
s and Q
s is a convention, introduce them to me.)
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.
Intriguing. Easy solution: drop Ruby 2.7 support (we’re still in 0.x aren’t we?) |
Unfortunately we cannot drop 2.7 support, as that is BASERUBY and we need it to build Ruby itself. |
I'm not sure this is true. Before, we always set |
Like with
This though is intended. |
Oof, I had it mixed up. It’s only overridable with |
Hey @ParadoxV5 are you still working on this or should this be closed? |
Hey, @kddnewton, now that https://bugs.ruby-lang.org/issues/20499 has properly fixed #2716 in the Ruby upstream, I plan to get back to this these few of days. |
I think I'd prefer to leave it because I'd like to support all of the Ruby versions in the range that we support, which includes patch revisions. |
Yeah agreed let's keep that workaround for existing releases and link to the relevant issues to make it easy to figure out from the code why that is needed |
`ARFLAGS` is an implicit variable in GNU `make` (the `README` _specifies GNU_ `make`) and defaulted verbosely, so un-verbose-fy it is the more direct *and platform-agnostic* way to quiet `ar`.
As observed in ruby#2771, `?=` thinks that implicit definitions of CC`, `AR` and `ARFLAGS` are explicit. Disabling implicit variables is more straightforward than adapting the `Makefile` and `extconf.rb` around them.
17762fa
to
0779fa9
Compare
ar
with ARFLAGS
rather than > null
& Remove CC ?= cc
make
implicit variables and Quiet ar
with ARFLAGS
rather than > null
`File::exist?` does not check the PATH, meaning the checks fail as long as `CC`/`AR` aren’t absolute paths. OTOH, `MakeMakefile#find_executable` does.
@@ -51,6 +51,7 @@ def make(env, target) | |||
system( | |||
env, | |||
RUBY_PLATFORM.include?("openbsd") ? "gmake" : "make", | |||
"--no-builtin-variables", # don't let GNU make implicit variables override variable fallbacks in the Makefile |
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'm not sure I understand what this is doing. Could you explain why we need this?
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.
As noted on the previous posts, this flag disables implicit variables for GNU make
(updated top post).
GNU make takes those implicit variables precedence over our ?=
s, especially the new ARFLAGS ?= -r$(V0:1=v)
(PR thread), meaning they aren’t applied without this flag.
Lines 15 to 17 in 9bb8710
CC ?= cc | |
AR ?= ar | |
ARFLAGS ?= -r$(V0:1=v) |
CC
,AR
andARFLAGS
(and alsoRM
andCXX
) are all implicit variables in GNUmake
.CC
andAR
already defaults tocc
andar
, which meansCC ?= cc
does nothing since before I started tinkering.ARFLAGS
defaults to-rv
, wherev
stands forv
erbose.r
avoids printing tonull
,and printing to
/dev/null
was the final obstacle for me to build nightly Prism on my MSYS-less Windows setup!Rather than adapting the
Makefile
andextconf.rb
around them, I disabled them with--no-builtin-variables
. While this flag may be GNU-exclusive, theREADME
implies that we only support GNUmake
.CURDIR
from Avoid shelling *nix commands #2706 is also possibly GNU-exclusive.