Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
fast enable/distable distcc
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
mortonP
Tux's lil' helper
Tux's lil' helper


Joined: 22 Dec 2015
Posts: 89

PostPosted: Thu Oct 20, 2022 7:26 am    Post subject: fast enable/distable distcc Reply with quote

I use an underpowered laptop, but I got a distcc setup running, and compiling chromium with distcc workers drops compile time massively - yay! :-)

Problem is, with my laptop I'm moving around, so when I'm at home I have to compile locally, when I'm at a specific site I can use the extra, unused PCs there and on them VMs with Gentoo as workers...
Now I'm manually editing /etc/portage/make.conf, FEATURES for +distcc and MAKEOPTS to adjust -jx -l2y, and start distcc service.

Questions: Is there a more convenient way to do enable/disable this? Maybe an "emerge --distcc ...." option or something like that, to prevent always editing config files?

Thank you!
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9614
Location: beyond the rim

PostPosted: Thu Oct 20, 2022 9:42 am    Post subject: Reply with quote

Just add a function in your .profile:
Code:
emerge-distcc() {
    FEATURES="$FEATURES distcc" MAKEOPTS="$MAKEOPTS -jX -lY" emerge "$@"
}

(of course replacing X and Y)
Then call emerge-distcc instead of emerge whenever you want to build with distcc support.
Back to top
View user's profile Send private message
mortonP
Tux's lil' helper
Tux's lil' helper


Joined: 22 Dec 2015
Posts: 89

PostPosted: Fri Oct 21, 2022 2:39 pm    Post subject: Reply with quote

That's a good idea - put it into /root/.bashrc with my other custom stuff:

Code:
emerge-distcc() {
    FEATURES="parallel-fetch distcc" MAKEOPTS="-jXX -lY" emerge "$@"
}


I don't know whether that also works with .profile and custom additions like FEATURES="$FEATURES distcc".

Thank you!

Hmmm... the Rust-enabled stuff like firefox and thunderbird can also be parallelized/outsourced via sccache? - however once I tried to setup sccache and it failed with an error :-/ ... maybe that got fixed meanwhile?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22753

PostPosted: Fri Oct 21, 2022 4:09 pm    Post subject: Reply with quote

Genone specifically wrote FEATURES="$FEATURES features-you-want" so that any preexisting FEATURES environment variable would influence the resulting emerge. Your rewritten version replaces, rather than augments, $FEATURES. Therefore:
Code:
FEATURES=nostrip genone-emerge-distcc ... # nostrip is applied
FEATURES=nostrip mortonP-emerge-distcc ... # nostrip is not passed to emerge via FEATURES
One could also write it as:
Code:
emerge-distcc() {
    FEATURES="distcc $FEATURES" MAKEOPTS="-jX -lY $MAKEOPTS" emerge "$@"
}
This way, an explicit FEATURES=-distcc emerge-distcc would still disable it. That is not useful when the wrapper only changes one FEATURES flag, but if it changed more than one, allowing the user to override part of the implied features, and inherit the rest, could be useful.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Thu Nov 17, 2022 7:24 am    Post subject: Reply with quote

Hi, I have taken your approach defining an emerge-distcc function into my How to share /etc/portage and world file.
This is not only setting FEATURES for distcc but also different CFLAGS to have explicit -march= instead of native. However I wonder that CXXFLAGS also needs to be set although already defined as CXXFLAGS="${CFLAGS}": https://forums.gentoo.org/viewtopic-p-8759259.html#8759259
Any idea why this is the case?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9614
Location: beyond the rim

PostPosted: Thu Nov 17, 2022 8:07 am    Post subject: Reply with quote

Simple: The CXXFLAGS=$CFLAGS substitution takes place when the corresponding config file is parsed. If you then later override CFLAGS the content of CXXFLAGS no longer references CFLAGS. And that is how it should be.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Thu Nov 17, 2022 8:24 am    Post subject: Reply with quote

Genone wrote:
Simple: The CXXFLAGS=$CFLAGS substitution takes place when the corresponding config file is parsed. If you then later override CFLAGS the content of CXXFLAGS no longer references CFLAGS. And that is how it should be.
Isn't a temporary variable declaration exported to the forked environment of emerge before anything takes place inside there?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9614
Location: beyond the rim

PostPosted: Thu Nov 17, 2022 9:16 am    Post subject: Reply with quote

The substitution is done by portage itself when parsing the config, the build environment is not involved there and only ever sees the final result. Basically the same if you run "source make.conf" manually.

I'm not exactly sure which syntax elements are supported by portage these days, so if you really want to you may be able to bypass it using a syntax not supported by portage but only the actual shell, e.g. CXXFLAGS="\$(echo \$CFLAGS)" (again, no idea how portage will actually react to that, may take some trial-and-error to figure out the details).

Note that USE and some other special (so-called incremental) variables are treated a bit different, but those are limited to things affecting portage itself. For normal variables the last definition simply overwrites a previous one.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum