Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cross-compiling qemu for aarch64 failed, damaged system
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Tue Jul 09, 2024 10:15 am    Post subject: Reply with quote

The script I've been using to chroot is a modified form of that on the wiki:
Code:

systemctl start systemd-binfmt

cd /usr/aarch64-unknown-linux-gnu/
mount -t proc none proc
mount -o bind /dev dev
mount -o bind /var/db/repos/gentoo var/db/repos/gentoo
mount -o bind /var/db/repos/crossdev/ var/db/repos/crossdev
mount -o bind /usr/src/linux-6.1.21_p20230405-raspberrypi/ usr/src/linux
mount -o bind /lib/modules lib/modules
mount -o bind /sys sys
cp /etc/resolv.conf etc/resolv.conf
#mount -o bind /tmp tmp
#mount -o bind /dev/pts dev/pts #only for X

chroot . /bin/bash --login

#umount dev/pts
#umount tmp
umount sys
umount lib/modules
umount usr/src/linux
umount var/db/repos/crossdev
umount var/db/repos/gentoo
umount dev
umount proc


When I run your test command I get
Code:

gentoo / # ldd /usr/bin/python
        linux-vdso.so.1 (0x0000400000801000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x0000400000840000)
        /lib/ld-linux-aarch64.so.1 => /lib64/ld-linux-aarch64.so.1 (0x00007f70b3919000)


The script is binding /dev, /proc etc. to their respective places if that's what you mean.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Tue Jul 09, 2024 1:10 pm    Post subject: Reply with quote

nameiwillforget,

Yes, this is what I was looking for, thank you very much.

small critique about the chroot script. you should use "rbind" instead "bind" for dev and sys because there are sub-mount in those file system that should be carry over to chroot environment. when unmounting at the end use umount -R option to recursive down to sub-mounts.

Since the ldd python given me expected result. I am not sure about those "command not found" error any more.

So in your chroot environment, please verify you have PATH setup correctly And once you verified please test if the system search executable is functional for example if you do "type ldconfig" does it return something meaningful?

I think it may take sometime to understand what is going on. I hope you have time for debugging this.
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Tue Jul 09, 2024 1:53 pm    Post subject: Reply with quote

So the internal PATH is set to
Code:

/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:

and is thus not configured correctly. I considered adding the missing directories in /etc/env.d, but since I can't run env-update internally I wouldn't have a way of actually updating PATH from there. Furthermore,
Code:

gentoo /usr/aarch64-unknown-linux-gnu # find /usr/aarch64-unknown-linux-gnu/usr/ -name "*env-update*" -print

gives nothing. But I get
Code:

gentoo /usr/aarch64-unknown-linux-gnu # find /usr/aarch64-unknown-linux-gnu/usr/ -name "*ldconfig*" -print
/usr/aarch64-unknown-linux-gnu/usr/sbin/ldconfig

So at least ldconfig would be in sbin. "type ldconfig" gives "command not found" but it works if I manually specify PATH beforehand
Code:

gentoo / # PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/17/bin: type ldconfig
ldconfig is /usr/sbin/ldconfig

I can do something similar for "gcc-config" with a bit more success than before:
Code:

gentoo / # PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/17/bin: gcc-config -l;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/17/bin: ldconfig -v;ROOT=/ env-update; source /etc/profile
 * Python or Portage seems to be broken, attempting to locate CHOST ourselves ...
 * gcc-config: No gcc profile is active!

