Package Details: makepkg-optimize-mold 30-2

Git Clone URL: https://aur.archlinux.org/makepkg-optimize-mold.git (read-only, click to copy)
Package Base: makepkg-optimize-mold
Description: Supplemental build and packaging optimizations for makepkg
Upstream URL: https://wiki.archlinux.org/index.php/Makepkg-optimize
Keywords: makepkg-optimize makepkg-tweaks mold
Licenses: GPL-1.0-only
Submitter: ptr1337
Maintainer: ptr1337
Last Packager: ptr1337
Votes: 5
Popularity: 0.014820
First Submitted: 2021-12-31 21:48 (UTC)
Last Updated: 2024-08-24 12:42 (UTC)

Dependencies (11)

Required by (0)

Sources (26)

Latest Comments

1 2 3 4 Next › Last »

Tjuh commented on 2025-09-12 14:22 (UTC)

Cool, glad to help ;)

brikler commented on 2025-09-12 09:49 (UTC)

thank you again @Tjuh i was able to solve my problem by using bash instead fish

Tjuh commented on 2025-09-11 19:02 (UTC)

Also symlinked lld to point to ld; sudo ln /usr/bin/ld.lld /usr/bin/ld

Tjuh commented on 2025-09-11 18:40 (UTC)

Check out my makepkg.conf for suggestions;

#!/hint/bash
# shellcheck disable=2034

DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
          'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')
