tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

First go at adding GCC_VERSIONS_ACCEPTED support



As suggested by David Holland (and Greg Troxel) in another thread:

On 29-Aug-2015 02:59:46, David Holland wrote:
On Fri, Aug 28, 2015 at 07:12:53PM -0400, Greg Troxel wrote:
>
> What you need to do is to implement better compiler selection logic :-)
> This is a known issue.  Part of the problem is that newer/higher is not
> always better.   So really we need a min required, and perhaps a list of
> incomptible above that.

GCC_VERSIONS_ACCEPTED? :-)

I've been reading through /usr/pkgsrc/mk/compiler/gcc.mk and I have to admit I have yet to fully understand how it works. But I've carried on nonetheless and the attached patch is fully certified as "works for me".

What I've done is, just before the bit where the GCC_REQD list gets worked down to a single, highest _GCC_REQD value, is:

1. Look for the presence of GCC_VERSIONS_ACCEPTED.
2. If it is there, check each version in the list against what is actually installed 3. Once it finds a match it sets GCC_REQD to that single value (so it picks the first found)
4. If it finds no matches then set GCC_REQD to GCC_VERSIONS_ACCEPTED

I don't think this is too bad an approach, but there probably is room for improvement:

- It's probably a bit wasteful to check if a version exists only to pass this on to the following bits in the makefile which must re-check once again (somewhere). - I've assumed versions would be listed as "4.7 4.8 4.9", etc. There is no error handling. It probably won't work if someone puts "4.8.4" for instance, nor if they put "47 48 49". I'm not sure how much error handling is required?

Feedback welcome.

Thanks.
$NetBSD$

--- gcc.mk	2015-09-25 11:02:22.000000000 +0000
+++ newgcc.mk
@@ -33,6 +33,11 @@
 #	is in effect to ensure that a specific compiler is used for
 #	packages which do not specify a higher version.
 #
+# GCC_VERSIONS_ACCEPTED
+#	A list of acceptable versions, will use the first one that is
+#	available, if none are available sets GCC_REQD to all of them (so
+#	GCC_REQD can pick the highest version).
+#
 # USE_GCC_RUNTIME
 #	Packages which build shared libraries but do not use libtool to
 #	do so should define this variable.  It is used to determine whether
@@ -200,6 +205,26 @@ _IS_BUILTIN_GCC=	NO
 .  endif
 .endif
 
+# See if any of GCC_VERSIONS_ACCEPTED are available, this will get the first match
+.if defined(GCC_VERSIONS_ACCEPTED)
+    GCC_REQD=  ${GCC_VERSIONS_ACCEPTED}
+    _GCC_PKG_SATISFIES_DEP=     NO
+.   for _version_ in ${GCC_VERSIONS_ACCEPTED}
+        _GCC_VERSION_ACCEPTED!= ${ECHO} ${_version_} | ${SED} -e "s/\\.//"
+.       if empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
+            _GCC_PKG_SATISFIES_DEP!=    \
+            if ${PKG_INFO} -qE 'gcc${_GCC_VERSION_ACCEPTED}'; then \
+                ${ECHO} "YES";                      \
+            else                                \
+                ${ECHO} "NO";                       \
+            fi
+.           if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
+                GCC_REQD= ${_version_}
+.           endif
+.       endif
+.   endfor
+.endif
+
 # Distill the GCC_REQD list into a single _GCC_REQD value that is the
 # highest version of GCC required.
 #


Home | Main Index | Thread Index | Old Index