/usr/bin/gcc-config: line 104: /etc/env.d/gcc/config-aarch64-unknown-linux-gnu: No such file or directory
/usr/sbin/ldconfig: Path `/lib' given more than once
(from <builtin>:0 and /etc/ld.so.conf:6)
/usr/sbin/ldconfig: Path `/lib64' given more than once
(from <builtin>:0 and /etc/ld.so.conf:4)
/usr/sbin/ldconfig: Can't stat /libilp32: No such file or directory
/usr/sbin/ldconfig: Path `/usr/lib' given more than once
(from <builtin>:0 and /etc/ld.so.conf:6)
/usr/sbin/ldconfig: Path `/usr/lib64' given more than once
(from <builtin>:0 and /etc/ld.so.conf:4)
/usr/sbin/ldconfig: Can't stat /usr/libilp32: No such file or directory
/usr/lib64: (from /etc/ld.so.conf:4)
        libsframe.so.1 -> libsframe.so.1.0.0
        libbfd-2.42.0.gentoo-sys-libs-binutils-libs-st-def.so -> libbfd.so
        libctf-2.42.0.gentoo-sys-libs-binutils-libs-st-def.so -> libctf.so
        libopcodes-2.42.0.gentoo-sys-libs-binutils-libs-st-def.so -> libopcodes.so
        libctf-nobfd-2.42.0.gentoo-sys-libs-binutils-libs-st-def.so -> libctf-nobfd.so
        libgnutls.so.30 -> libgnutls.so.30.40.0
        libgnutlsxx.so.30 -> libgnutlsxx.so.30.0.0
        libgnutls-openssl.so.27 -> libgnutls-openssl.so.27.0.2
        libsandbox.so -> libsandbox.so
        libgdbm.so.6 -> libgdbm.so.6.0.0
        libgdbm_compat.so.4 -> libgdbm_compat.so.4.0.0
        libperl.so.5.40.0 -> libperl.so.5.40.0
        libelf.so.1 -> libelf-0.191.so
        libdw.so.1 -> libdw-0.191.so
        libasm.so.1 -> libasm-0.191.so
        libfreetype.so.6 -> libfreetype.so.6.20.1
        libmagic.so.1 -> libmagic.so.1.0.0
        libpcre2-8.so.0 -> libpcre2-8.so.0.13.0
        libpcre2-16.so.0 -> libpcre2-16.so.0.13.0
        libpcre2-32.so.0 -> libpcre2-32.so.0.13.0
        libpcre2-posix.so.3 -> libpcre2-posix.so.3.0.5
        libbz2.so.1 -> libbz2.so.1.0.8
        libcrypt.so.1 -> libowcrypt.so.1
        libcrypt.so.2 -> libowcrypt.so
        libXdmcp.so.6 -> libXdmcp.so.6.0.0
        libICE.so.6 -> libICE.so.6.3.0
        libgcrypt.so.20 -> libgcrypt.so.20.5.0
        libpsl.so.5 -> libpsl.so.5.3.5
        libip4tc.so.2 -> libip4tc.so.2.0.0
        libip6tc.so.2 -> libip6tc.so.2.0.0
        libxtables.so.12 -> libxtables.so.12.7.0
        libmpc.so.3 -> libmpc.so.3.3.1
        libkmod.so.2 -> libkmod.so.2.4.2
        libsqlite3.so.0 -> libsqlite3.so.0.8.6
        libBrokenLocale.so.1 -> libBrokenLocale.so.1
        libm.so.6 -> libm.so.6
        libdl.so.2 -> libdl.so.2
        libpthread.so.0 -> libpthread.so.0
        librt.so.1 -> librt.so.1
        libmemusage.so -> libmemusage.so
        libc_malloc_debug.so.0 -> libc_malloc_debug.so.0
        libc.so.6 -> libc.so.6
        libpcprofile.so -> libpcprofile.so
        libmvec.so.1 -> libmvec.so.1
        libthread_db.so.1 -> libthread_db.so.1
        libresolv.so.2 -> libresolv.so.2
        libnss_dns.so.2 -> libnss_dns.so.2
        libanl.so.1 -> libanl.so.1
        libnss_files.so.2 -> libnss_files.so.2
        libnss_compat.so.2 -> libnss_compat.so.2
        libnss_db.so.2 -> libnss_db.so.2
        libnss_hesiod.so.2 -> libnss_hesiod.so.2
        libnsl.so.1 -> libnsl.so.1
        libutil.so.1 -> libutil.so.1
        ld-linux-aarch64.so.1 -> ld-linux-aarch64.so.1
        libhogweed.so.6 -> libhogweed.so.6.9
        libnettle.so.8 -> libnettle.so.8.9
        libmtdev.so.1 -> libmtdev.so.1.0.0
        libevdev.so.2 -> libevdev.so.2.3.0
        libxshmfence.so.1 -> libxshmfence.so.1.0.0
        libksba.so.8 -> libksba.so.8.14.7
        libpipeline.so.1 -> libpipeline.so.1.5.7
        libXau.so.6 -> libXau.so.6.0.0
        libtiff.so.6 -> libtiff.so.6.0.2
        libtiffxx.so.6 -> libtiffxx.so.6.0.2
        libmpfr.so.6 -> libmpfr.so.6.2.1
        libassuan.so.9 -> libassuan.so.9.0.0
        libfribidi.so.0 -> libfribidi.so.0.4.0
        libseccomp.so.2 -> libseccomp.so.2.5.5
        libidn2.so.0 -> libidn2.so.0.4.0
        libicuuc.so.74 -> libicuuc.so.74.2
        libicui18n.so.74 -> libicui18n.so.74.2
        libicuio.so.74 -> libicuio.so.74.2
        libicutu.so.74 -> libicutu.so.74.2
        libicutest.so.74 -> libicutest.so.74.2
        libicudata.so.74 -> libicudata.so.74.2
        libpng16.so.16 -> libpng16.so.16.43.0
        libacl.so.1 -> libacl.so.1.1.2302
        libzstd.so.1 -> libzstd.so.1.5.6
        libhistory.so.8 -> libhistory.so.8.2
        libreadline.so.8 -> libreadline.so.8.2
        libcrypto.so.3 -> libcrypto.so.3
        libssl.so.3 -> libssl.so.3
        libgraphite2.so.3 -> libgraphite2.so.3.2.1
        libpixman-1.so.0 -> libpixman-1.so.0.43.4
        libdouble-conversion.so.3 -> libdouble-conversion.so.3.3.0
        libnpth.so.0 -> libnpth.so.0.2.0
        libpopt.so.0 -> libpopt.so.0.0.2
        liblz4.so.1 -> liblz4.so.1.9.4
        libtasn1.so.6 -> libtasn1.so.6.6.3
        libunistring.so.5 -> libunistring.so.5.1.0
        liblzma.so.5 -> liblzma.so.5.6.2
        libjpeg.so.62 -> libjpeg.so.62.4.0
        libturbojpeg.so.0 -> libturbojpeg.so.0.3.0
        libgmp.so.10 -> libgmp.so.10.5.0
        libgmpxx.so.4 -> libgmpxx.so.4.7.0
        libexpat.so.1 -> libexpat.so.1.9.2
        libexpatw.so.1 -> libexpatw.so.1.9.2
        libgpg-error.so.0 -> libgpg-error.so.0.37.0
        libattr.so.1 -> libattr.so.1.1.2502
        libz.so.1 -> libz.so.1.3.1
        libpkgconf.so.5 -> libpkgconf.so.5.0.0
        liblzo2.so.2 -> liblzo2.so.2.0.0
        libcares.so.2 -> libcares.so.2.16.0
        libpaper.so.2 -> libpaper.so.2.1.3
        libmnl.so.0 -> libmnl.so.0.2.0
        libmpdec.so.4 -> libmpdec.so.4.0.0
        libduktape.so.207 -> libduktape.so.207.20700
        libduktaped.so.207 -> libduktaped.so.207.20700
        libffi.so.8 -> libffi.so.8.1.4
        libtinfo.so.6 -> libtinfo.so.6.4
        libncurses.so.6 -> libncurses.so.6.4
        libpanel.so.6 -> libpanel.so.6.4
        libmenu.so.6 -> libmenu.so.6.4
        libform.so.6 -> libform.so.6.4
        libncurses++.so.6 -> libncurses++.so.6.4
        libtinfow.so.6 -> libtinfow.so.6.4
        libncursesw.so.6 -> libncursesw.so.6.4
        libpanelw.so.6 -> libpanelw.so.6.4
        libmenuw.so.6 -> libmenuw.so.6.4
        libformw.so.6 -> libformw.so.6.4
        libncurses++w.so.6 -> libncurses++w.so.6.4
        libtinfot.so.6 -> libtinfot.so.6.4
        libncursest.so.6 -> libncursest.so.6.4
        libpanelt.so.6 -> libpanelt.so.6.4
        libmenut.so.6 -> libmenut.so.6.4
        libformt.so.6 -> libformt.so.6.4
        libncurses++t.so.6 -> libncurses++t.so.6.4
        libtinfotw.so.6 -> libtinfotw.so.6.4
        libncursestw.so.6 -> libncursestw.so.6.4
        libpaneltw.so.6 -> libpaneltw.so.6.4
        libmenutw.so.6 -> libmenutw.so.6.4
        libformtw.so.6 -> libformtw.so.6.4
        libncurses++tw.so.6 -> libncurses++tw.so.6.4
