Skip to content

Commit

Permalink
Feat: Add -j flag to control build concurrency
Browse files Browse the repository at this point in the history
Hilariously enough on my overclocked i9 if I try to build tor with the previously  hardcoded `fmt.Sprintf("-j%d", runtime.NumCPU())` - I get sporadic internal gcc errors.

 This allows passing `-j 16`, which in my case permits me to build tor.
  • Loading branch information
yunginnanet committed Jun 18, 2024
1 parent 187c19c commit 3ecf4ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ var (
autopointPath string
folders = []string{"_openssl", "libevent", "zlib", "xz", "tor"}
absCurrDir = getAbsCurrDir()
numJobs = fmt.Sprintf("-j%d", runtime.NumCPU())
numJobsInt = runtime.NumCPU()
numJobs = ""
)

func main() {
flag.BoolVar(&verbose, "verbose", false, "Whether to show command output")
flag.StringVar(&host, "host", "", "Host option, useful for cross-compilation")
flag.StringVar(&autopointPath, "autopoint-path", "/usr/local/opt/gettext/bin", "OSX: Directory that contains autopoint binary")
flag.IntVar(&numJobsInt, "j", runtime.NumCPU(), "Number of jobs to run in parallel")
flag.Parse()
numJobs = fmt.Sprintf("-j%d", numJobsInt)
if len(flag.Args()) != 1 {
log.Fatal("Missing command. Can be build-all, build-<folder>, clean-all, clean-<folder>, show-libs, or package-libs")
}
Expand Down Expand Up @@ -206,12 +209,12 @@ func build(folder string) error {
env = append(env, "LIBS=-lcrypt32 -lgdi32")
}
torConf = []string{"sh", "./configure", "--prefix=" + pwd + "/dist",
"--disable-gcc-hardening", "--disable-system-torrc", "--disable-asciidoc",
"--disable-gcc-hardening", "--disable-linker-hardening", "--disable-system-torrc",
"--enable-static-libevent", "--with-libevent-dir=" + pwd + "/../libevent/dist",
"--enable-static-openssl", "--with-openssl-dir=" + pwd + "/../_openssl/dist",
"--enable-static-zlib", "--with-zlib-dir=" + pwd + "/../zlib/dist",
"--disable-systemd", "--disable-lzma", "--disable-seccomp",
"--disable-html-manual", "--disable-manpage"}
"--disable-html-manual", "--disable-manpage", "--disable-asciidoc"}

if host != "" {
torConf = append(torConf, "--host="+host)
Expand Down

0 comments on commit 3ecf4ba

Please sign in to comment.