summarylogtreecommitdiffstats
path: root/03.pgo.patch
diff options
context:
space:
mode:
Diffstat (limited to '03.pgo.patch')
-rw-r--r--03.pgo.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/03.pgo.patch b/03.pgo.patch
new file mode 100644
index 000000000000..43b47ee551c8
--- /dev/null
+++ b/03.pgo.patch
@@ -0,0 +1,47 @@
+--- makepkg-optimize
++++ makepkg-optimize
+@@ -877,6 +877,21 @@ run_build() {
+ NMFLAGS+=" --plugin $LTOPLUGIN"
+ fi
+
++ # Generate or utilize pgo if it is requested (check buildenv and PKGBUILD opts)
++ if check_buildoption "pgo" "y"; then
++ if [ ! -d "$PROFDEST/$pkgbase.gen" ]; then
++ mkdir "$PROFDEST/$pkgbase.gen"
++ CFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
++ CXXFLAGS+=" -fprofile-generate -fprofile-dir=$PROFDEST/$pkgbase.gen"
++ LDFLAGS+=" -Wl,-lgcov"
++ elif [ ! -d "$PROFDEST/$pkgbase.used" ]; then
++ mv "$PROFDEST/$pkgbase.gen" "$PROFDEST/$pkgbase.used"
++ CFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
++ CXXFLAGS+=" -fprofile-correction -fprofile-use -fprofile-dir=$PROFDEST/$pkgbase.used"
++ fi
++ fi
++
++
+ run_function_safe "build"
+ }
+
+@@ -2012,6 +2027,7 @@ trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' E
+ # preserve environment variables and canonicalize path
+ [[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
+ [[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
++[[ -n ${PROFDEST} ]] && _PROFDEST=$(canonicalize_path ${PROFDEST})
+ [[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
+ [[ -n ${LOGDEST} ]] && _LOGDEST=$(canonicalize_path ${LOGDEST})
+ [[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
+@@ -2109,6 +2125,14 @@ if (( SOURCEONLY )); then
+ IGNOREARCH=1
+ fi
+
++PROFDEST=${_PROFDEST:-$PROFDEST}
++PROFDEST=${PROFDEST:-$startdir} #default to $startdir if undefined
++if [[ ! -w $PROFDEST ]] ; then
++ error "$(gettext "You do not have write permission to store profiles in %s.")" "$PROFDEST"
++ plain "$(gettext "Aborting...")"
++ exit 1
++fi
++
+ LOGDEST=${_LOGDEST:-$LOGDEST}
+ LOGDEST=${LOGDEST:-$startdir} #default to $startdir if undefined
+ if (( LOGGING )) && [[ ! -w $LOGDEST ]]; then