/usr/local/lib64: (from /etc/ld.so.conf:5)
/usr/lib: (from /etc/ld.so.conf:6)
/usr/local/lib: (from /etc/ld.so.conf:7)
bash: env-update: command not found
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Tue Jul 09, 2024 2:59 pm    Post subject: Reply with quote

nameiwillforget,

I feel I lost focus (or at least got idea wrong) on what to do. I think it may have to do with the whole thing was going for long time with different issues so I went to wrong direction and forgot about the original goal.

So let's get in sync on what to target :)

I go back to the first post of this thread and found that you start of by trying to setup QEMU for arm (the 32bits) and doing crossdev together, this is OK. but I think I got confused because the crossdev side create issues that reference to ARM64 (aarch64) so I went focus on the building process as opposite to getting system setup.

Can you help me get back to focus on what is current state?
  • Do you have QEMU support for ARM64(aarch64) build ready?
  • Do you just want a ARM(32bits) environment?
  • I just want to be sure, your chroot environment is /usr/aarch64-unknown-linux-gnu right?
  • What is your chroot environment current portage profile? is it point to embedded?
  • What is your final target profile for your target system?
  • Did you modified /usr/aarch64-unknown-linux-gnu/etc/ld.so.conf or ld.so.conf.d/*
  • Finally what is your goal of do this?
    • Are you trying to learn the process?
    • Are you want to have distcc helper for your target system?
    • something else?
    • all of above?
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Tue Jul 09, 2024 6:09 pm    Post subject: Reply with quote

Pingtoo,

Yes, I think so. I have an aarch64 system for my Raspberry Pi on an SD card and can chroot into that system and use portage there and everything works.

No, I don't want an ARM environment.

Yes, this is the location of the aarch64-system I'm trying to build.

I haven't set the profile within the environment yet as it wasn't in the wiki instructions. If I'm asking for a profile, I get an error:
Code:

gentoo / # eselect profile show
Current /etc/portage/make.profile symlink:
!!! Error: get_repos failed


The profile of the target system set from outside is
Code:

gentoo /home/alex # PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu/ eselect profile show
Current /usr/aarch64-unknown-linux-gnu/etc/portage/make.profile symlink:
  default/linux/arm64/23.0/desktop/systemd


I have not modified either of these files

My goal is to set up an aarch64-environment so I can cross-compile packages there that I can then copy to my Raspberry Pi4. It is also good if I can learn something in the process, but my main motivation is so I don't have to take the SD-card out of my Pi or use its hardware to install or upgrade packages on it.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Tue Jul 09, 2024 7:31 pm    Post subject: Reply with quote

nameiwillforget wrote:
My goal is to set up an aarch64-environment so I can cross-compile packages there that I can then copy to my Raspberry Pi4. It is also good if I can learn something in the process, but my main motivation is so I don't have to take the SD-card out of my Pi or use its hardware to install or upgrade packages on it.


Thank you for sharing for my questions!

In this case may I suggest we drop the crossdev issue and only focus on setup a environment on you X86 host?

There are performance disadvantage drop crossdev, but may be we can go back to crossdev later once we have a working environment.

I suggest setup a chroot environment base on existing Gentoo aarch64 stage3.

Then setup QEMU aarch64 as you have already.

Now you can try to build packages in aarch64 chroot. setup a binhost and setup your RPI4 to get binary packages from your binhist.

Does this idea sound good?

If you agree I can later share some idea on setup, we can work together to get a solution.
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Wed Jul 10, 2024 9:33 am    Post subject: Reply with quote

pingtoo,

yes, that sounds good. But you'll have to guide me through that because I don't really know what to do.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Wed Jul 10, 2024 6:18 pm    Post subject: Reply with quote

nameiwillforget wrote:
pingtoo,

yes, that sounds good. But you'll have to guide me through that because I don't really know what to do.


I need a little of time, I mess up my lab now. need to repair it, so I can test my procedure.

will get back to you as soon as I can.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Thu Jul 11, 2024 10:52 pm    Post subject: Reply with quote

nameiwillforget,

I hope this still in time for you to use. If you already got something working, then this is just for your information.

* * *
Please note this is not complete tested. especially those at bottom that did cross compiler build stuff in to chroot.
* * *

Code:
# Make sure having correct time and timezone
export TZ=EST5EDT
# Set CHROOT to where you want your Gentoo stage3 store.
export CHROOT=/chroot
# Change to your ARM64 stage3 archive.
export STAGE3=https://distfiles.gentoo.org/releases/arm64/autobuilds/20240707T225101Z/stage3-arm64-systemd-20240707T225101Z.tar.xz

# Change the chroot store. Can be a anywhere you like, just make sure there is enough space
mkdir $CHROOT
# Switch to chroot store and prepare load Gentoo stage3 archinve
pushd $CHROOT
# Download and un-archive Gentoo stage3 into CURRENT DIR (the chroot store)
wget -O - $STAGE3 | tar xJpvf - --xattrs-include='*.*' --numeric-owner
# Copy the static qemu user arm64 binary to where your binfmt setup
# see /proc/sys/fs/binfmt_misc/qemu-aarch64
install -o root -g root -m 755 -D /usr/bin/qemu-aarch64 $CHROOT/usr/bin/qemu-aarch64
popd
#
# Mount Gentoo standard pseudo filesystems
#
mount --bind /proc $CHROOT/proc
mount --rbind /sys $CHROOT/sys
mount --rbind /dev $CHROOT/dev
mount -t tmpfs tmpfs $CHROOT/run
#
# Share host Gentoo Portage setup
#
mkdir $CHROOT/var/db/repos/gentoo
mount --bind /var/db/repos/gentoo $CHROOT/var/db/repos/gentoo
mount --bind /var/cache/distfiles $CHROOT/var/cache/distfiles
# Mount your emerge binary packages into HOST somewhere for easy access
# This is optional
#mount --bind $HOME/binpkgs $CHROOT/var/cache/binpkgs

cp -p /etc/resolv.conf $CHROOT/etc/resolv.conf

PORTAGE_CONFIGROOT=$CHROOT eselect profile list
# uncomment following to set your profile inside the chroot
#PORTAGE_CONFIGROOT=$CHROOT eselect profile set XX
#
# Setup /etc/portage/make.conf
#
cat >$CHROOT/etc/portage/make.conf<<_EOF
CFLAGS="-mtune=cortex-a72 -march=armv8-a+crc -O2 -pipe"
CXXFLAGS="\${CFLAGS}"
FCFLAGS="\${CFLAGS}"
FFLAGS="\${CFLAGS}"

FEATURES="distcc parallel-fetch parallel-install -userpriv -usersandbox -network-sandbox -pid-sandbox buildpkg binpkg-multi-instance pkgdir-index-trusted"
VIDEO_CARDS="vc4 v3d"

INPUT_DEVICES="libinput"
CHOST="aarch64-unknown-linux-gnu"

EMERGE_DEFAULT_OPTS='-j4 -l4.1 --usepkg=y --keep-going'

CPU_FLAGS_ARM="edsp neon thumb vfp vfpv3 vfpv4 vfp-d32 crc32 v4 v5 v6 v7 v8 thumb2"
_EOF

#
# Testing crossdev compile. Never tried. so becareful
#
# Change crossdev setting
PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu eselect profile list
# uncomment following to set your profile inside the chroot
#PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu eselect profile set XX
#
# copy above example make.conf to crossdev's etc/portage/make.conf
#
cp -p $CHROOT/etc/portage/make.conf /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf
echo CBUILD=x86_64-pc-linux-gnu >> /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf
#
# Now try emerge to see if everything looks OK :-)
#
PORTAGE_CONFIGROOT=$CHROOT emerge-aarch64-unknown-linux-gnu --sysroot=$CHROOT --root=/$CHROOT -1pv sys-kernel/linux-headers virtual/os-headers
#
# Before Do any emerge besure your PKGDIR in your chroot is setup correct,
# The example make.conf above will build binary packages automativally, so make
# sure it is point to where you want, don't mix into your host binary packages
# directory
#
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Mon Jul 15, 2024 6:01 pm    Post subject: Reply with quote

Pingtoo,

Thanks, I'll try it out soon, maybe tomorrow!
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Fri Aug 09, 2024 6:48 pm    Post subject: Reply with quote

Pingtoo,

Sorry I only got to trying it out now, but thanks so much for putting that together, it seems to work for the most part! And I think I understand for the most part what is going on, but I have some questions:

1. So as I understand it, we've made a chroot-directory where we basically installed an aarch64-system that I can chroot into, but when I build packages in the chroot, I'm doing that using QEMU, which has a performance impact compared to cross-compiling. So in the last section, we're using the cross-compile-environment I've set up to cross-compile from outside the chroot to the system we've set up. So if I build packages from the outside, it's faster. Right?

2. When I started emerging packages in the chroot, I got the error message
Code:

Warning: distcc requested but no masquerade dir can be found in /usr/lib*/distcc/bin


