Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to setup a cross-compiling portage-prefix on computer?
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
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Thu Apr 04, 2024 9:40 am    Post subject: How to setup a cross-compiling portage-prefix on computer? Reply with quote

I want a package manager, to work with my small risc-v single-board computer, so I need a special portage-prefix environment with cross-compiling toolchain
but portage-prefix documents doesn't contained that, so how to setup such a enviroment?
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Thu Apr 04, 2024 4:04 pm    Post subject: Reply with quote

Dawn_Xu,

May be you are thinking sys-devel/crossdev?

Portage's Prefix is very special setup, it is design toward where you have a non-Gentoo based system and may be have no existing solution (no permission for example) to install build tools. so the Gentoo Portage Prefix allow you to install into a non-root based location. Do you really have this requirement?

In my opinion if you don't have Gentoo based environment ready to use, It may be easier to use Container (Docker for example) as replacement for Gentoo Portage Prefix.
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Fri May 17, 2024 2:08 pm    Post subject: Reply with quote

pingtoo wrote:


Now I encounter a new problem, I need a prefix with crossdev, because I don't want make mess in my single-board computer's /usr/
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Sat May 18, 2024 1:35 pm    Post subject: Reply with quote

Dawn_Xu wrote:
pingtoo wrote:


Now I encounter a new problem, I need a prefix with crossdev, because I don't want make mess in my single-board computer's /usr/


Can you explain what is the concern of having additional cross compile tool chain install in /usr?

I have also suggest container may be a better fit for you, so I am not sure why you choose not to use container either?

BTW, crossdev have a command line option to clean up entire crossdev installation, may be that option will suite your need?
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Sat May 18, 2024 2:16 pm    Post subject: Reply with quote

pingtoo wrote:



Can you explain what is the concern of having additional cross compile tool chain install in /usr?

I have also suggest container may be a better fit for you, so I am not sure why you choose not to use container either?

BTW, crossdev have a command line option to clean up entire crossdev installation, may be that option will suite your need?



Hmmm, my English is poor..
But my opinion is when I copy the contains in
Code:
/usr/toolchain_name/usr
from host PC to my single-board computer, it would pollute the SBC's /usr path. So I need a prefix with it, to keep clean and isolated with SBC's rootFS
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat May 18, 2024 2:30 pm    Post subject: Reply with quote

Dawn_Xu,

Install crossdev on the build host.
Use crossdev to produce a cross toolchain.
It will create a /usr/<target-tuple> on the build host.

Everything that is cross compiled for <target-tuple> will be installed into /usr/<target-tuple>.
You will also get binary packages that can be installed onto the target.
There is no building taking place on the target at all.

If you have root access an the target and want to keep Gentoo ant the existing install separate, Gentoo can be installed to its own partition, or it can be a chroot on the existing install.
The chroot approach requires that the existing kernel can support your Gentoo userland
_________________
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
pingtoo
l33t
l33t


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

PostPosted: Sat May 18, 2024 2:33 pm    Post subject: Reply with quote

Dawn_Xu wrote:
pingtoo wrote:



Can you explain what is the concern of having additional cross compile tool chain install in /usr?

I have also suggest container may be a better fit for you, so I am not sure why you choose not to use container either?

BTW, crossdev have a command line option to clean up entire crossdev installation, may be that option will suite your need?



Hmmm, my English is poor..
But my opinion is when I copy the contains in
Code:
/usr/toolchain_name/usr
from host PC to my single-board computer, it would pollute the SBC's /usr path. So I need a prefix with it, to keep clean and isolated with SBC's rootFS


I think you have misunderstood what crossdev is. Crossdev is to build a native(for you PC) compiler tool chain. And the crossdev tool chain in turn can build binary for your SBC.

If you move the crossdev (/usr/toolchain_name/usr) to your SBC, it will stop working because that binary set is for your PC.

If you wish to use your PC as the development for your SBC, you should consider use QEMU or a container with static qemu-user binary in the container and build from the VM or container.
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Sat May 18, 2024 2:40 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Dawn_Xu,

Install crossdev on the build host.
Use crossdev to produce a cross toolchain.
It will create a /usr/<target-tuple> on the build host.

Everything that is cross compiled for <target-tuple> will be installed into /usr/<target-tuple>.
You will also get binary packages that can be installed onto the target.
There is no building taking place on the target at all.

If you have root access an the target and want to keep Gentoo ant the existing install separate, Gentoo can be installed to its own partition, or it can be a chroot on the existing install.
The chroot approach requires that the existing kernel can support your Gentoo userland



I see, I see. But it's just a SINGLE-BOARD-COMPUTER, with only 64MiB RAM, so a chroot container of Gentoo in userland is not the solution, and that's why I need a prefixed crossdev. I need to compile with my PC, and copy the folder to the SBC's rootFS -- without polluting the SBC's /usr path
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Sat May 18, 2024 2:43 pm    Post subject: Reply with quote

pingtoo wrote:


I think you have misunderstood what crossdev is. Crossdev is to build a native(for you PC) compiler tool chain. And the crossdev tool chain in turn can build binary for your SBC.

