From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: qemu-user-static build of other architectures Date: Sun, 27 Nov 2022 12:49:39 +0000 Message-ID: <8A9069CC-E1A0-47BE-AEAB-4017D93FA6E4@ipfire.org> In-Reply-To: <7821758c-d77f-fd67-9858-ed009b1de146@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5259995721145335197==" List-Id: --===============5259995721145335197== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello Adolf, > On 27 Nov 2022, at 12:26, Adolf Belka wrote: >=20 > Hi Michael, >=20 > On 27/11/2022 13:09, Michael Tremer wrote: >> Hello Adolf, >>> On 26 Nov 2022, at 22:24, Adolf Belka wrote: >>>=20 >>> Hi All, >>>=20 >>> I tried to run a aarch64 build of samba so that I could get the correct r= ootfile but I had a few problems. >>>=20 >>> I installed qemu-user-static on Arch Linux but when I tried to run the ge= ttoolchain command I got an error message about not finding the binfmt_misc h= elper. >>>=20 >>> Figured out that I needed to also install qemu-user-static-binfmt as well= . Then the error message changed to the fact that it could not find /usr/bin/= qemu-aarch64-static but it was in that directory. >>>=20 >>> Eventually used the find static command from ./make.sh and found that on = Arch Linux it does not have "statically linked" but "static-pie linked". Chan= ging the ./make.sh find static command to look for "static-pie linked" then a= llowed the build for aarch64 to proceed. >> It is required that QEMU is statically linked. >> The reason for that is that we copy the binary into the build environment = where it has no access to any libraries of the host - and to make those avail= able, they need to be compiled into the binary. >> PIE does not have anything to do with a statically linked binary (well kin= d of, but I wouldn=E2=80=99t know why that is relevant in this context). >> So what did you change exactly for this to work on your system? make.sh wo= uld normally automatically try to find the correct binary. > I changed line 913 in make.sh from >=20 > file -L "${file}" 2>/dev/null | grep -q "statically linked" > to > file -L "${file}" 2>/dev/null | grep -q -e "statically linked" -e "static-p= ie linked" Oh yes, this is absolutely fine. It mainly looks like the output of file has = been changed and includes whether something has been compiled as PIC or not. = Cool. Please send a patch. > I did this based on running file -L on the qemu-aarch64-static file in /usr= /bin on my Arch Linux system after installing qemu-user-static. >=20 > I got >=20 > /usr/bin/qemu-aarch64-static: ELF 64-bit LSB pie executable, x86-64, versio= n 1 (GNU/Linux), static-pie linked, BuildID[sha1]=3D92b6a9c54239756a47441b87b= ed1dfab884cfdc8, for GNU/Linux 4.4.0, stripped >=20 > as the response which has static-pie linked instead of statically linked. >=20 > Changing the grep to look for static-pie linked may have got the build runn= ing but glibc took nearly three hors to build. I know it would be slower with= the emulation and probably also slower the first time round as there would b= e nothing in the ccache but nearly three hours for one package seems excessiv= e, especially when the native build is taking around 1.5 hours for the whole = IPFire build. Yes, the emulation is indeed *that* slow. > Could the fact that my qemu-user-static program has the files static-pie li= nked be the cause of this very long run time? No, this is just how long it takes sadly. -Michael > Regards, >=20 > Adolf. >>> Of course having changed ./make.sh means that it now shows up as a modifi= ed file in the git status. I will look at changing the find static command to= look for either "statically linked" or "static-pie linked" and submit it as = a patch for consideration. >>> Regards, >>>=20 >>> Adolf. >>>=20 >> -Michael --===============5259995721145335197==--