So I installed distcc in the chroot and now I don't get that error message anymore when I emerge within the chroot, but when I emerge outside of the chroot, I still get that message. So I tried
Code:

aarch64-unknown-linux-gnu-emerge -av distcc

but I get a compilation error when I do that. Can I use the distcc I've emerged in the chroot somehow? I also just noticed that I get
Code:

distcc[1244036] (dcc_build_somewhere) Warning: failed to distribute, running locally instead

when I emerge packages inside the chroot.

3. You write
Quote:

# Before Do any emerge besure your PKGDIR in your chroot is setup correct,
# The example make.conf above will build binary packages automativally, so make
# sure it is point to where you want, don't mix into your host binary packages
# directory

But I'm not sure how to do that. More generally, how do I get the packages that I emerge here, whether from inside the chroot or outside, onto my Pi?

4. I took out the "-j4" flag from the make.conf so the compiler could use all cores of my processor. Is that a problem?
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Fri Aug 09, 2024 7:47 pm    Post subject: Reply with quote

nameiwillforget,

Such long time passed, I am not entirely sure my original idea 8O

But from reading my posted script, I think the idea is use crossdev most of time, only when some packages that have build problem due to require rpi native binary as part of build process than you need to switch into chroot and build the package.

My posted script propose use TWO environments, One is /usr/aarch64-unknown-linux-gnu (this is the crossdev setup), Second one is /chroot (or whatever location you choose).

