From 21d2ba49bde2180972513b878b768c6e1bddaa7c Mon Sep 17 00:00:00 2001 From: Shane Peelar Date: Sat, 28 Oct 2023 16:13:23 -0400 Subject: [PATCH] sys-config/ltoize: Fix portageq --- .../2023-10-28-portageq.en.txt | 50 +++++++ .../2023-10-28-portageq.en.txt.asc | 7 + .../ltoize/files/bashrc.d/41-lto-patch.sh | 10 +- sys-config/ltoize/ltoize-0.9.12.ebuild | 135 ++++++++++++++++++ 4 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt create mode 100644 metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt.asc create mode 100644 sys-config/ltoize/ltoize-0.9.12.ebuild diff --git a/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt b/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt new file mode 100644 index 00000000..14671e70 --- /dev/null +++ b/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt @@ -0,0 +1,50 @@ +Title: GentooLTO portageq changes +Author: Shane Peelar +Content-Type: text/plain +Posted: 2023-10-28 +Revision: 1 +News-Item-Format: 1.0 + +Greetings GentooLTO community, + +As a result of the portageq removal from ebuilds, I've had to change the configuration of GentooLTO a bit. +In make.conf, if you are using the override-flagomatic option, you must now specify the path to lto-overlay +in the variable LTO_OVERLAY_PATH. If you're not using this GentooLTO flag, this probably wouldn't affect you. +Both ltoize and 41-lto-patch.sh have been updated for the change and will issue an error if the flag isn't set. +Hopefully this migration isn't too inconvenient for you. + +On another note, as you probably already know, I don't maintain GentooLTO very often anymore. +There's a number of reasons for this, but the biggest is probably that the project has kind of accomplished +its goals, more or less. There just aren't very many workarounds required anymore for getting a working LTO system. +Larger Linux distributions even support building with LTO now, which is fantastic! I don't know if it's our +community that normalized LTO necessarily, but I like to imagine that we've had some impact here at least. + +If you're looking for a more stable alternative to GentooLTO for your system, I encourage you to use the upstream +support provided by the Gentoo community. Upstream now supports LTO and will accept bugs with packages that +don't build with LTO cleanly. So, if you're running a vanilla LTO system now without the other flags supported +in this repo, you might consider just using the upstream Gentoo support, as they have your back. + +If you're using the other flags in GentooLTO that aren't supported upstream, rest assured, this repository +isn't going away. However, my time is pretty limited now and I can't verify workarounds like I once could. +So, if it's not a straightforward verification, it might take a while for me (read: months?) to get around to confirming +the need for your workaround. + +As for future GentooLTO plans, consider the project on maintenance mode now with no major work planned other +than keeping the lights on. For anything seriously urgent (like the portageq stuff) I'll definitely intervene. +Otherwise, you can continue enjoying your LTO system. BTW, Even if you use LTO without sys-config/ltoize, you might +consider using lto-rebuild here to help you deal with static archives. Not sure if that's an upstream thing yet. + +One last thing. I've received some calls for adding another maintainer to the project. I have considered this +but consider it far too risky to do. GentooLTO installs itself directly into your package manager and basically +has root access, and I simply can't pay enough attention to maintainer activity to ensure no funny business is going +on. So, while I appreciate the genuine offers for help from various members of the community, +I can't accept any requests for maintainer access to the project. If you truly want to do this, +I recommend forking the project and direct users to your fork. Who knows, I may even use it myself :) + +Anyway, sad as it is to say, it's been a slice, GentooLTO'ers. +Thank you so much for your dedication and support over the years. +As a community I like to think we've accomplished a lot together, even if it is a rather niche topic. +Keep on doing great things and being awesome people. + +-Shane + diff --git a/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt.asc b/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt.asc new file mode 100644 index 00000000..94c57473 --- /dev/null +++ b/metadata/news/2023-10-28-portageq/2023-10-28-portageq.en.txt.asc @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- + +iHUEABYKAB0WIQRQKz0hsEWJZFu2CI4PbWnCixM/0QUCZT1rVQAKCRAPbWnCixM/ +0fC7AQDXQ0OwCbrO/H4HU93hy43v0wcDRzE1mDkPLpEyqJ3pCgEAm9Hl2SSgtUqp +L0W28QKzyR1h5HWnAx4CPwL57neBOQE= +=xcao +-----END PGP SIGNATURE----- diff --git a/sys-config/ltoize/files/bashrc.d/41-lto-patch.sh b/sys-config/ltoize/files/bashrc.d/41-lto-patch.sh index e2afbed0..28d0c0ee 100644 --- a/sys-config/ltoize/files/bashrc.d/41-lto-patch.sh +++ b/sys-config/ltoize/files/bashrc.d/41-lto-patch.sh @@ -1,4 +1,10 @@ LTOPatch() { + if [ -z "${LTO_OVERLAY_PATH}" ]; then + eerror "You must set LTO_OVERLAY_PATH in your make.conf to point to where lto-overlay lives." + eerror "You can use: 'portageq get_repo_path ${PORTAGE_CONFIGROOT} lto-overlay' to obtain it if you're not sure." + die + fi + # Lifted straight from the Portage sources # Working directory is set to ${HOME} by default # Set it properly for patch application @@ -17,8 +23,8 @@ LTOPatch() { local tagfile=${T}/.portage_lto_patches_applied [[ -f ${tagfile} ]] && return >> "${tagfile}" - - local lto_overlay_dir="$(portageq get_repo_path ${PORTAGE_CONFIGROOT} lto-overlay)" + + local lto_overlay_dir="${LTO_OVERLAY_PATH:-/var/db/repos/lto-overlay}" local basedir="${lto_overlay_dir%/}/sys-config/ltoize/files/patches" local applied d f diff --git a/sys-config/ltoize/ltoize-0.9.12.ebuild b/sys-config/ltoize/ltoize-0.9.12.ebuild new file mode 100644 index 00000000..0967f026 --- /dev/null +++ b/sys-config/ltoize/ltoize-0.9.12.ebuild @@ -0,0 +1,135 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit toolchain-funcs + +DESCRIPTION="A configuration for portage to make building with LTO easy" +HOMEPAGE="https://github.com/InBetweenNames/gentooLTO" + +#Note: there's nothing preventing this from working on stable, but the dependencies of ltoize aren't keyworded for +#stable, so we only can do testing +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86" + +SRC_URI="" + +LICENSE="GPL-2+" +SLOT="0" +IUSE="clang keep-nocommon override-flagomatic" + +#portage-bashrc-mv can be obtained from mv overlay +DEPEND=" + app-portage/portage-bashrc-mv[cflags] + sys-apps/portage + sys-devel/gcc-config +" +RDEPEND="${DEPEND}" + +#Test binutils and gcc version +pkg_setup() { + + ACTIVE_GCC=$(gcc-fullversion) + + if ver_test "${ACTIVE_GCC}" -lt 10.2.0; then + ewarn "Warning: Active GCC version '$ACTIVE_GCC' is lower then the expected version '10.2.0', it is recommended that you use the newest GCC if you want LTO." + if [ "${I_KNOW_WHAT_I_AM_DOING}" != "y" ]; then + eerror "Aborting LTOize installation due to older GCC version '$ACTIVE_GCC' -- set I_KNOW_WHAT_I_AM_DOING=y if you want to override this behaviour." + die + else + ewarn "I_KNOW_WHAT_I_AM_DOING=y -- continuing anyway" + fi + fi + + if [ -f "${PORTAGE_CONFIGROOT%/}/etc/portage/package.cflags" ]; then + eerror "${PORTAGE_CONFIGROOT%/}/etc/portage/package.cflags is a file not a directory. Please convert package.cflags to a directory with the current contents of package.cflags being moved to a file inside it." + die + fi + +} + +pkg_preinst() { + ACTIVE_GCC=$(gcc-fullversion) + if use override-flagomatic; then + if [ -z "${LTO_OVERLAY_PATH}" ]; then + eerror "It seems you're using the override-flagomatic feature of GentooLTO. You must set LTO_OVERLAY_PATH in your make.conf to point to where lto-overlay lives." + eerror "You can use: 'portageq get_repo_path ${PORTAGE_CONFIGROOT} lto-overlay' to obtain it if you're not sure." + die + fi + fi + + GENTOOLTO_PORTDIR="${LTO_OVERLAY_PATH}" + LTO_PORTAGE_DIR="${GENTOOLTO_PORTDIR}/${CATEGORY}/${PN}/files" + + COMMON_WORKAROUNDS=( + cmake-makefile.conf + devirtualize-at-ltrans.conf + graphite.conf + ipa-pta.conf + lto.conf + no-common-libtool.conf + no-plt.conf + no-semantic-interposition.conf + optimizations.conf + portage-bashrc-mv.conf + tls-dialect.conf + use-ld.conf + ) + + #Install make.conf settings + elog "Installing make.conf.lto.defines definitions for optimizations used in this overlay" + dosym "${LTO_PORTAGE_DIR}/make.conf.lto.defines" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/make.conf.lto.defines" + + elog "Installing make.conf.lto default full optimization config for make.conf" + dosym "${LTO_PORTAGE_DIR}/make.conf.lto" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/make.conf.lto" + + #Install main workarounds files + for i in "${COMMON_WORKAROUNDS[@]}"; do + elog "Installing package.cflags ${i} override" + dosym "${LTO_PORTAGE_DIR}/package.cflags/${i}" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/package.cflags/${i}" + done + + #Install -fno-common workarounds file + use keep-nocommon && dosym "${LTO_PORTAGE_DIR}/package.cflags/no-common.conf" \ + "${PORTAGE_CONFIGROOT#${EPREFIX}%/}/etc/portage/package.cflags/no-common.conf" + + # Install Clang LTO workarounds + use clang && dosym "${LTO_PORTAGE_DIR}/package.cflags/clang.conf" \ + "${PORTAGE_CONFIGROOT#${EPREFIX}%/}/etc/portage/package.cflags/clang.conf" + + #Install patch framework + elog "Installing bashrc.d hook symlink to apply LTO patches directly from lto-overlay" + dosym "${LTO_PORTAGE_DIR}/bashrc.d/41-lto-patch.sh" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/bashrc.d/41-lto-patch.sh" + + #Optional: install flag-o-matic overrides + if use override-flagomatic; then + ewarn "Installing bashrc.d hook to override strip-flags and replace-flags functions in flag-o-matic. This is an experimental feature!" + dosym "${LTO_PORTAGE_DIR}/bashrc.d/42-lto-flag-o-matic.sh" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/bashrc.d/42-lto-flag-o-matic.sh" + dosym "${LTO_PORTAGE_DIR}/package.cflags/flag-o-matic.conf" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/package.cflags/flag-o-matic.conf" + fi + + elog "Installing bashrc.d hook symlink to override package libtool lt_cv_sys_global_symbol_pipe and lt_cv_sys_global_symbol_to_cdecl" + dosym "${LTO_PORTAGE_DIR}/bashrc.d/43-lto-no-common.sh" "${PORTAGE_CONFIGROOT#${EPREFIX}}/etc/portage/bashrc.d/43-lto-no-common.sh" +} + +pkg_postinst() +{ + elog "If you have not done so, you will need to modify your make.conf settings to enable LTO building on your system." + elog "A symlink has been placed in ${PORTAGE_CONFIGROOT%/}/etc/portage/make.conf.lto that can be used as a basis for these modifications." + elog "See README.md for more details." + elog "lto-overlay and ltoize are part of a project to help find undefined behaviour in C and C++ programs through the use of aggressive compiler optimizations." + elog "One of the aims of this project is also to improve the performance of linux distributions through these mechanisms as well." + elog "Occasionally, you will experience breakage due to LTO problems. These are documented in the README.md of this repository." + elog "If you add an override for a particular package, please consider sending a pull request upstream so that other users of this repository can benefit." + ewarn "You will require a complete system rebuild in order to gain the benefits of LTO system-wide." + echo + elog "Please consider reading the README.md at the root of this repository before attempting to rebuild your system to familiarize yourself with the goals of this project and potential pitfalls you could run into." + echo + ewarn "This is an experimental project and should not be used on a stable system in its current state." + + BINUTILS_VER=$(binutils-config ${CHOST} -c | sed -e "s/.*-//") + + if ver_test "${BINUTILS_VER}" -lt 2.34; then + ewarn "Warning: active binutils version < 2.34, it is recommended that you use the newest binutils for LTO." + fi +}