From 5432ea326d4f8e0c107d08480378d763057c50c0 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Tue, 21 Dec 2021 22:33:42 +0100 Subject: [PATCH] changed LTO logic to match per-default enabled LTO in upstream Archlinux --- main.go | 4 ++-- utils.go | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 261f44e..771b368 100644 --- a/main.go +++ b/main.go @@ -120,10 +120,10 @@ func (b *BuildManager) buildWorker(id int, march string) { pkg.PkgFiles = []string{} // default to LTO - makepkgFile := "makepkg-%s-lto.conf" + makepkgFile := makepkg if pkg.DbPackage.Lto == dbpackage.LtoDisabled || pkg.DbPackage.Lto == dbpackage.LtoAutoDisabled { // use non-lto makepkg.conf if LTO is blacklisted for this package - makepkgFile = "makepkg-%s.conf" + makepkgFile = makepkgLTO } cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+filepath.Join(conf.Basedir.Work, makepkgDir)+" -l worker-"+march+"-"+strconv.Itoa(id)+" -r "+filepath.Join(conf.Basedir.Work, chrootDir)+" -- "+ diff --git a/utils.go b/utils.go index bb1ef3d..f010cc0 100644 --- a/utils.go +++ b/utils.go @@ -38,6 +38,8 @@ const ( chrootDir = "chroot" makepkgDir = "makepkg" waitingDir = "to_be_moved" + makepkgLTO = "makepkg-%s-non-lto.conf" + makepkg = "makepkg-%s.conf" ) var ( @@ -947,8 +949,8 @@ func syncMarchs() { //goland:noinspection SpellCheckingInspection func setupMakepkg(march string) error { - lMakepkg := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf("makepkg-%s.conf", march)) - lMakepkgLTO := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf("makepkg-%s-lto.conf", march)) + lMakepkg := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf(makepkg, march)) + lMakepkgLTO := filepath.Join(conf.Basedir.Work, makepkgDir, fmt.Sprintf(makepkgLTO, march)) err := os.MkdirAll(filepath.Join(conf.Basedir.Work, makepkgDir), 0755) if err != nil { @@ -965,25 +967,25 @@ func setupMakepkg(march string) error { makepkgStr = strings.ReplaceAll(makepkgStr, " check ", " !check ") } makepkgStr = strings.ReplaceAll(makepkgStr, " color ", " !color ") - makepkgStr = strings.ReplaceAll(makepkgStr, "-O2", "-O3") + // Add align-functions=32, see https://github.com/InBetweenNames/gentooLTO/issues/164 for more + makepkgStr = strings.ReplaceAll(makepkgStr, "-O2", "-O3 -falign-functions=32") makepkgStr = strings.ReplaceAll(makepkgStr, "#MAKEFLAGS=\"-j2\"", "MAKEFLAGS=\"-j"+strconv.Itoa(conf.Build.Makej)+"\"") makepkgStr = reMarch.ReplaceAllString(makepkgStr, "${1}"+march) makepkgStr = strings.ReplaceAll(makepkgStr, "#PACKAGER=\"John Doe \"", "PACKAGER=\"ALHP "+march+" \"") - // write non-lto makepkg + // write makepkg err = os.WriteFile(lMakepkg, []byte(makepkgStr), 0644) if err != nil { return err } - // Add LTO. Since (lto) not in devtools yet, add it instead. + // Remove LTO. Since lto is enabled pre default in devtools since 20211129-1, remove it. // See https://git.harting.dev/anonfunc/ALHP.GO/issues/52 for more - makepkgStr = strings.ReplaceAll(makepkgStr, "!lto", "") - makepkgStr = strings.ReplaceAll(makepkgStr, "!debug", "!debug lto") - // Add align-functions=32, see https://github.com/InBetweenNames/gentooLTO/issues/164 for more - makepkgStr = strings.ReplaceAll(makepkgStr, "-O3", "-O3 -falign-functions=32") + makepkgStr = strings.ReplaceAll(makepkgStr, "lto", "!lto") + // Remove align-functions=32, which is enabled because of LTO and not needed without + makepkgStr = strings.ReplaceAll(makepkgStr, "-falign-functions=32", "") - // write lto makepkg + // write non-lto makepkg err = os.WriteFile(lMakepkgLTO, []byte(makepkgStr), 0644) if err != nil { return err