In my script I have copy the qemu-aarch64 into chroot, this should allow execute rpi native binary in the chroot environment. Assume you have the binfmt setup correctly.


nameiwillforget wrote:
1. So as I understand it, we've made a chroot-directory where we basically installed an aarch64-system that I can chroot into, but when I build packages in the chroot, I'm doing that using QEMU, which has a performance impact compared to cross-compiling. So in the last section, we're using the cross-compile-environment I've set up to cross-compile from outside the chroot to the system we've set up. So if I build packages from the outside, it's faster. Right?

Yes, this is the idea.

nameiwillforget wrote:
2. When I started emerging packages in the chroot, I got the error message
Code:
Warning: distcc requested but no masquerade dir can be found in /usr/lib*/distcc/bin
You can take out the distcc in the FEATUREs variable, I did it in hurry without checking.
example:
FEATURES="distcc parallel-fetch parallel-install -userpriv -usersandbox -network-sandbox -pid-sandbox buildpkg binpkg-multi-instance pkgdir-index-trusted"
## Change to
FEATURES="parallel-fetch parallel-install -userpriv -usersandbox -network-sandbox -pid-sandbox buildpkg binpkg-multi-instance pkgdir-index-trusted"

Install distcc is just good to have, it is not a necessary.

nameiwillforget wrote:
3. You write
Quote:

