Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
distcc/crossdev question
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
skiwarz
Apprentice
Apprentice


Joined: 23 Feb 2014
Posts: 263

PostPosted: Fri Nov 26, 2021 4:36 am    Post subject: distcc/crossdev question Reply with quote

Happy Thanksgiving, Americans! And happy Thursday to everyone else!

I have an old laptop with an atom processor. It's getting hard to emerge everything on it these days, so I'm trying to set up some sort of binhost on my desktop machine. Both have amd64 architectures, although my desktop is an intel i7, so their features vary a bit :P
All I really want to do is have my desktop PC emerge a separate "world" (or some other set) using a second make.conf, and export the packages to a binhost instead of installing.

The three options I know of (and why I don't think they work in this situation) are:
1. After updating my desktop, use quickpkg to make a binary I can then pull in from my laptop. However, I would then need to have ALL of my laptop's packages also installed on my desktop... which is not ideal.
2. Use distcc to simply speed things up. This COULD work, however I have some weird power settings and scripts on my PCs to suspend/wake at certain times, which might interfere with distcc. Plus, I've read that linking operations still need to occur on the local machine with this method, which could still potentially exceed the specs of my laptop.
3. Use crossdev. I read through the gentoo wiki on this, and it seems like the tool is meant more for compiling on different architectures, not simply for a machine with a different make.conf. Particularly, you are supposed to run "crossdev -t x86_64-pc-linux-gnu" which seems like it will duplicate my current toolchain needlessly (and possibly causing conflicts).

EDIT: After trying to set up crossdev anyways, it flat out refuses:
Code:
crossdev --overlays cross-amd64 --stable -t x86_64-pc-linux-gnu
 * Refusing to create a cross-compiler using the same
 * target name as your host utils.
So, probably not the right method

Does anyone have any suggestions/recommendations/corrections to this situation?
Back to top
View user's profile Send private message
skiwarz
Apprentice
Apprentice


Joined: 23 Feb 2014
Posts: 263

PostPosted: Fri Nov 26, 2021 9:29 am    Post subject: Reply with quote

Kinda buggy, but here's what I came up with for a workaround, unless somebody can point me in a better direction:

create a "config-root" at /var/db/repos/laptop (it could have been anywhere, but this seemed logical)
create etc/portage in that config-root
copy all my portage config files over from my laptop into the new config-root
create a pkgdir folder on my NAS
modify the make.conf in my new config-root as such:

  • change -march=native to something more usable
  • change makeopts
  • change PKGDIR to point to my new pkgdir

created a new set at /var/db/repos/laptop/etc/portage/sets/laptop containing the packages I wish to build on my desktop
now, whenever I want to compile a new version, I need to:
emerge -a1qv --buildpkgonly --config-root=/var/db/repos/laptop --nodeps @laptop

The only problem with this method is that it won't handle update detection (emerge -u), since it doesn't know which versions I've emerged previously (only what is installed on my desktop). So when I try to "emerge -u" on my laptop, it will try to pull packages from my binhost that aren't there (and then try to compile them itself), until I manually emerge them.
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


Joined: 10 Sep 2021
Posts: 920
Location: Richmond Hill, Canada

PostPosted: Fri Nov 26, 2021 3:44 pm    Post subject: Reply with quote

Just an idea, You can use an docker container simulate your laptop. Or an VM.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Fri Nov 26, 2021 5:30 pm    Post subject: Reply with quote

skiwarz,

The trival case when the build CPU can execute all the instructions of the target CPU is to create a chroot that contains the install you want to build for.
You share distfiles and the repos, so you don't need two copies of them but you keep the binary packages separate.

Ask the Atom CPU what -march=native means and put that into make.conf or it will build for the wrong CPU.
Code:
gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'

Use the Atoms CPU_FLAGS_X86= too.

Now it can get trickier. Suppose that the Atom has some instructions that build host does not. This means that the build host can build things that it cannot execute.
That's mostly harmless and you won't know except for two circumstances.
Code that must run on the build host, like gcc, python, portage bash ... all the things the build system needs.
Code that build system build and execute as part of the build.

The fix for the first group is to set per package CFLAGS and CXXFLAGS. Either to suit the build host, it these packages will never be installed on the target, or to find a common set of instructions that work both places. There is also the option of building some packages twice, one with --buildpkgonly for the target and one to run on the build host.

The last set is harder. The code has to run on the build host, even if it will be suboptimal on the target. There is no real work around.
Hopefully, its a small number of packages. If execution performance matters, they will need to be built on the target, perhaps with help from distcc.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Fri Nov 26, 2021 5:32 pm    Post subject: Reply with quote

The traditional answer here is to use a chroot, which is like a Docker container or VM, but is lighter weight. Regardless of which of those three options is chosen, the desktop will need to build and install (in the isolated area) separate copies of every package the laptop needs, even if the desktop already uses that package. This has the minor virtue that at least the package is not installed on the desktop's root filesystem, but the drawback that packages which are used in both systems will be built twice.
Back to top
View user's profile Send private message
skiwarz
Apprentice
Apprentice


Joined: 23 Feb 2014
Posts: 263

PostPosted: Sat Nov 27, 2021 5:21 am    Post subject: Reply with quote

Thank you Neddy and Hu, you guys answered my question perfectly. I'll probably work on setting up a chroot soon. But in the meantime, I found a halfway decent workaround using some portage trickery:

Using the configuration I listed in my last post, I emerge the packages I need on my build system, adding the options "--buildpkgonly" and "--usepkg=y". Then I set a cron job to emerge the packages I need every night. If a particular version already exists in pkgdir, portage will pull it from pkgdir (--usepkg=y), unpack it and repack it, then upload back to pkgdir (--buildpkgonly). This way, I always have the newest versions available in pkgdir for my laptop's use, while not wasting processing time rebuilding every day.
It's a little gimmick-y, but it will do until I get around to setting up a proper chroot.

Thanks again guys,
-skiwarz
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Sat Nov 27, 2021 9:44 pm    Post subject: Reply with quote

Consider running a gentoo distribution on your laptop that has a binhost. I have been having good luck with calculate linux, which I install on old laptops and vm's that I use to run (guess what) distcc for my main machines. Calculate is pretty full featured, and leverages all your gentoo knowledge.

Jon.
Back to top
View user's profile Send private message
skiwarz
Apprentice
Apprentice


Joined: 23 Feb 2014
Posts: 263

PostPosted: Sat Nov 27, 2021 10:13 pm    Post subject: Reply with quote

jesnow wrote:
Consider running a gentoo distribution on your laptop that has a binhost. I have been having good luck with calculate linux, which I install on old laptops and vm's that I use to run (guess what) distcc for my main machines. Calculate is pretty full featured, and leverages all your gentoo knowledge.

Jon.


Nah, it's more fun this way :D
I like building things from source myself, as it makes me "feel" like I'm safer and more in control. I have another machine that runs slackware, and its package manager downloads binaries for everything, which constantly bothers me a bit in the back of my mind... lol
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