I have way over-commited myself on open-source contributions, I hope no one is in a rush.

Here’s attempt number two I made, I really need to crack on with number three because already I know that option is itself outdated and we are at least up to number four.

This was placed after the existing “Distill the GCC_REQD list into a single _GCC_REQD value that is the highest version of GCC required” routine in an attempt to be slightly less hacky. I.e. I was trying to think of situation of packages with dependencies being built at the same time where we’d legitimately need one long list of GCC_REQD values; However, I think I failed this - see below.

#See if a gcc version greater than or equal to the required is available, if there is get the maximum
_GCC_PKG_SATISFIES_DEP=     NO
_GCC_PKG_VERSIONS_INSTALLED!= ${PKG_INFO} -I 'gcc*' | cut -f 1 -d " " | ${GREP} -E "^gcc[0-9]+-[0-9nb.]+"
_GCC_PKG_VERSION= 1
.for _gcc_pkg_version_ in ${_GCC_PKG_VERSIONS_INSTALLED}
	_GCC_PKG_NUMBER!= ${ECHO} ${_gcc_pkg_version_} | ${SED} -e "s/gcc\([0-9][0-9]*\)\-.*/\1/"
	_GCC_REQD_NUMBER!= ${ECHO} ${_GCC_REQD} | ${SED} -e "s/\\.//"
	_GCC_PKG_SATISFIES_DEP!=    \
		if [ ${_GCC_PKG_NUMBER} -ge ${_GCC_REQD_NUMBER} ] && [ ${_GCC_PKG_NUMBER} -gt ${_GCC_PKG_VERSION} ]; then \
			${ECHO} "YES";                      \
		else                                \
			${ECHO} "NO";                       \
		fi
.   if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
		_GCC_PKG_VERSION= ${_GCC_PKG_NUMBER}
.   endif
.endfor
#Only override _GCC_REQD if we've found a match
.if ${_GCC_PKG_VERSION} != 1
	_GCC_REQD!= ${ECHO}  ${_GCC_PKG_VERSION} | ${SED} -e "s/\([0-9]\)\([0-9]\)/\1\.\2/"
.endif

The good:

  • Gets highest version instead of first found.
  • Leaves GCC_REQD completely alone, which is what packages actually set.
  • Uses pkg_info again to check what is actually installed instead of that weird if ${PKG_ADMIN} pmatch 'gcc>=${_vers_}' ${_pkg_} 2>/dev/null; thing which can only compare patch/revision numbers of packages (i.e. 4.7.4 vs 4.7.2, not 4.8 vs 4.7) and doesn’t actually check if packages are installed; However, somewhere within gcc.mk or linked build system files a proper comparison must be made somewhere between what is available and what is required - I need to track that down and understand how and where that is done.

The bad:

  • Uses cut and not ${CUT} because I don’t think that is defined as a standard tool in Pkgsrc. Since Pkgsrc is very cross-platform I need to careful what I use; Which is also why some of the programming in the Pkgsrc build system makefiles seems convoluted.
  • Still hacky as overrides _GCC_REQD.
  • And apparently, despite what I thought, complicated systems of packages (with various dependencies which are also being built) could end up building against different versions of gcc. I still don’t really understand why this would happen when I’m overriding _GCC_REQD and not GCC_REQD though, but it seems it is something to do with the build order.

Anyway, full understanding (or more honestly: “greater understanding”) of that last point will come with attempt number three.

PS: Hence why I said I “procrastinated through action” in my last post. I needed more experience understanding how packages build, especially C++ packages, so took a two week detour through Ledger Land.