# Before Do any emerge besure your PKGDIR in your chroot is setup correct,
# The example make.conf above will build binary packages automativally, so make
# sure it is point to where you want, don't mix into your host binary packages
# directory


But I'm not sure how to do that. More generally, how do I get the packages that I emerge here, whether from inside the chroot or outside, onto my Pi?


My idea is to have setup for long term, you should try not build on your rpi4 if possible.

You may want to create another storage location (on you X86 pc, a sub-directory for example) and bind mount into /chroot/var/cache/binpkgs. And on you X86 pc start a simple web server, (for example lighttpd) to serve that storage location. And on your rpi4 setup binhost (over http(s)) so on your rpi4 yoir emerge always use -KG (--usepkgonly --getbinpkgonly) to get binary packages off your PC.

nameiwillforget wrote:
4. I took out the "-j4" flag from the make.conf so the compiler could use all cores of my processor. Is that a problem?
No, it is not a problem. it just good for building time. I suspect some packages may need to use -j1 in order to successfully build.
Back to top
View user's profile Send private message
nameiwillforget
n00b
n00b


Joined: 07 May 2024
Posts: 37

PostPosted: Sat Aug 10, 2024 6:24 pm    Post subject: Reply with quote

I've compiled some more by now, and so far, it seems to work. But I have another question and an issue. The issue first, as it is somewhat concerning: I have had it two times now that my host system suddenly told me that I hadn't started the system using systemd and thus it couldn't shutdown or suspend. Each time (somewhat stupidly the second time) I tried changing to another TTY to see if the problem would persist, and was greeted by a black screen and an unresponsive computer. Of course, I have booted completely normally, and when I try using systemd-functions after booting, they work. My explanation would have been that somehow setting the system root as in your emerge command would have confused the system, but I tried using a systemd-command while setting both ROOT and SYSROOT to / and still got the same error. After the second time rebooting I also tried both to chroot into the /chroot environment and to emerge a package from the outside using the script I prepared for outside emerging:
Code:

