aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. Jung2022-01-06 23:34:12 +0000
committerP. Jung2022-01-06 23:34:12 +0000
commit5b5ae11e02025cef933386404e03b1f390b0f564 (patch)
tree886c0013e00bfcd8d8d1c30efb7ce077e8e8fb66
parent064328a8d2b5f303094bfe04b913158e143d42b3 (diff)
downloadaur-5b5ae11e02025cef933386404e03b1f390b0f564.tar.gz
fixes
-rw-r--r--.SRCINFO8
-rw-r--r--PKGBUILD8
-rw-r--r--README.md47
-rw-r--r--ZZ-lto.sh.in11
-rw-r--r--buildenv_ext.conf4
-rw-r--r--gcc11-support-mold.patch128
-rw-r--r--mold.sh.in8
7 files changed, 196 insertions, 18 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 311db8f94e69..7085b3eb5508 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = makepkg-optimize-mold
pkgdesc = Supplemental build and packaging optimizations for makepkg
- pkgver = 19
+ pkgver = 20
pkgrel = 1
url = https://wiki.archlinux.org/index.php/Makepkg-optimize
arch = any
@@ -35,10 +35,10 @@ pkgbase = makepkg-optimize-mold
source = pkgopts-param_ext.conf
source = compress-param_max.conf
sha1sums = 4c5f0be71638a6ec2f18c01675d99f19eb6dd45d
- sha1sums = 8a29f5b36fd191f5ca061625f006dfe822148281
+ sha1sums = befd8d13ef5c2ec92f4bc9f3981af8d32e8a6223
sha1sums = d7a3801037333c582dba976db27cf8896bc1b401
sha1sums = 3a356f52131e39f59d360c54a572d678c7208b42
- sha1sums = 9ea51e4cade43db60a43ebc7f41bdb19f881c94b
+ sha1sums = 83fb4e2bc0a75e91d7db317d221f45a6dc525e8a
sha1sums = a893c32f2a3fff8b279025ec60f0c3d88143dc1e
sha1sums = 9270b5e33d4508a959688a10c20dec3732763937
sha1sums = 34a33b47a8b667f9dc810737c0f598660b962d4c
@@ -51,7 +51,7 @@ pkgbase = makepkg-optimize-mold
sha1sums = f17b1a8ccbd807fd59fbc716cc695be32e261e38
sha1sums = 3c61762a183a2f76cc2ff2e55cfffb68b6a8320c
sha1sums = 981eab856abb43c5e093620cdf4d8bfa2d690805
- sha1sums = 02b26a3abf1102fb9d1c746575b570265b10f11d
+ sha1sums = 62ffed4ae52c9b828115633f4d7ccc57b45caed2
sha1sums = efb3ed7d7d5516259709149d7bcd6ec208c07593
sha1sums = 1fc8035e64b739e20c70fbb4eaa5cb7aa1c63c90
sha1sums = 5d0cde13b50641371e4ec4d813d6b2dfae493889
diff --git a/PKGBUILD b/PKGBUILD
index a85b299a8a45..34e4831b1462 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
# Contributor: bartus ( aur\at\bartus.33mail.com )
pkgname=makepkg-optimize-mold
-pkgver=19
+pkgver=20
pkgrel=1
pkgdesc='Supplemental build and packaging optimizations for makepkg'
arch=('any')
@@ -25,10 +25,10 @@ source=(${_buildenv[@]}
${_tidy[@]}
${_conf[@]})
sha1sums=('4c5f0be71638a6ec2f18c01675d99f19eb6dd45d'
- '8a29f5b36fd191f5ca061625f006dfe822148281'
+ 'befd8d13ef5c2ec92f4bc9f3981af8d32e8a6223'
'd7a3801037333c582dba976db27cf8896bc1b401'
'3a356f52131e39f59d360c54a572d678c7208b42'
- '9ea51e4cade43db60a43ebc7f41bdb19f881c94b'
+ '83fb4e2bc0a75e91d7db317d221f45a6dc525e8a'
'a893c32f2a3fff8b279025ec60f0c3d88143dc1e'
'9270b5e33d4508a959688a10c20dec3732763937'
'34a33b47a8b667f9dc810737c0f598660b962d4c'
@@ -41,7 +41,7 @@ sha1sums=('4c5f0be71638a6ec2f18c01675d99f19eb6dd45d'
'f17b1a8ccbd807fd59fbc716cc695be32e261e38'
'3c61762a183a2f76cc2ff2e55cfffb68b6a8320c'
'981eab856abb43c5e093620cdf4d8bfa2d690805'
- '02b26a3abf1102fb9d1c746575b570265b10f11d'
+ '62ffed4ae52c9b828115633f4d7ccc57b45caed2'
'efb3ed7d7d5516259709149d7bcd6ec208c07593'
'1fc8035e64b739e20c70fbb4eaa5cb7aa1c63c90'
'5d0cde13b50641371e4ec4d813d6b2dfae493889'
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..994325f0a82e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,47 @@
+# makepkg-optimize
+
+makepkg-optimizeAUR is a collection of supplemental tidy, buildenv, and executable scripts for pacman which provide macros for several kinds of optimization in the build() and package() stages.
+
+## Installation
+
+Install makepkg-optimize-mold(https://aur.archlinux.org/packages/makepkg-optimize-mold/) and, to make optimizations available, install their backends: openmp, upx, optipng, svgo and mold
+
+## Configuration
+
+makepkg-optimize generates a redundant configuration file, /etc/makepkg-optimize.conf, from your current makepkg.conf configuration.
+
+This file lists supplementary COMPILE FLAGS, BUILD ENVIRONMENT options, GLOBAL PACKAGE OPTIONS, PACKAGE OUTPUT options, and COMPRESSION DEFAULTS, all of which are disabled by default.
+
+Some packages may fail to build with certain optimizations and over-optimization may cause problems for some programs--such as decreased performance and segmentation faults.
+
+## Build an optimized package
+
+After selecting your preferred optimizations, pass the configuration file when building:
+
+- makepkg -c --config /etc/makepkg-optimize.conf
+
+### Profile-guided optimization
+
+Note: Profile-guided optimization requires that a package be built and installed twice. The first phase initiates profile generation in $PROFDEST/pkgbase.gen; the second moves them to $PROFDEST/pkgbase.used and applies them
+
+## Build an optimized package in a clean chroot
+
+Alternatively, makepkg-optimize can be used to build optimized packages within a chroot.
+
+## Create a PGO cache ====
+
+To use PGO, create a folder in the same place, inside and outside of the chroot, to store [https://gcc.gnu.org/onlinedocs/gcc/Gcov-Data-Files.html profiles]:
+
+ - mkdir -m 777 {"$CHROOT"/{root,"$USER"},}/mnt/pgo
+
+Then edit CHROOT/root/etc/makepkg-optimize.conf and set PROFDEST=/mnt/pgo.
+
+## Building with PGO
+
+After the first building phase, bind the PGO cache:
+
+- mount -o bind {,"CHROOT"/root}/mnt/pgo
+
+- mount -o bind "$CHROOT"/{root,"$USER"}/mnt/pgo
+
+Tip: Use fstab to bind these folders at boot.
diff --git a/ZZ-lto.sh.in b/ZZ-lto.sh.in
index 6d0972cd9d39..eb7c526b0b36 100644
--- a/ZZ-lto.sh.in
+++ b/ZZ-lto.sh.in
@@ -1,6 +1,7 @@
#!/usr/bin/bash
#
-# ZZ-lto.sh - Compile with link-time optimization
+# ZZ-lto.sh - Compile with link-time optimization # Changed lto to lto-gcc because arch already provides the options with lto
+#
#
[[ -n "$LIBMAKEPKG_BUILDENV_LTO_SH" ]] && return
@@ -10,18 +11,18 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/option.sh"
-build_options+=('lto' 'lto-thin' 'lto-clang' 'lto-thin-clang')
+build_options+=('lto-gcc' 'lto-thin' 'lto-clang' 'lto-thin-clang')
buildenv_functions+=('buildenv_lto')
buildenv_lto() {
- if check_buildoption "lto" "y" || check_buildoption "lto-thin" "y" || \
+ if check_buildoption "lto-gcc" "y" || check_buildoption "lto-thin" "y" || \
check_buildoption "lto-clang" "y" || check_buildoption "lto-thin-clang" "y"; then
ltoflags=" -flto"
check_buildoption "lto-thin-clang" "y" && ltoflags+="=thin"
- check_buildoption "lto-thin" "y" || check_buildoption "lto" "y" && \
+ check_buildoption "lto-thin" "y" || check_buildoption "lto-gcc" "y" && \
[[ -f "$(gcc -print-search-dirs | grep install | awk '{print $2 "liblto_plugin.so"}')" ]] && \
ltoflags+="=auto -fno-fat-lto-objects"
- check_buildoption "lto" "y" && ltoflags+=" -flto-partition=none"
+ check_buildoption "lto-gcc" "y" && ltoflags+=" -flto-partition=none"
CFLAGS+="$ltoflags"
CXXFLAGS+="$ltoflags"
diff --git a/buildenv_ext.conf b/buildenv_ext.conf
index e034fa916c3b..3c50beb080ee 100644
--- a/buildenv_ext.conf
+++ b/buildenv_ext.conf
@@ -1,6 +1,6 @@
-#-- lto{,-clang}: Use monolithic link-time optimization (use "lto-clang" for clang/llvm)
+#-- lto-gcc{,-clang}: Use monolithic link-time optimization (use "lto-clang" for clang/llvm)
#-- lto-thin{,-clang}: Use partitioned link-time optimization (use "lto-thin-clang" for clang/llvm)
#-- pgo: Generate or utilize profile guided optimization (requires two build and install cycles)
#-- {graphite,polly}: Use polyhedral model optimization (use "polly" for clang/llvm)
#-- rice{,-clang}: Use extreme and unsafe optimization (use "rice-clang" for clang/llvm)
-#-- mold: Use the fast mold linker (does not work with lto, and for gcc versions under 12)
+#-- mold: Use the fast mold linker (Can be used for GCC 12 or GCC 11.x (11 needs a patch), if you compile it yourself with the patch in the repo here, CLANG works without problems)
diff --git a/gcc11-support-mold.patch b/gcc11-support-mold.patch
new file mode 100644
index 000000000000..ca5a5f6798c0
--- /dev/null
+++ b/gcc11-support-mold.patch
@@ -0,0 +1,128 @@
+From ad964f7eaef9c03ce68a01cfdd7fde9d56524868 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Tue, 21 Dec 2021 17:43:55 +0100
+Subject: [PATCH] Support ld.mold linker.
+
+gcc/ChangeLog:
+
+ * collect2.c (main): Add ld.mold.
+ * common.opt: Add -fuse-ld=mold.
+ * doc/invoke.texi: Document it.
+ * gcc.c (driver_handle_option): Handle -fuse-ld=mold.
+ * opts.c (common_handle_option): Likewise.
+---
+ gcc/collect2.c | 10 +++++++---
+ gcc/common.opt | 4 ++++
+ gcc/doc/invoke.texi | 4 ++++
+ gcc/gcc.c | 4 ++++
+ gcc/opts.c | 1 +
+ 5 files changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/collect2.c b/gcc/collect2.c
+index d47fe3f9195..b322527847c 100644
+--- a/gcc/collect2.c
++++ b/gcc/collect2.c
+@@ -776,6 +776,7 @@ main (int argc, char **argv)
+ USE_GOLD_LD,
+ USE_BFD_LD,
+ USE_LLD_LD,
++ USE_MOLD_LD,
+ USE_LD_MAX
+ } selected_linker = USE_DEFAULT_LD;
+ static const char *const ld_suffixes[USE_LD_MAX] =
+@@ -784,7 +785,8 @@ main (int argc, char **argv)
+ PLUGIN_LD_SUFFIX,
+ "ld.gold",
+ "ld.bfd",
+- "ld.lld"
++ "ld.lld",
++ "ld.mold"
+ };
+ static const char *const real_ld_suffix = "real-ld";
+ static const char *const collect_ld_suffix = "collect-ld";
+@@ -957,6 +959,8 @@ main (int argc, char **argv)
+ selected_linker = USE_GOLD_LD;
+ else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
+ selected_linker = USE_LLD_LD;
++ else if (strcmp (argv[i], "-fuse-ld=mold") == 0)
++ selected_linker = USE_MOLD_LD;
+ else if (strncmp (argv[i], "-o", 2) == 0)
+ {
+ /* Parse the output filename if it's given so that we can make
+@@ -1048,7 +1052,7 @@ main (int argc, char **argv)
+ ld_file_name = 0;
+ #ifdef DEFAULT_LINKER
+ if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD ||
+- selected_linker == USE_LLD_LD)
++ selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD)
+ {
+ char *linker_name;
+ # ifdef HOST_EXECUTABLE_SUFFIX
+@@ -1283,7 +1287,7 @@ main (int argc, char **argv)
+ else if (!use_collect_ld
+ && startswith (arg, "-fuse-ld="))
+ {
+- /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
++ /* Do not pass -fuse-ld={bfd|gold|lld|mold} to the linker. */
+ ld1--;
+ ld2--;
+ }
+diff --git a/gcc/common.opt b/gcc/common.opt
+index 2ed818d6057..dba3fa886f9 100644
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -3046,6 +3046,10 @@ fuse-ld=lld
+ Common Driver Negative(fuse-ld=lld)
+ Use the lld LLVM linker instead of the default linker.
+
++fuse-ld=mold
++Common Driver Negative(fuse-ld=mold)
++Use the Modern linker (MOLD) linker instead of the default linker.
++
+ fuse-linker-plugin
+ Common Undocumented Var(flag_use_linker_plugin)
+
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index e644c63767b..54fa75ba138 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -16266,6 +16266,10 @@ Use the @command{gold} linker instead of the default linker.
+ @opindex fuse-ld=lld
+ Use the LLVM @command{lld} linker instead of the default linker.
+
++@item -fuse-ld=mold
++@opindex fuse-ld=mold
++Use the Modern Linker (@command{mold}) instead of the default linker.
++
+ @cindex Libraries
+ @item -l@var{library}
+ @itemx -l @var{library}
+diff --git a/gcc/gcc.c b/gcc/gcc.c
+index b75b50b87b2..06e18a75b52 100644
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -4282,6 +4282,10 @@ driver_handle_option (struct gcc_options *opts,
+ use_ld = ".gold";
+ break;
+
++ case OPT_fuse_ld_mold:
++ use_ld = ".mold";
++ break;
++
+ case OPT_fcompare_debug_second:
+ compare_debug_second = 1;
+ break;
+diff --git a/gcc/opts.c b/gcc/opts.c
+index e4e47ff77b3..f820052307c 100644
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -3105,6 +3105,7 @@ common_handle_option (struct gcc_options *opts,
+ case OPT_fuse_ld_bfd:
+ case OPT_fuse_ld_gold:
+ case OPT_fuse_ld_lld:
++ case OPT_fuse_ld_mold:
+ case OPT_fuse_linker_plugin:
+ /* No-op. Used by the driver and passed to us because it starts with f.*/
+ break;
+--
+2.27.0
diff --git a/mold.sh.in b/mold.sh.in
index 869534501cb5..745d6c30a8d3 100644
--- a/mold.sh.in
+++ b/mold.sh.in
@@ -14,10 +14,12 @@ build_options+=('mold')
buildenv_functions+=('buildenv_mold')
buildenv_mold() {
- if check_buildoption "mold" "y"; then
+ if
+ check_buildoption "mold" "y"; then
moldflags=" -fuse-ld=mold"
CFLAGS+="$moldflags"
- CFLAGS+="$moldflags"
- CLAGS+="$moldflags"
+ CXXFLAGS+="$moldflags"
+ LDFLAGS+="$moldflags"
+
fi
}