git: fb5f03a87cf4 - main - Mk/bsd.lto.mk: add global LTO support for ports

Mathieu Arnold mat at freebsd.org
Mon Oct 4 13:31:11 UTC 2021


On Thu, Sep 30, 2021 at 06:34:20PM +0000, Piotr Kubaj wrote:
> The branch main has been updated by pkubaj:
> 
> URL: https://cgit.FreeBSD.org/ports/commit/?id=fb5f03a87cf432751fae1f0ae7f29c9d4fc65917
> 
> commit fb5f03a87cf432751fae1f0ae7f29c9d4fc65917
> Author:     Piotr Kubaj <pkubaj at FreeBSD.org>
> AuthorDate: 2021-09-30 18:27:50 +0000
> Commit:     Piotr Kubaj <pkubaj at FreeBSD.org>
> CommitDate: 2021-09-30 18:27:50 +0000
> 
>     Mk/bsd.lto.mk: add global LTO support for ports
>     
>     It's well known that LTO provides both performance and size benefits for
>     binaries.
>     
>     Add preliminary, opt-in support for global LTO enforcement to ports. Ports that
>     provide LTO option on their own and the ones that don't work with LTO will need
>     to set LTO_UNSAFE in the future.
>     
>     PR:     258536

Not to be picky about approval and all, but this was added to the
framework, and the framework is maintained by portmgr.  When you want to
add something to it, you must consult with portmgr before anything gets
committed.

In that case, we would have told you not to do it this way, but to make
this a Mk/Uses/lto.mk.

So please, turn this into a USES=lto.

> ---
>  Mk/bsd.lto.mk  | 10 ++++++++++
>  Mk/bsd.port.mk |  4 ++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/Mk/bsd.lto.mk b/Mk/bsd.lto.mk
> new file mode 100644
> index 000000000000..c2a079ea28bb
> --- /dev/null
> +++ b/Mk/bsd.lto.mk
> @@ -0,0 +1,10 @@
> +# LTO Support
> +
> +LTO_Include_MAINTAINER=	pkubaj at FreeBSD.org
> +
> +.if !defined(LTO_UNSAFE)
> +# Overridable as a user may want to use -flto
> +LTO_CFLAGS?=	-flto=thin
> +CFLAGS+=	${LTO_CFLAGS}
> +CXXFLAGS+=	${LTO_CFLAGS}
> +.endif
> diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
> index 337d3f6be6a6..493b15a59fff 100644
> --- a/Mk/bsd.port.mk
> +++ b/Mk/bsd.port.mk
> @@ -1799,6 +1799,10 @@ INSTALL_TARGET:=	${INSTALL_TARGET:S/^install-strip$/install/g}
>  .endif
>  .endif
>  
> +.if defined(USE_LTO)
> +.include "${PORTSDIR}/Mk/bsd.lto.mk"
> +.endif
> +
>  .if !defined(WITHOUT_SSP)
>  .include "${PORTSDIR}/Mk/bsd.ssp.mk"
>  .endif
> 

-- 
Mathieu Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/dev-commits-ports-all/attachments/20211004/0a7621d0/attachment.sig>


More information about the dev-commits-ports-all mailing list