#!/bin/bash
export CHROOT=/usr/pi5cc
PORTAGE_CONFIGROOT=$CHROOT emerge-aarch64-unknown-linux-gnu --sysroot=$CHROOT --root=/$CHROOT -1av $1

and neither time did it result in the error I had previously. So I don't know what triggers it. Do you have any idea?

The second question is this: I have to emerge chromium and because it takes an obscene amount of time and I've read that using clang reduces the time I'd like to do it using clang. So where do I have to put the config files to tell portage to cross-compile chromium using clang: into the /usr/aarch64-unknown-gnu-linux directory or the /chroot directory?
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


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

PostPosted: Sat Aug 10, 2024 7:41 pm    Post subject: Reply with quote

nameiwillforget wrote:
I've compiled some more by now, and so far, it seems to work. But I have another question and an issue. The issue first, as it is somewhat concerning: I have had it two times now that my host system suddenly told me that I hadn't started the system using systemd and thus it couldn't shutdown or suspend. Each time (somewhat stupidly the second time) I tried changing to another TTY to see if the problem would persist, and was greeted by a black screen and an unresponsive computer. Of course, I have booted completely normally, and when I try using systemd-functions after booting, they work. My explanation would have been that somehow setting the system root as in your emerge command would have confused the system, but I tried using a systemd-command while setting both ROOT and SYSROOT to / and still got the same error. After the second time rebooting I also tried both to chroot into the /chroot environment and to emerge a package from the outside using the script I prepared for outside emerging:
Code:

#!/bin/bash
export CHROOT=/usr/pi5cc
PORTAGE_CONFIGROOT=$CHROOT emerge-aarch64-unknown-linux-gnu --sysroot=$CHROOT --root=/$CHROOT -1av $1

and neither time did it result in the error I had previously. So I don't know what triggers it. Do you have any idea?
I just started using systemd, and have not yet going that deep into system building so I am not sure what could be the cause. If I would to guess, it will be related to bind mount /run into chroot (if you did that) or bind mount /sys, I think systemd use some thing in those directory for IPC, so it is possible some ebuild actualling calling systemctl duing pre/post build that confuse host systemd

nameiwillforget wrote:
The second question is this: I have to emerge chromium and because it takes an obscene amount of time and I've read that using clang reduces the time I'd like to do it using clang. So where do I have to put the config files to tell portage to cross-compile chromium using clang: into the /usr/aarch64-unknown-gnu-linux directory or the /chroot directory?
I think current chromium always use clang at least my recent build www-client/chromium-126.0.6478.126
Back to top
View user's profile Send private message
Phoenix591
Guru
Guru


Joined: 17 Sep 2007
Posts: 491

PostPosted: Mon Aug 12, 2024 10:09 am    Post subject: Reply with quote

nameiwillforget wrote:
I've compiled some more by now, and so far, it seems to work. But I have another question and an issue. The issue first, as it is somewhat concerning: I have had it two times now that my host system suddenly told me that I hadn't started the system using systemd and thus it couldn't shutdown or suspend.


make sure you arn't sharing the host's /run with the chroot. just mount a fresh empty tmpfs there.
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
Goto page Previous  1, 2
Page 2 of 2

 
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