PF4Public / gentoo-overlay

Personal Gentoo overlay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

www-client/ungoogled-chromium: Allow specifying linker thread count

mrnoname1000 opened this issue · comments

My desktop has 8 cores/16 threads so my MAKEOPTS is set to -j16, but when linking chromium with thinlto enabled, the 32GB of RAM eventually fills up. Could you add an environment variable or other way to specify how many linker threads should be used?

Also, QtWebengine's pre-emerge check multiplies makeopts_jobs by an estimate of the compiler's RAM usage, which if implemented here would prevent the OOM I encountered.

Right now it is kind of hardcoded here:

append-ldflags "-Wl,--thinlto-jobs=$(makeopts_jobs)"

How would you imagine this could be changed?

Upon further examination I think the simplest solution would be to scan LDFLAGS for the relevant flag. The value of the flag would probably need to be parsed out if the aforementioned pre-emerge check is implemented, but it would be an easy change to skip the append-ldflags call. I'm not very familiar with the ebuild infrastructure, but [[ " $LDFLAGS " =~ [[:space:]]-Wl,--thinlto-jobs=([[:digit:]]+|all)[[:space:]] ]] should do the trick. $BASH_REMATCH[1] can be used to grab the value too.

As the user, I would modify LDFLAGS like so:

# /etc/portage/package.env
www-client/ungoogled-chromium thinlto-jobs.conf
# /etc/portage/env/thinlto.jobs.conf
LDFLAGS="$LDFLAGS --Wl,--thinlto-jobs=8"

Alternatively, a dedicated environment variable could be used (like LTOTHREADS or something) but I'm not aware of any existing convention for this.

Just realized -flto=n could also be grepped to avoid the Clang-specific flag. Everything else I mentioned should still apply.