From owner-svn-ports-all@freebsd.org Fri Apr 3 21:55:44 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 468A8273817; Fri, 3 Apr 2020 21:55:44 +0000 (UTC) (envelope-from gerald@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48vDJZ6csQz4KtN; Fri, 3 Apr 2020 21:55:42 +0000 (UTC) (envelope-from gerald@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3DACC72E; Fri, 3 Apr 2020 21:46:40 +0000 (UTC) (envelope-from gerald@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 033Lke6x087493; Fri, 3 Apr 2020 21:46:40 GMT (envelope-from gerald@FreeBSD.org) Received: (from gerald@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 033LkeG0087492; Fri, 3 Apr 2020 21:46:40 GMT (envelope-from gerald@FreeBSD.org) Message-Id: <202004032146.033LkeG0087492@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gerald set sender to gerald@FreeBSD.org using -f From: Gerald Pfeifer Date: Fri, 3 Apr 2020 21:46:40 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r530527 - head/Mk X-SVN-Group: ports-head X-SVN-Commit-Author: gerald X-SVN-Commit-Paths: head/Mk X-SVN-Commit-Revision: 530527 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 21:55:44 -0000 Author: gerald Date: Fri Apr 3 21:46:40 2020 New Revision: 530527 URL: https://svnweb.freebsd.org/changeset/ports/530527 Log: Refactor the handling of USE_GCC=any so that it essentially becomes a block of its own as opposed to touching bits and pieces throughout. Use the opportunity to simplify various aspects, such as the static tables describing versions of GCC we support and their initialization. Overall this sheds another 30 lines off what used to me more tricky Makefile code. It should not change behavior. Modified: head/Mk/bsd.gcc.mk Modified: head/Mk/bsd.gcc.mk ============================================================================== --- head/Mk/bsd.gcc.mk Fri Apr 3 21:41:17 2020 (r530526) +++ head/Mk/bsd.gcc.mk Fri Apr 3 21:46:40 2020 (r530527) @@ -34,53 +34,40 @@ GCC_Include_MAINTAINER= gerald@FreeBSD.org # All GCC versions supported by the ports framework. Keep them in # ascending order and in sync with the table below. # When updating this, keep Mk/bsd.default-versions.mk in sync. -GCCVERSIONS= 040200 040800 070000 080000 090000 +GCCVERSIONS= 040800 070000 080000 090000 -# The first field is the OSVERSION in which it disappeared from the base. -# The second field is the version as USE_GCC would use. -GCCVERSION_040200= 9999999 4.2 -GCCVERSION_040800= 0 4.8 -GCCVERSION_070000= 0 7 -GCCVERSION_080000= 0 8 -GCCVERSION_090000= 0 9 +# The right side is the version as USE_GCC uses it. +_GCCVERSION_040800_V= 4.8 +_GCCVERSION_070000_V= 7 +_GCCVERSION_080000_V= 8 +_GCCVERSION_090000_V= 9 # No configurable parts below this. #################################### # -.if defined(USE_GCC) && ${USE_GCC} == yes -USE_GCC= ${GCC_DEFAULT}+ -.endif - -# Extract the fields from GCCVERSION_... -.for v in ${GCCVERSIONS} -. for j in ${GCCVERSION_${v}} -. if !defined(_GCCVERSION_${v}_R) -_GCCVERSION_${v}_R= ${j} -. elif !defined(_GCCVERSION_${v}_V) -_GCCVERSION_${v}_V= ${j} -. endif -. endfor -.endfor - .if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING) -. if ${USE_GCC} == any +.if ${USE_GCC} == any && exists(/usr/bin/gcc) +CC:= gcc +CXX:= g++ +. if exists(/usr/bin/gcpp) +CPP:= gcpp +. else +CPP:= cpp +. endif +.else # The regular approach, not using the age-old base compiler. -# Enable the clang-is-cc workaround. Default to the last GCC imported -# into base. -_USE_GCC:= 4.2 -_GCC_ORLATER:= true +# Handle USE_GCC=yes and USE_GCC=any. +.if ${USE_GCC} == yes || ${USE_GCC} == any +USE_GCC= ${GCC_DEFAULT}+ +.endif -. 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 -. endif # ${USE_GCC} == any - # See whether we have the specific version requested installed already # and save that into _GCC_FOUND. In parallel, check if USE_GCC refers # to a valid version to begin with. @@ -89,8 +76,6 @@ _GCC_ORLATER:= true _GCCVERSION_OKAY= true . if exists(${LOCALBASE}/bin/gcc${_GCCVERSION_${v}_V:S/.//}) _GCC_FOUND:= ${_USE_GCC} -. elif ${OSVERSION} < ${_GCCVERSION_${v}_R} && exists(/usr/bin/gcc) -_GCC_FOUND:= ${_USE_GCC} . endif . endif .endfor @@ -107,44 +92,25 @@ _USE_GCC:= ${GCC_DEFAULT} . endif .endif # defined(_GCC_ORLATER) -.endif # defined(USE_GCC) - - -.if defined(_USE_GCC) -# A concrete version has been selected. Determine if the installed OS -# features this version in the base, and if not then set proper ports -# dependencies, CC, CXX, CPP, and flags. -.for v in ${GCCVERSIONS} -. if ${_USE_GCC} == ${_GCCVERSION_${v}_V} -. if ${OSVERSION} > ${_GCCVERSION_${v}_R} || !exists(/usr/bin/gcc) -V:= ${_GCCVERSION_${v}_V:S/.//} +# A concrete version has been selected. Set proper ports dependencies, +# CC, CXX, CPP, and flags. +V:= ${_USE_GCC:S/.//} _GCC_PORT_DEPENDS:= gcc${V} _GCC_PORT:= gcc${V} CC:= gcc${V} CXX:= g++${V} CPP:= cpp${V} _GCC_RUNTIME:= ${LOCALBASE}/lib/gcc${V} -. if ${PORTNAME} == gcc +. if ${PORTNAME} == gcc # We don't want the rpath stuff while building GCC itself # so we do not set the FLAGS as done in the else part. # When building a GCC, we want the target libraries to be used and not the # host GCC libraries. -. else +. else CFLAGS+= -Wl,-rpath=${_GCC_RUNTIME} CXXFLAGS+= -Wl,-rpath=${_GCC_RUNTIME} LDFLAGS+= -Wl,-rpath=${_GCC_RUNTIME} -L${_GCC_RUNTIME} -. endif -. else # Use GCC in base. -CC:= gcc -CXX:= g++ -. if exists(/usr/bin/gcpp) -CPP:= gcpp -. else -CPP:= cpp -. endif -. endif # Use GCC in base. -. endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V} -.endfor +. endif .undef V # Now filter unsupported flags for CC and CXX. @@ -158,6 +124,9 @@ RUN_DEPENDS+= ${_GCC_PORT_DEPENDS}:lang/${_GCC_PORT} # build leverages this as well. USE_BINUTILS= yes .endif + +.endif # USE_GCC=any + .endif # defined(_USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)