How to set sysroot for cross compiling?

Kai Ruottu kai.ruottu@wippies.com
Thu Aug 10 11:15:01 GMT 2023


unlvsur unlvsur kirjoitti 6.8.2023 klo 23.35:
>
> x86_64-ubuntu-linux-gnu-g++ -v
>
> Using built-in specs.
>
> COLLECT_GCC=x86_64-ubuntu-linux-gnu-g++
>
> COLLECT_LTO_WRAPPER=/home/cqwrteur/toolchains/x86_64-pc-linux-gnu/x86_64-ubuntu-linux-gnu/libexec/gcc/x86_64-ubuntu-linux-gnu/14.0.0/lto-wrapper
>
> Target: x86_64-ubuntu-linux-gnu
>
> <snip>
>
> gcc version 14.0.0 20230802 (experimental) (GCC)
>
> Arsen Arsenović via Gcc-help kirjoitti 3.8.2023 klo 13.06:
>
> > unlvsur unlvsur <unlvsur@live.com> writes:
> >
> >> i do set with multilib list, the problem is that gcc gets very 
> messed up when
> >> trying to find where the libs located at build.
> >>
> >> like only trying to find lib64 in $targettriple/$targettriple/lib, 
> lib32 in
> >> $targettriple/$targettriple/lib/32, libx32 in
> >> $targettriple/$targettriple/lib/x32
> >>
> >> It won't find anywhere else for libc
> > Please post more information.  This could, perhaps, be binutils
> > misconfiguration.
> Sounds sane if one forgot to use the '--with-sysroot=' when configuring
> the GNU binutils for
> the target system. Here seemingly 'x86_64-linux-androideabi' when
> mentioning these three multilib directories.
>
So the target was Ubuntu...
Last when I tried this target there weren't the 'x32' libraries, only 
the 32- and 64-bit ones.
So maybe it was the time to try a newer Ubuntu target. The "22.04.2" 
seemed to be suitable
to try.
As you told, the target headers and libraries seemed to be a big mess 
when looking in which
packages they were delivered. The "Desktop" release ISO-package seemed 
to provide only a
subset and one needed to look at the "pool/main" archives. The Ubuntu 
mirror in Finland had
even this somehow "stripped" because I got this error when trying 
gcc-11.4.0 for
the 'x86_64-ubuntu-linux22.04' target :

/home/src/gcc-11.4.0/build/./gcc/xgcc 
-B/home/src/gcc-11.4.0/build/./gcc/ 
-B/opt/cross/x86_64-ubuntu-linux22.04/bin/ 
-B/opt/cross/x86_64-ubuntu-linux22.04/lib/ -isystem 
/opt/cross/x86_64-ubuntu-linux22.04/include -isystem 
/opt/cross/x86_64-ubuntu-linux22.04/sys-include    -g -O2 -mx32 -O2 -g 
-O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes 
-Wold-style-definition  -isystem ./include -fpic -mlong-double-80 
-DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 
-fbuilding-libgcc -fno-stack-protector  -fpic -mlong-double-80 
-DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. -I../../.././gcc 
-I../../../../libgcc -I../../../../libgcc/. -I../../../../libgcc/../gcc 
-I../../../../libgcc/../include -I../../../../libgcc/config/libbid 
-DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _muldi3.o -MT 
_muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c 
../../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from 
/opt/host-x86_64-ubuntu-linux22.04/usr/include/bits/errno.h:26,
                  from 
/opt/host-x86_64-ubuntu-linux22.04/usr/include/errno.h:28,
                  from ../../../../libgcc/../gcc/tsystem.h:93,
                  from ../../../../libgcc/libgcc2.c:27:
/opt/host-x86_64-ubuntu-linux22.04/usr/include/linux/errno.h:1:10: fatal 
error: asm/errno.h: No such file or directory
     1 | #include <asm/errno.h>
       |          ^~~~~~~~~~~~~
compilation terminated.

The 'kernel headers' were from the two 
'linux-libc-dev_5.15.0-78.85_*.deb' packages but something
was missing for the '-mx32' case. Earlier there were a faulty symlink to 
'/lib/ld-linux.so.2' or what the
32-bit one is. Of course this shouldn't be to the absolute '/lib' but to 
the relative '../lib'. And all the
32-bit headers were missing, the desktop-image providing only a 
'linux-libc-dev_5.15.0-60.66_amd64.deb'
package for which the 'linux-libc-dev_5.15.0-60.66_i386.deb' equivalent 
wasn't found. Therefore using
the '78.85' packages. Let's see whether the found 
'linux-headers-5.15.0-78-generic_5.15.0-78.85_amd64.deb'
has all the required headers...


More information about the Gcc-help mailing list