If you move the crossdev (/usr/toolchain_name/usr) to your SBC, it will stop working because that binary set is for your PC.

If you wish to use your PC as the development for your SBC, you should consider use QEMU or a container with static qemu-user binary in the container and build from the VM or container.



In fact, I need cross-emerge to create binary executable for my SBC,
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Sat May 18, 2024 2:48 pm    Post subject: Reply with quote

Dawn_Xu wrote:
I see, I see. But it's just a SINGLE-BOARD-COMPUTER, with only 64MiB RAM, so a chroot container of Gentoo in userland is not the solution, and that's why I need a prefixed crossdev. I need to compile with my PC, and copy the folder to the SBC's rootFS -- without polluting the SBC's /usr path


I am not sure if you understood Neddy's saying. As Neddy is talk the same as I do.

I have NOT suggest you build on your SBC (by the way I do know what SBC mean). I am suggest you use a VM or container (container by design, is a chroot environment) on your PC, build any binary you want and copy the result binary into your SBC.

BTW, compiler tool chain usually have tool set location path hard coded during generate time. so it is very difficult to relocate them from initial installed path to somewhere new. (I am not saying it is not possible, but you will need to have deep knowledge of the tool chain in order to relocate them)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat May 18, 2024 2:48 pm    Post subject: Reply with quote

Dawn_Xu,

That's how you use the cross toolchain that you make with crossdev.
The detail is on the Gentoo crossdev wiki page.
_________________
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
pingtoo
l33t
l33t


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

PostPosted: Sat May 18, 2024 2:51 pm    Post subject: Reply with quote

Dawn_Xu wrote:
In fact, I need cross-emerge to create binary executable for my SBC,

Yes that is indeed what crossdev do for you.

So I am not sure if you you have question in your statement?
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Sat May 18, 2024 3:04 pm    Post subject: Reply with quote

pingtoo wrote:

Yes that is indeed what crossdev do for you.

So I am not sure if you you have question in your statement?


Yes, I doesn't want to compile executables on my Single-Board computer, but I need to compile on my PC and copy the executable file to my Single-Board Computer's /usr/lib, /usr/bin and so on.

However, copy the cross-emerged executable to SBC's /usr would polluted SBC's libraries and environment , so I need a prefix to isolated the SBC's rootFS with the cross-emerged binaries
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat May 18, 2024 3:19 pm    Post subject: Reply with quote

Dawn_Xu,

That's not how it works.

Crossdev will create a toolchain on you build host, that runs on the build host but generates code for your SBC.
That code is never run on the build host.

During cross compiling the setup creates binary packages that can be installed on your SBC.

I have run
Code:
crossdev -t aarch64-unknown-linux-gnu

which creates a cross toolchain that emits code for 64 bit Raspberry Pi
The aarch64 code is all installed into the build systems /usr/aarch64-unknown-linux-gnu

/usr/aarch64-unknown-linux-gnu is a root filesystem for a Raspberry Pi.
It has its own /usr/aarch64-unknown-linux-gnu/etc/portage/*
and /usr/aarch64-unknown-linux-gnu//var/cache/binpkgs/ which are binary packages for the Pi.

You can do the same for any supported target.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.


Last edited by NeddySeagoon on Sat May 18, 2024 3:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Sat May 18, 2024 3:20 pm    Post subject: Reply with quote

Dawn_Xu wrote:
pingtoo wrote:

Yes that is indeed what crossdev do for you.

So I am not sure if you you have question in your statement?


Yes, I doesn't want to compile executables on my Single-Board computer, but I need to compile on my PC and copy the executable file to my Single-Board Computer's /usr/lib, /usr/bin and so on.

However, copy the cross-emerged executable to SBC's /usr would polluted SBC's libraries and environment , so I need a prefix to isolated the SBC's rootFS with the cross-emerged binaries


emerge (or cross-emerge) have option --root (or environment variable ROOT=) to set a target location for generated binary. please see man page for detail.

I am not sure why you keep emphasize SBC (Single-Board Computer) Are you concern I don't know what is SBC?
Back to top
View user's profile Send private message
Dawn_Xu
n00b
n00b


Joined: 04 Oct 2023
Posts: 12

PostPosted: Sat May 18, 2024 3:33 pm    Post subject: Reply with quote

pingtoo wrote:
Dawn_Xu wrote:
pingtoo wrote:

Yes that is indeed what crossdev do for you.

So I am not sure if you you have question in your statement?


Yes, I doesn't want to compile executables on my Single-Board computer, but I need to compile on my PC and copy the executable file to my Single-Board Computer's /usr/lib, /usr/bin and so on.

However, copy the cross-emerged executable to SBC's /usr would polluted SBC's libraries and environment , so I need a prefix to isolated the SBC's rootFS with the cross-emerged binaries


emerge (or cross-emerge) have option --root (or environment variable ROOT=) to set a target location for generated binary. please see man page for detail.

I am not sure why you keep emphasize SBC (Single-Board Computer) Are you concern I don't know what is SBC?


OK, I'll have a try, but I short circuit and borken my SBC by accident yesterday...
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