This patch is created for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211154 and adds support for specifying arguments to USE_GCC.
Details
- Reviewers
novel fabian.freyer_physik.tu-berlin.de - Group Reviewers
portmgr O5: Ports Framework - Commits
- rP563416: In some cases one may want to use GCC to build something when its
run with a test port using make test-gcc.
Diff Detail
- Repository
- rP FreeBSD ports repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Thanks for doing this! I have been on medical leave for most of this
months and am still not fully up and running, so would like to defer the
final review to a different (ports) committer or portmgr, but (a) this looks
fine in principle and (b) some specific comments below.
When this goes in, feel free to add Approved by: gerald in addition to that
of the other reviewer(s).
- Is there any practical need (example?) for the use of TEST_DEPENDS?
I cannot imagine any, but may be missing something, But, if there is none,
let's omit this?
- Is there any practical need (example?) for the use of test and run?
Unless there is, I suggest to omit "test" and/or "run".
- In the comments, please refer to "GCC" (uppercase), not "gcc".
While I can't think of any current port requiring this, I can imagine it to be useful for any kind of testing of toolkits/toolchains that are used at compile-time and where testing involves compiling things against them. While I admit it's a bit of an edge case, I have seen some (admittedly obscure) library headers not compile correctly using clang++ or g++, respectively. Testing this might be useful. However, I'd agree to not adding GCC to TEST_DEPENDS by default.
- Is there any practical need (example?) for the use of test and run?
Unless there is, I suggest to omit "test" and/or "run".
Is there any harm in including it? I'd personally tend to including it since in cases when such a need may arise, it does not promote the practice of manually adding to RUN_DEPENDS and/or TEST_DEPENDS.
Example: https://www.freshports.org/devel/stack/
- In the comments, please refer to "GCC" (uppercase), not "gcc".
No problem here.
- used GCC instead of gcc in comments
- only add to RUN_DEPENDS and BUILD_DEPENDS by default.
Im +1 on including all *_DEPENDS (including TEST) if nothing else but to keep it consistent (with Python and other Uses) and standardised going forward, as TEST_DEPENDS support in the framework is relatively new. If foo can be a FOO_DEPENDS, I can't see any reason it can't be a TEST_DEPENDS (some piece of software written in * that has its test suite framework written in C)
Agreed on the error checking, the debug info I'd leave as-is though since it's part of the test-gcc target.
Mk/bsd.gcc.mk | ||
---|---|---|
246–248 ↗ | (On Diff #18747) | I guess I should have added some more context. This is indeed debug info, but it's part of the test-gcc target, which has the explicit purpose of printing debug information. |
254–262 ↗ | (On Diff #18747) | see above. |
Mk/bsd.gcc.mk | ||
---|---|---|
246–248 ↗ | (On Diff #18747) | Ah, well, you're not using arcanist to upload the diff, so unless you use svn diff --diff-cmd=diff -x -U9999 the review will not get more context and we can't really know what this is all about :-) |
I rather agree with @gerald, we try to not add more code that what is in use, if there are no known user of USE_GCC=test and USE_GCC=run, then please, do not add the code for it.
Thanks for the update, Fabian!
Heads up, my top priority is to get lang/gcc / USE_GCC=yes updated
to GCC 5 in the coming days (which finally appears good to go, then
a small infrastructure improvement that has queued up) and then hope
to get to this finally, hopefully this coming weekend.
Gerald
Thanks for your patience (and sorry for my slowness, still, Fabian)!
This looks good to me, though I tend to agree with mat@ about removing the two cases of "...will be added to..."
debugging.
What are the next steps? I can commit this (and make the change myself), or does portmgr@ want to review
or possibly do an -exp run?
Ah, one thing I nearly forgot: Since you kept USE_GCC=run in the
updated patch, I assume there is at least one tree in the port that
can leverage this after your patch?
I did not mean to contradict mat@ with my approval.
Sorry about not stating that in my original note a few minutes ago.
As a bit of background, that small infrastruture improvement got
stalled (by one port at this point), and I simply did not want to
make this delay any further, so putting this on the fast lane,
finally.
Can we do something with this?
Mk/bsd.gcc.mk | ||
---|---|---|
89 ↗ | (On Diff #26422) | This should probably use IGNORE=. |
Mk/bsd.gcc.mk | ||
---|---|---|
89 ↗ | (On Diff #26422) | Please, please, please. Use of .error breaks metadata sweeps (such as when you build INDEX). |
Yep, I've got an updated/simplified patch ready.
And an update of your net/ipxe port as an example as part of that. :-)
Okay, I am getting officially desparate. :-(
How can I upload a new diff for this issue in this tool? "Update diff..." always seems to want to create a new issue instead of appending to this one, regardless of web browser (even my "accept all trackers and cookies" one).
So here we go, the updated diff below; feedback very welcome.
Index: Mk/bsd.gcc.mk
- Mk/bsd.gcc.mk (revision 501438)
+++ Mk/bsd.gcc.mk (working copy)
@@ -17,6 +17,15 @@
- do so by specifying USE_GCC=X+ which requests at least GCC version X.
- To request a specific version omit the trailing + sign. #
+# Optional comma-separated arguments may be specified after the version
+# specifier. The following arguments are supported:
+# build ... Add GCC as a build dependency (BUILD_DEPENDS).
+# If no arguments are specified, GCC is added both as a build dependency
+# and a runtime dependency.
+#
+# USE_GCC=build is a shortcut for USE_GCC=yes:build.
+#
+#
- Examples:
- USE_GCC= yes # port requires a current version of GCC
- # as defined in bsd.default-versions.mk.
@@ -23,6 +32,9 @@
- USE_GCC= any # port requires GCC 4.2 or later.
- USE_GCC= 7+ # port requires GCC 7 or later.
- USE_GCC= 5 # port requires GCC 5.
+# USE_GCC= 8:build # port requires GCC 8 at build-time only.
+# USE_GCC= build # port requires a current version of GCC at
+# # build-time only.
- If you are wondering what your port exactly does, use "make test-gcc"
- to see some debugging.
@@ -49,6 +61,35 @@
- No configurable parts below this. ######## #
+# Alias USE_GCC=build to USE_GCC=yes:build
+.if ${USE_GCC} == build
+USE_GCC:= yes:${USE_GCC}
+.endif
+
+# Split arguments
+.if defined(USE_GCC)
+USE_GCC:= ${USE_GCC:C/\:.*}
+_USE_GCC_ARGS:= ${USE_GCC:C/^[^\:]*(\:|\$):S/,/ /g}
+USE_GCC= ${USE_GCC}
+.endif
+
+.if ${_USE_GCC_ARGS:Mbuild}
+_USE_GCC_BUILD_DEP= yes
+_USE_GCC_ARGS:= ${_USE_GCC_ARGS:Nbuild}
+.endif
+
+.if !empty(_USE_GCC_ARGS)
+IGNORE= Bad target specification in USE_GCC; only "build" is supported
+.endif
+
+# If the port does not specify a specific dependency, assume all are required.
+.if !defined(_USE_GCC_BUILD_DEP) && !defined(_USE_GCC_RUN_DEP)
+_USE_GCC_BUILD_DEP:= yes
+_USE_GCC_RUN_DEP:= yes
+.endif
+
+
+# Handle USE_GCC=yes.
.if defined(USE_GCC) && ${USE_GCC} == yes
USE_GCC= ${GCC_DEFAULT}+
.endif
@@ -177,8 +218,12 @@
CXXFLAGS:= ${CXXFLAGS:N-mretpoline}
.if defined(_GCC_PORT_DEPENDS)
+. if defined(_USE_GCC_BUILD_DEP)
BUILD_DEPENDS+= ${_GCC_PORT_DEPENDS}:lang/${_GCC_PORT}
+. endif
+. if defined(_USE_GCC_RUN_DEP)
RUN_DEPENDS+= ${_GCC_PORT_DEPENDS}:lang/${_GCC_PORT}
+. endif
- Later GCC ports already depend on binutils; make sure whatever we
- build leverages this as well. USE_BINUTILS= yes
I made all changes suggested plus simplified to only cover what I saw as required by the current ports tree (plus minor simplifications/updates)
This looks fine to me (i.e., I do not see anything really wrong and I can still build net/ipxe).
I can only recommend to install devel/arcanist and setting it up according to https://wiki.freebsd.org/Phabricator#Configure_Client. Then updating a review becomes just arc diff --update D7223. It also generates a diff with full context automatically (something this review lacks at the moment) which can make reviews easier.
Mk/bsd.gcc.mk | ||
---|---|---|
82 ↗ | (On Diff #57354) | Maybe start it with has or any other verb so that it does not read weird like ===> ipxe-20190307 Bad target specification in USE_GCC; only "build" is supported. Though the framework is hardly consistent here. |
Is there anything else that needs to be changed before this goes in? Is it still even relevant?
Further simplifications and some updates, focusing on USE_GCC=...:build only, which is the only case we need in the Ports Collection.