changed LTO logic to match per-default enabled LTO in upstream Archlinux

This commit is contained in:
Giovanni Harting 2021-12-21 22:33:42 +01:00
parent 4bd831142f
commit 5432ea326d
2 changed files with 14 additions and 12 deletions

View File

@ -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)+" -- "+

View File

@ -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 <john@doe.com>\"", "PACKAGER=\"ALHP "+march+" <alhp@harting.dev>\"")
// 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