VCSCLIENTS=('bzr::breezy'
            'fossil::fossil'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"
PACKAGECARCH="x86_64_v3"

CFLAGS="-v -march=znver3 -Ofast -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffp-contract=fast -munsafe-fp-atomics -mtgsplit -fplugin=LLVMPolly.so --param=ssp-buffer-size=4 -DNDEBUG -fPIC -falign-functions=32 -fcoroutines -fdata-sections -fexperimental-library -ffunction-sections -flto=thin -fmerge-all-constants -fopenmp -fopenmp-cuda-mode -fopenmp-enable-irbuilder -fopenmp-extensions -fopenmp-optimistic-collapse -funroll-loops -fvisibility-inlines-hidden -fwhole-program-vtables -mprefer-vector-width=256 -mrelax-all -mllvm -polly -mllvm -polly-num-threads=16 -mllvm -polly-omp-backend=LLVM -mllvm -polly-parallel -mllvm -polly-position=before-vectorizer -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-scheduling=dynamic -mllvm -polly-vectorizer=stripmine -mllvm -polly-process-unprofitable -mllvm -polly-use-llvm-names -pthread -stdlib=libc++ -w -fno-threadsafe-statics -Wno-incompatible-pointer-types -Wno-sign-conversion -Wno-sizeof-pointer-memaccess -Wno-unused-function -Wno-unused-parameter -Wno-error -fno-finite-math-only"
CXXFLAGS="$CFLAGS -std=gnu++23"
LDFLAGS="-Wl,-O2,--sort-common,--as-needed,-zrelro,-znow,-zpack-relative-relocs,--emit-relocs,--gc-sections,--hash-style=gnu,--icf=safe,--ignore-data-address-equality,--ignore-function-address-equality,--optimize-bb-jumps,--print-gc-sections,--print-icf-sections,--strip-debug,--trace,--verbose,--thinlto-cache-dir=/tmp,--thinlto-jobs=16,-lmimalloc,-lomp,-lpthread,-zifunc-noplt,-znotext,-zmax-page-size=0x4000,-zseparate-code,-zseparate-loadable-segments,-zshstk,-lm"
MAKEFLAGS="-j16"
NINJAFLAGS="-j16"

#BUILDDIR="/tmp/makepkg"
BUILDENV=(color !check !sign)
OPTIONS=(!strip !docs !emptydirs !libtool !staticlibs)
INTEGRITY_CHECK=(sha256)
DOC_DIRS=(usr/share/{doc,gtk-doc,locale,metainfo,zsh,man,vim,ffmpeg,lua-examples,backgrounds,themes,licenses})

LOGDEST="/home/tjuh/logs"
PKGDEST="/home/tjuh/packages"
SRCDEST="/home/tjuh/sources"

PACKAGER="Tjuh <tjuh@proton.me>"
COMPRESSZST=(zstd -c -z -vv --ultra -22 -T16 -)
PKGEXT=".pkg.tar.zst"
SRCEXT=".src.tar.gz"
GITFLAGS="--filter=tree:0"
chrt -iap 0 $$

brikler commented on 2025-09-11 12:17 (UTC) (edited on 2025-09-11 12:22 (UTC) by brikler)

thank you @Tjuh

it seems it is a bit more complicated :(

stderr: cc: error: unrecognized command-line option ‘-mllvm’
cc: error: unrecognized command-line option ‘-polly’
cc: error: unrecognized command-line option ‘-mllvm’
cc: error: unrecognized command-line option ‘-polly-num-threads=8’
cc: error: unrecognized command-line option ‘-mllvm’
cc: error: unrecognized command-line option ‘-polly-parallel’
cc: error: unrecognized command-line option ‘-Xclang’ 

/usr/share/makepkg/buildenv/graphite.sh:

buildenv_graphite() {
    if check_buildoption "graphite" "y" || check_buildoption "polly" "y"; then
        graphiteflags=" -lgomp -mllvm -polly -mllvm -polly-num-threads=$(getconf _NPROCESSORS_ONLN) -mllvm -polly-parallel"
        check_buildoption "polly" "y" && \
            graphiteflags+=" -Xclang -load -fplugin=LLVMPolly.so"
        check_buildoption "graphite" "y" && \
            graphiteflags=" -fgraphite-identity -floop-interchange -floop-nest-optimize -floop-parallelize-all -ftree-loop-distribution -ftree-parallelize-loops=$(getconf _NPROCESSORS_ONLN) -ftree-vectorize"

        CFLAGS+="$graphiteflags"
        CXXFLAGS+="$graphiteflags"
    fi

Tjuh commented on 2025-09-04 17:49 (UTC)

Install polly and use this -fplugin=LLVMPolly.so instead of -Xclang -load -Xclang LLVMPolly.so. Also that PGO script doesn't work with Clang, only GCC.

brikler commented on 2025-08-07 14:57 (UTC) (edited on 2025-08-07 14:58 (UTC) by brikler)

hi,

it seems something isn't ok with makepkg-optimize-mold :( and pgo also doesn't work

error: unable to load plugin 'LLVMPolly.so': 'LLVMPolly.so: cannot open shared object file: No such file or directory'
clang (LLVM option parsing): Unknown command line argument '-polly'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--color'?
clang (LLVM option parsing): Unknown command line argument '-polly-num-threads=8'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--xcore-max-threads=8'?
clang (LLVM option parsing): Unknown command line argument '-polly-parallel'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--enable-pre'?
make[1]: *** [<builtin>: conn_bomb] Error 1
make[1]: *** Waiting for unfinished jobs....

clang -march=native -O2 -pipe -pthread -lgomp -mllvm -polly -mllvm -polly-num-threads=8 -mllvm -polly-parallel -Xclang -load -Xclang LLVMPolly.so -flto=auto -fprofile-generate -fprofile-dir=/home/tom/compile/bpftune-git/bpftune-git.gen -lpthread -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -lgcov --coverage conn_bomb.c -o conn_bomb

oech3 commented on 2025-07-16 15:11 (UTC)

@ptr1337 I think this should have proper upstream (instead of wiki) and replace makepkg-optimize which is not maintained.

murlakatamenka commented on 2025-02-04 09:25 (UTC) (edited on 2025-07-21 20:10 (UTC) by murlakatamenka)

Peter @ptr1337, consider using oxipng instead of optipng

Why?

1) It does optimize better.

You can see that optipng is one of the dependencies of Calibre. Indeed, it's used internally by it:

https://github.com/kovidgoyal/calibre/blob/eb161166b05f33eb0ff6bda97bac1fafadca77c5/src/calibre/utils/img.py#L621-L625

CLI utility of calibre ebook-polish is using it. My experience is that after running epub-polish on EPUB book with PNG images, the latter can be further optimized with oxipng:

oxipng --opt max extracted_epub/**.png

So it means that optipng doesn't optimally encodes PNGs. Worth noting that oxipng with --opt max doesn't use Zopfli, there is separate CLI switch for it, i.e. it's not why oxipng compresses files better.

2) oxipng is faster (multithreaded, uses all avaliable cores/threads by default).

As stated in the project's README:

The core goal of rewriting OptiPNG was to implement multithreading, which would be very difficult to do within the existing C codebase of OptiPNG. This also served as an opportunity to choose a more modern, safer language (Rust).

Multi-threading would be especially useful if you need to optimize only a few images (< $(nproc)), because you won't be able to utilize all your threads with single-threaded optipng, unlike with oxipng

brikler commented on 2024-11-30 09:04 (UTC) (edited on 2024-11-30 09:05 (UTC) by brikler)

makepkg-optimize.conf isn't properly created

CFLAGS="-march=native -O3 -pipe -fno-plt -fexceptions \
#CFLAGS="-march=native -O3 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt -fopenmp -pthread -Wno-error -w" #
#CFLAGS="-march=native -Og -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt" #
        -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"