Disable GNU make implicit variables and Quiet ar with ARFLAGS rather than > null#2711
Conversation
| 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.
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.
- 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.
Switched to --no-builtin-variables. Explicit is better than implicit anyways.
| 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.
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
(I’m a novice in C-land; if the entire set of
Vs and Qs is a convention, introduce them to me.)
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 |
17762fa to
0779fa9
Compare
ar with ARFLAGS rather than > null & Remove CC ?= ccmake implicit variables and Quiet ar with ARFLAGS rather than > null
| 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.
I'm not sure I understand what this is doing. Could you explain why we need this?
There was a problem hiding this comment.
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
|
@ParadoxV5 now that the build system has changed because it's not shelling out to make anymore, can you check if this is still necessary? If it is can you rebase? |
There was a problem hiding this comment.
now that the build system has changed because it's not shelling out to make anymore, can you check if this is still necessary?
Interesting, @kddnewton.
At #3273, @mame was practically requesting Prism-gem support for MSVC, and it was approved by the decision to stop intercepting the platform-agnostic mkmf.
FWIW, MSVC is also not MSYS.
My goal was to support MSYS (DevKit in RubyInstaller’s jargon)-less MinGW.
I built the latest HEAD and can confirm that, because the RbConfig-based mkmk absorbs all setup differences, that decision covers my case as well and it no longer requires this PR.
The only purpose left in this patch, then, is to improve the general code quality.
| build/libprism.a: $(STATIC_OBJECTS) | ||
| $(ECHO) "building $@ with $(AR)" | ||
| $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null) | ||
| $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) |
There was a problem hiding this comment.
Writing to Null has always been questionable as we could simply not supply -v to ar.
As stated in OP, this workaround exists because ARFLAGS defaults to -rv, unless forcefully replaced.
Alternate approaches include:
- use
RbConfig::CONFIGfor those (i.e., allrbconfig.rbcases) as well- tricking
create_makefilealso counts
- tricking
- Do those still need a separate
.aandarsteps?
Most C projects (mkmfor not) builds.cs to.os and.os to.so/.dll; there’s no.astep after.os.- Follow-up of Fails to install gem on mswin64 #3273 discussion
| CC ?= cc | ||
| AR ?= ar | ||
| ARFLAGS ?= -r$(V0:1=v) |
469487f to
98d7192
Compare
`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`.
98d7192 to
ad7de0c
Compare
CC,ARandARFLAGS(and alsoRMandCXX) are all implicit variables in GNUmake.CCandARalready defaults toccandar, which meansCC ?= ccdoes nothing since before I started tinkering.ARFLAGSdefaults to-rv, wherevstands forverbose.ravoids printing tonull,and printing to
/dev/nullwas the final obstacle for me to build nightly Prism on my MSYS-less Windows setup!Rather than adapting the
Makefileandextconf.rbaround them, I disabled them with--no-builtin-variables. While this flag may be GNU-exclusive, theREADMEimplies that we only support GNUmake.CURDIRfrom Avoid shelling *nix commands #2706 is also possibly GNU-exclusive.