1
0
forked from ALHP/ALHP.GO

added LTO blacklist

This commit is contained in:
2021-11-13 20:45:47 +01:00
parent 9586bf80f6
commit de3ca80aab
3 changed files with 45 additions and 14 deletions

View File

@@ -23,7 +23,6 @@ march:
blacklist: blacklist:
packages: packages:
- pacman
- tensorflow - tensorflow
- tensorflow-cuda - tensorflow-cuda
- gcc - gcc
@@ -32,6 +31,9 @@ blacklist:
- i686 - i686
- staging - staging
- unstable - unstable
lto:
- llvm
- rust
build: build:
worker: 4 worker: 4

View File

@@ -77,9 +77,15 @@ func (b *BuildManager) buildWorker(id int) {
} }
pkg.PkgFiles = []string{} pkg.PkgFiles = []string{}
// default to LTO
makepkgFile := "makepkg-%s-lto.conf"
if contains(conf.Blacklist.LTO, pkg.Pkgbase) {
// use non-lto makepkg.conf if LTO is blacklisted for this package
makepkgFile = "makepkg-%s.conf"
}
cmd := exec.Command("sh", "-c", cmd := exec.Command("sh", "-c",
"cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+conf.Basedir.Makepkg+" -l worker-"+strconv.Itoa(id)+" -r "+conf.Basedir.Chroot+" -- "+ "cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+conf.Basedir.Makepkg+" -l worker-"+strconv.Itoa(id)+" -r "+conf.Basedir.Chroot+" -- "+
"--config "+filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s.conf", pkg.March))) "--config "+filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf(makepkgFile, pkg.March)))
var out bytes.Buffer var out bytes.Buffer
cmd.Stdout = &out cmd.Stdout = &out
cmd.Stderr = &out cmd.Stderr = &out

View File

@@ -83,6 +83,7 @@ type Conf struct {
Blacklist struct { Blacklist struct {
Packages []string Packages []string
Repo []string Repo []string
LTO []string `yaml:"lto"`
} }
} }
@@ -584,7 +585,10 @@ func syncMarchs() {
} }
for _, march := range conf.March { for _, march := range conf.March {
setupMakepkg(march) err := setupMakepkg(march)
if err != nil {
log.Errorf("Can't generate makepkg for %s: %v", march, err)
}
for _, repo := range conf.Repos { for _, repo := range conf.Repos {
fRepo := fmt.Sprintf("%s-%s", repo, march) fRepo := fmt.Sprintf("%s-%s", repo, march)
repos = append(repos, fRepo) repos = append(repos, fRepo)
@@ -612,28 +616,47 @@ func syncMarchs() {
} }
//goland:noinspection SpellCheckingInspection //goland:noinspection SpellCheckingInspection
func setupMakepkg(march string) { func setupMakepkg(march string) error {
lMakepkg := filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s.conf", march)) lMakepkg := filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s.conf", march))
lMakepkgLTO := filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf("makepkg-%s-lto.conf", march))
check(os.MkdirAll(conf.Basedir.Makepkg, 0755)) err := os.MkdirAll(conf.Basedir.Makepkg, 0755)
if err != nil {
return err
}
t, err := os.ReadFile(makepkgConf) t, err := os.ReadFile(makepkgConf)
check(err) if err != nil {
return err
}
makepkgStr := string(t) makepkgStr := string(t)
makepkgStr = strings.ReplaceAll(makepkgStr, "-mtune=generic", "") makepkgStr = strings.ReplaceAll(makepkgStr, "-mtune=generic", "")
makepkgStr = strings.ReplaceAll(makepkgStr, "!lto", "")
// 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, " check ", " !check ") makepkgStr = strings.ReplaceAll(makepkgStr, " check ", " !check ")
makepkgStr = strings.ReplaceAll(makepkgStr, " color ", " !color ") makepkgStr = strings.ReplaceAll(makepkgStr, " color ", " !color ")
// Add LTO. Since it's (!lto) not in devtools yet, add it instead. makepkgStr = strings.ReplaceAll(makepkgStr, "-O2", "-O3")
// See https://git.harting.dev/anonfunc/ALHP.GO/issues/52 for more
makepkgStr = strings.ReplaceAll(makepkgStr, "!debug", "!debug lto")
makepkgStr = strings.ReplaceAll(makepkgStr, "#MAKEFLAGS=\"-j2\"", "MAKEFLAGS=\"-j"+strconv.Itoa(conf.Build.Makej)+"\"") makepkgStr = strings.ReplaceAll(makepkgStr, "#MAKEFLAGS=\"-j2\"", "MAKEFLAGS=\"-j"+strconv.Itoa(conf.Build.Makej)+"\"")
makepkgStr = reMarch.ReplaceAllString(makepkgStr, "${1}"+march) makepkgStr = reMarch.ReplaceAllString(makepkgStr, "${1}"+march)
check(os.WriteFile(lMakepkg, []byte(makepkgStr), 0644)) // write non-lto makepkg
err = os.WriteFile(lMakepkg, []byte(makepkgStr), 0644)
if err != nil {
return err
}
// Add LTO. Since (lto) not in devtools yet, add it instead.
// 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")
// write lto makepkg
err = os.WriteFile(lMakepkgLTO, []byte(makepkgStr), 0644)
if err != nil {
return err
}
return nil
} }
func isMirrorLatest(h *alpm.Handle, buildPkg *BuildPackage) (bool, alpm.IPackage, string, error) { func isMirrorLatest(h *alpm.Handle, buildPkg *BuildPackage) (bool, alpm.IPackage, string, error) {