Bug 233542 - devel/kBuild improperly selects gcc version
Summary: devel/kBuild improperly selects gcc version
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: vbox
Depends on:
Reported: 2018-11-26 18:41 UTC by rkoberman
Modified: 2019-08-03 12:12 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (vbox)

Patch to allow kBuild to use gcc7 (384 bytes, patch)
2018-11-26 18:41 UTC, rkoberman
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rkoberman 2018-11-26 18:41:18 UTC
Created attachment 199577 [details]
Patch to allow kBuild to use gcc7

gcc6 is deprecated but kBuild/Makefile specifies "USE_GCC=any" which results in gcc6 being used. gcc6 is EOL and is taged for expiration.

While I believe that bsd.gcc.mk is incorrectly selecting gcc6 for the "any"case, the recommended value for gcc when a specific version is required is "USE_GCC=yes". Changing the Makefile successfully builds kBuild using gcc7. The attached patch makes this change.
Comment 1 Jung-uk Kim freebsd_committer 2018-11-26 20:59:40 UTC
Actually, all you have to do is deinstalling lang/gcc6 first and rebuilding devel/kBuild.
Comment 2 rkoberman 2018-11-27 07:39:30 UTC
(In reply to Jung-uk Kim from comment #1)
This is true, but I have another port that uses gcc6 and, while I will fix it shortly, the proper fix of "yes" fixes it permanently (hopefully).
Comment 3 Jung-uk Kim freebsd_committer 2018-11-27 20:02:03 UTC
(In reply to rkoberman from comment #2)
Are you saying ports should not do "USE_GCC=any" at all?  Sorry but I disagree.
Comment 4 rkoberman 2018-11-28 05:02:35 UTC
(In reply to Jung-uk Kim from comment #3)
I won't argue, but the comments in Mk/bsd.gcc.mk would seem to. They also argue that Mk/bsd.gcc.mk has a problem.

# To request the use of a current version of GCC, specify USE_GCC=yes in
# your port/system configuration.  This is the preferred use of USE_GCC.
# It uses the canonical version of GCC defined in bsd.default-versions.mk.
# USE_GCC=any is similar, except that it also accepts the old GCC 4.2-
# based system compiler in older versions of FreeBSD.
# If your port needs a specific (minimum) version of GCC, you can easily
# specify that with a USE_GCC= statement.  Unless absolutely necessary
# do so by specifying USE_GCC=X+ which requests at least GCC version X.
# To request a specific version omit the trailing + sign.
# Examples:
#   USE_GCC=    yes                     # port requires a current version of GCC
#                                       # as defined in bsd.default-versions.mk.
#   USE_GCC=    any                     # port requires GCC 4.2 or later.

The use of "any" is to allow the use of gcc4.2, which is likely to cause issues considering its age and lack of recent support. Further, the coe in the .mk file seesm to likely not o what might be expected nor what the comments state, though I find the comment "Default to the last GCC imported into base" to be very unclear. In any case, it should not choose gcc7 on n 11.2 system.

The .mk code for "any" looks a bit odd to me. It does not appear to do what the comments say, but I am far from an expert if make(1).
.if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)

. if ${USE_GCC} == any

# Enable the clang-is-cc workaround.  Default to the last GCC imported
# into base.
_USE_GCC:=      4.2
_GCC_ORLATER:=  true

. else # ${USE_GCC} == any

# See if we can use a later version or exclusively the one specified.
_USE_GCC:=      ${USE_GCC:S/+//}
.if ${USE_GCC} != ${_USE_GCC}
_GCC_ORLATER:=  true

. endif # ${USE_GCC} == any

 .mk code for "any"is a bit odd to me.
Comment 5 Walter Schwarzenfeld freebsd_triage 2019-08-03 12:12:32 UTC
In the meantime Makefile has  GCC=yes. Is this still relevant are there still issues?