From nobody Sat Dec 17 20:21:35 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NZHRz2zHTz1G2vK; Sat, 17 Dec 2022 20:21:35 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NZHRz2NFRz4Kkg; Sat, 17 Dec 2022 20:21:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671308495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NEIrorexgDrnUXAq+8l354JEckV1MpJrWvoswsXWG/s=; b=m7yZd1h3w/11fMTFB8XP1AM2vw5BCd7OvN+NeTHOMJpywcT8Rllem0P0FBzAqT0YOUR1gN Tq/VS/88AyMYOrRLpLXTu/I/C6oTQJoXWny7miLHS+Od4F6Sc+RVe7gkM27hhnovNcNU0i +KFTV/BrI8BrlvvU2sOtUw8hi96N9tDdUYnoYEYFRfseNrQ7kijj3j6GfU0MPh+mYthFoe BcXW0DHqVj5WFEw/gyUbQACv2SS2ihNTlDqkbFWNdCWC73dZaSEpeGYXGwzUcx+dQBzJxK zHiGDY2HAkV/v5kwqoWyhkSaA6+KPQDIO/PU/w7AQu0/Rgsv1kV2FzKc/sEXVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671308495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NEIrorexgDrnUXAq+8l354JEckV1MpJrWvoswsXWG/s=; b=c8O0AkygTt6qkJUhRFUNFD9B4vz1RHZHGno2Na6bEqN3JdrvJklGkBrn5oOpyxtFdgGuLP 7OCDY93sn4pNOOOzcyGBnOKJs9uUKpFWgqTirzuJfXl4WxiqOk0hsvbt/wPLLZzbpMJmGa alxwCdfOJyw70kwELD9t2niQftxQ/XShqD2z9kIZPYBuwrXAQ7vZ8j9qpXUg+yQrzk8T0J QFqxPnA/Wxlryz4clzBjvA6AG1pp4soCZKfPc8etWAcx1XoxLff0zjBj1jzfGm2EA6CV05 jY7oMuo2okR+idKUc4JDe4R+sBmFW9qOmPXBXjS3QcDYp+iMDxBXZWYHdhmzuw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671308495; a=rsa-sha256; cv=none; b=bgiJ8DAKM9lfJ+OGqrn2AZaXV/a6In70WTPd3rVIp/CluH34X1SYyFeGgODw+bAqsCI6Bd Tf0o1kykc+opwEuBsi6cyNSbgtZBpT44s7p+3SxVbtKgS50q4h4yVaai6qfQLUMeG+QF8T bcPLwT/v9AShfX+zlR5eE7dlTkYzqFZFLVF3HIZhRd905gIobPuGkaei5YlA42zTJx8cMY wEuTm49pjULCZOCA3C5AIiOz7QjUO9ubZSq8E10KM22VHPrV5Az4M9KJxwh1lWMpnN+hpw J2VuOCBpL1gfEDJY3O0xXiqINtPzLMbF6saeIzCa/sCFn9jwqXA+xQS5/b8lDQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NZHRz1QpZz14lp; Sat, 17 Dec 2022 20:21:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BHKLZE9071026; Sat, 17 Dec 2022 20:21:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BHKLZTh071025; Sat, 17 Dec 2022 20:21:35 GMT (envelope-from git) Date: Sat, 17 Dec 2022 20:21:35 GMT Message-Id: <202212172021.2BHKLZTh071025@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: "Tobias C. Berner" Subject: git: 2b3e37f30c24 - main - framework: Add new USES=llvm to more easily depend on one an llvm port List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tcberner X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b3e37f30c249db5e9957c3ee41c25dea3191fc5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tcberner: URL: https://cgit.FreeBSD.org/ports/commit/?id=2b3e37f30c249db5e9957c3ee41c25dea3191fc5 commit 2b3e37f30c249db5e9957c3ee41c25dea3191fc5 Author: Tobias C. Berner AuthorDate: 2022-12-17 20:13:44 +0000 Commit: Tobias C. Berner CommitDate: 2022-12-17 20:20:28 +0000 framework: Add new USES=llvm to more easily depend on one an llvm port USES=llvm supports two kinds of arguments: * mode : defaults to build build: add a BUILD_DEPENDS on chosen llvm-port run: add a RUN_DEPENDS on chosen llvm-port lib: add a LIB_DEPENDS on chosen llvm-port * version : defaults to ${LLVM_DEFAULT} number: use explicitly the specified version min=number: use specified min if ${LLVM_DEFAULT} is lower max=number: use specified max if ${LLVM_DEFAULT} is higher An example usage might be: USES= llvm or USES= llvm:13,build or USES= llvm:min=14,lib The following variables are exposed to be used in the ports tree at the moment: * LLVM_VERSION version chosen from the arguments to llvm.mk * LLVM_PORT chosen llvm port * LLVM_CONFIG llvm-config of the chosen port * LLVM_LIBLLVM libLLVM.so of the chosen port * LLVM_PREFIX installation prefix of the chosen port Reviewed by: manu, bapt Differential Revision: https://reviews.freebsd.org/D37728 --- CHANGES | 33 +++++++++++++++++++ Mk/Uses/llvm.mk | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/CHANGES b/CHANGES index 2cbcf2bd6a31..35c4205aee0b 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,39 @@ in the release notes and/or placed into UPDATING. All ports committers are allowed to commit to this file. +20221217: +AUTHOR: tcberner@FreeBSD.org + + USES=llvm has been added to more easily depend on llvm. + + USES=llvm supports two kinds of arguments: + + * mode + : defaults to build + build: add a BUILD_DEPENDS on chosen llvm-port + run: add a RUN_DEPENDS on chosen llvm-port + lib: add a LIB_DEPENDS on chosen llvm-port + + * version + : defaults to ${LLVM_DEFAULT} + number: use explicitly the specified version + min=number: use specified min if ${LLVM_DEFAULT} is lower + max=number: use specified max if ${LLVM_DEFAULT} is higher + + An example usage might be: + USES= llvm + or + USES= llvm:13,build + or + USES= llvm:min=14,lib + + The following variables are exposed to be used in the ports tree at the moment: + * LLVM_VERSION version chosen from the arguments to llvm.mk + * LLVM_PORT chosen llvm port + * LLVM_CONFIG llvm-config of the chosen port + * LLVM_LIBLLVM libLLVM.so of the chosen port + * LLVM_PREFIX installation prefix of the chosen port + 20221026: AUTHOR: bapt@FreeBSD.org 3 new features are available now: PIE, RELRO, BIND_NOW, each port can diff --git a/Mk/Uses/llvm.mk b/Mk/Uses/llvm.mk new file mode 100644 index 000000000000..459fd8736cb6 --- /dev/null +++ b/Mk/Uses/llvm.mk @@ -0,0 +1,98 @@ +# Provides support to depend on LLVM +# +# It chooses the llvm port to be used based on the following constraint: +# 1) no constraints given => ${LLVM_DEFAULT} +# 2) exact constraint given => ${exact} +# 2) max constraint given && ${max} < ${LLVM_DEFAULT} => ${max} +# 3) min constraint given && ${LLVM_DEFAULT} < ${LLVM_DEFAULT} => ${LLVM_DEFAULT} + +# Usage: +# USES= llvm - default version chosen +# USES= llvm:15 - exact constraint +# USES= llvm:min=9 - min constraint: max(min,default) +# USES= llvm:max=10 - max constraint: min(max,default) +# USES= llvm:min=10,max=11 - all constraint: max(min(max,default),default) + +.if !defined(_INCLUDE_USES_LLVM_MK) +_INCLUDE_USES_LLVM_MK= YES + +_LLVM_MK_VALID_VERSIONS= 7 8 9 10 11 12 13 14 15 +_LLVM_MK_VALID_CONSTRAINTS= min max +_LLVM_MK_VALID_MODES= build run lib + +# === parse mode arguments === +_LLVM_MK_MODES= # empty +. for _mode in ${_LLVM_MK_VALID_MODES} +. if ${llvm_ARGS:M${_mode}} +_LLVM_MK_MODES+= ${_mode} +. endif +. endfor +. if empty(_LLVM_MK_MODES) +_LLVM_MK_MODES= build +. endif + +# === parse version arguments === +_LLVM_MK_VERSION= # empty +. for _ver in ${_LLVM_MK_VALID_VERSIONS} +. if ${llvm_ARGS:M${_ver}} +. if !empty(_LLVM_MK_VERSION) +BROKEN= USES=llvm:${llvm_ARGS} contains multiple version definitions +. else +_LLVM_MK_VERSION= ${_ver} +. endif +. endif +. endfor +. if empty(_LLVM_MK_VERSION) +_LLVM_MK_VERSION= ${LLVM_DEFAULT} +. endif + +# === handle constraints === +. for _constraint in ${_LLVM_MK_VALID_CONSTRAINTS} +_version= ${llvm_ARGS:M${_constraint}=[0-9]*:S/${_constraint}=//} +. if !empty(_version) +_LLVM_MK_CONSTRAINT_${_constraint}= ${_version} +. endif +. endfor + +. if !empty(_LLVM_MK_CONSTRAINT_min) +. if ${_LLVM_MK_CONSTRAINT_min} > ${_LLVM_MK_VERSION} +_LLVM_MK_VERSION= ${_LLVM_MK_CONSTRAINT_min} +. endif +. endif + +. if !empty(_LLVM_MK_CONSTRAINT_max) +. if ${_LLVM_MK_CONSTRAINT_max} < ${_LLVM_MK_VERSION} +_LLVM_MK_VERSION= ${_LLVM_MK_CONSTRAINT_max} +. endif +. endif + +# === define helpers for the dependencies === +. for _ver in ${_LLVM_MK_VALID_VERSIONS:N1[0-9]} +_LLVM_MK_SUFFIX_${_ver}= ${_ver}0 +. endfor + +. for _ver in ${_LLVM_MK_VALID_VERSIONS} +_LLVM_MK_SUFFIX_${_ver}?= ${_ver} +. endfor + +# === define variables to depend on and export === +_LLVM_MK_PORT= devel/llvm${_LLVM_MK_SUFFIX_${_LLVM_MK_VERSION}} +_LLVM_MK_LIBLLVM= libLLVM-${_LLVM_MK_VERSION}.so +_LLVM_MK_PATH= llvm-config${_LLVM_MK_SUFFIX_${_LLVM_MK_VERSION}} +_LLVM_MK_PREFIX= ${PREFIX}/llvm${_LLVM_MK_SUFFIX_${_LLVM_MK_VERSION}} + +# == add actual dependencies === +_LLVM_MK_PATH_lib= ${_LLVM_MK_LIBLLVM} +. for _mode in ${_LLVM_MK_MODES} +_LLVM_MK_PATH_${_mode}?= ${_LLVM_MK_PATH} +${_mode:tu}_DEPENDS+= ${_LLVM_MK_PATH_${_mode}}:${_LLVM_MK_PORT} +. endfor + +# == export config === +LLVM_PORT= ${_LLVM_MK_PORT} +LLVM_CONFIG= ${_LLVM_MK_PATH} +LLVM_LIBLLVM= ${_LLVM_MK_LIBLLVM} +LLVM_VERSION= ${_LLVM_MK_VERSION} +LLVM_PREFIX= ${_LLVM_MK_PREFIX} + +.endif