Re: help cross-compiling gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le sam. 31 déc. 2022, à 07 h 05, Kai Ruottu <kai.ruottu@xxxxxxxxxxx> a écrit :
>
> Vincent Fortier via Gcc-help kirjoitti 29.12.2022 klo 23.24:
> > Hi all,
> >
> > I've been trying to cross-compile various versions of gcc using the
> > Synology DSM6 and DSM7 toolchains and kernel for various archs
> > (armv5-7-8, ppc, i686, x64).
> >
> > Over the years I've been actively working on the SynoCommunity project
> > that provides a framework to help integrate free software and generate
> > linux packages that can be installed on Synology NAS (ref:
> > https://github.com/SynoCommunity/spksrc)
> >
> > Pertaining to gcc, my first attempt has been to try to build the same
> > compiler as the one used on various versions of DSM6 (gcc-4.9) and
> > DSM7 (gcc-7.5).
> OK...
> >    In order to do so I use the Synology provided
> > toolchain and prepare the associated kernel with proper platform
> > configuration in order to provide its headers.
> Not understood. Why you think that you must replace the kernel headers
> coming with the Synology-made toolchain?

I was able to build C only using --enable-languages=c only when adding
the relative kernel headers along with:
# kernel headers
ADDITIONAL_CFLAGS +=
-I$(WORK_DIR)/linux-$(ARCH)-$(TCVERSION)/arch/$(ARCH)/include
ADDITIONAL_CPPFLAGS +=
-I$(WORK_DIR)/linux-$(ARCH)-$(TCVERSION)/arch/$(ARCH)/include

As such I expected that the toolchain header files weren't
sufficient... But I just retested this and it actually did built
without it, thus meaning it isn't needed.

> > In extra I look
> > forward into applying crosstool-ng patches.
> What you do expect finding in these patches?

Until now I hadn't looked at it in detail.  I recalled an aarch64 issue:
https://lwn.net/Articles/842122/
And was also hoping a miracle fix would come out of it solving my build issue.
But I just looked at the patchset and this actual aarch64 fix isn't
even included, and no, it ain't solving miraculously my build issue.
I'll have to investigate a little to confirm if it make sense or not
of applying them.

> > As a relatively "simple" example, I've been working on cross-compiling
> > for a x86_64 host/target using DSM6 with gcc-4.9.4.  So far I was only
> > able to build the gcc C compiler (beginner's luck?).  Enabling any
> > other languages fails so has trying newer versions of gcc on that
> > particular platform.
> For pure curiosity I tried to reproduce the GCC in the
> 'r1000-gcc850_glibc226_i686-GPL.txz'
> package. But with the "as it is now" stuff in this Synology toolchain -
> with the glibc and kernel
> headers being provided. And on my old CentOS 6 / i686 host with a CentOS
> 5 / i686 targeted
> cross gcc-8.5.0. Everything went ok until hitting in this error when
> compiling libstdc++ :
>
> libtool: compile:  /home/src/gcc-8.5.0/build/./gcc/xgcc -shared-libgcc
> -B/home/src/gcc-8.5.0/build/./gcc -nostdinc++
> -L/home/src/gcc-8.5.0/build/i686-syno_r1000-linux-gnu/libstdc++-v3/src
> -L/home/src/gcc-8.5.0/build/i686-syno_r1000-linux-gnu/libstdc++-v3/src/.libs
> -L/home/src/gcc-8.5.0/build/i686-syno_r1000-linux-gnu/libstdc++-v3/libsupc++/.libs
> -B/opt/cross/i686-syno_r1000-linux-gnu/bin/
> -B/opt/cross/i686-syno_r1000-linux-gnu/lib/ -isystem
> /opt/cross/i686-syno_r1000-linux-gnu/include -isystem
> /opt/cross/i686-syno_r1000-linux-gnu/sys-include -D_GNU_SOURCE -D_DEBUG
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -DHAVE_RPC_XDR_H=1 -DHAVE_TIRPC_RPC_XDR_H=0 -I.
> -I../../../../libsanitizer/sanitizer_common -I.. -I
> ../../../../libsanitizer/include -isystem
> ../../../../libsanitizer/include/system -Wall -W -Wno-unused-parameter
> -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin
> -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables
> -fvisibility=hidden -Wno-variadic-macros -I../../libstdc++-v3/include
> -I../../libstdc++-v3/include/i686-syno_r1000-linux-gnu
> -I../../../../libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++11
> -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I
> ../../../../libsanitizer/../libbacktrace -I ../libbacktrace -I
> ../../../../libsanitizer/../include -include
> ../../../../libsanitizer/libbacktrace/backtrace-rename.h -g -O2
> -D_GNU_SOURCE -g -Os -MT sanitizer_platform_limits_posix.lo -MD -MP -MF
> .deps/sanitizer_platform_limits_posix.Tpo -c
> ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
> -fPIC -DPIC -o .libs/sanitizer_platform_limits_posix.o
> ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:902:46:
> virhe: ”SCSI_IOCTL_TAGGED_DISABLE” on esittelemättä tällä näkyvyysalueella
>     unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE = SCSI_IOCTL_TAGGED_DISABLE;
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:902:46:
> huom: suggested alternative: ”IOCTL_SCSI_IOCTL_TAGGED_DISABLE”
>     unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE = SCSI_IOCTL_TAGGED_DISABLE;
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> IOCTL_SCSI_IOCTL_TAGGED_DISABLE
> ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:903:45:
> virhe: ”SCSI_IOCTL_TAGGED_ENABLE” on esittelemättä tällä näkyvyysalueella
>     unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE = SCSI_IOCTL_TAGGED_ENABLE;
> ^~~~~~~~~~~~~~~~~~~~~~~~
> ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:903:45:
> huom: suggested alternative: ”IOCTL_SCSI_IOCTL_TAGGED_ENABLE”
>     unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE = SCSI_IOCTL_TAGGED_ENABLE;
> ^~~~~~~~~~~~~~~~~~~~~~~~
> IOCTL_SCSI_IOCTL_TAGGED_ENABLE
> make[4]: *** [sanitizer_platform_limits_posix.lo] Virhe 1
> make[4]: Poistutaan hakemistosta
> "/media/2c439158-ef3e-4dcf-a63b-03191c302829/home/src/gcc-8.5.0/build/i686-syno_r1000-linux-gnu/libsanitizer/sanitizer_common"
> make[3]: *** [all-recursive] Virhe 1
>
> Seemingly the 'include/scsi/scsi.h' was changed either in newer glibcs
> or kernel headers, I don't remember
> where these SCSI headers belong. The CentOS 5 and 6 '/usr/include'
> headers still have this :
>
> /*
>   * Here are some scsi specific ioctl commands which are sometimes useful.
>   */
> /* These are a few other constants only used by scsi devices.  */
>
> #define SCSI_IOCTL_GET_IDLUN 0x5382
>
> /* Used to turn on and off tagged queuing for scsi devices.  */
>
> #define SCSI_IOCTL_TAGGED_ENABLE 0x5383
> #define SCSI_IOCTL_TAGGED_DISABLE 0x5384
>
> /* Used to obtain the host number of a device.  */
> #define SCSI_IOCTL_PROBE_HOST 0x5385
>
> The Synology R1000 headers only mention that these values 0x5383 and
> 0x5384 "were once defined".
>
> Let's see what one should do with this problem...
>

This is the exact problem I've been hitting, at least on x86_64 archs.
I've looked at many source packages provided by synology but nowhere I
could find a thing pertaining to glibc, gcc or a patch of somesort
related to SCSI_IOCTL ...  Also, seems I'm not the first asking:
https://www.spinics.net/lists/gcchelp/msg49136.html

I've also tried using the --with-sysroot switch, again in hope of
finding a miracle cure.  Once proper variables were set in the
framework it ended generating errors where it would mix in build
include with host include and thus generating interesting errors.
There a portion of GCC that ends-up being compiled using the build C
compiler instead of host/target specified where include get mixed-up:

In file included from
/home/spksrc/gdb/spksrc/cross/gcc-4.9.4/work-apollolake-6.1/gcc-4.9.4/libcilkrts/runtime/local_state.h:62,
                 from
/home/spksrc/gdb/spksrc/cross/gcc-4.9.4/work-apollolake-6.1/gcc-4.9.4/libcilkrts/runtime/cilk-abi.c:60:
/home/spksrc/gdb/spksrc/toolchain/syno-apollolake-6.1/work/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/include/pthread.h:1004:21:
warning: ‘struct timespec’ declared inside parameter list will not be
visible outside of this definition or declaration
 1004 |        const struct timespec *__restrict __abstime)
      |                     ^~~~~~~~
make[5]: *** [Makefile:782: cilk-abi-cilk-for.lo] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from /usr/include/stdlib.h:25,
                 from /usr/include/c++/10/cstdlib:75,
                 from
/home/spksrc/gdb/spksrc/cross/gcc-4.9.4/work-apollolake-6.1/gcc-4.9.4/libcilkrts/runtime/cilk_fiber.cpp:54:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:56:17: error:
missing binary operator before token "("
   56 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X)
      |                 ^
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:73:17: error:
missing binary operator before token "("
   73 | #if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC2X)
      |                 ^
In file included from /usr/include/c++/10/cstdlib:75,
                 from
/home/spksrc/gdb/spksrc/cross/gcc-4.9.4/work-apollolake-6.1/gcc-4.9.4/libcilkrts/runtime/cilk_fiber.cpp:54:
/usr/include/stdlib.h:133:35: error: missing binary operator before token "("
  133 | #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
      |                                   ^

I'm now tempted to patch GCC to remove the definitions from:
$ grep -Rl SCSI_IOCTL *
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc

Any ideas and/or help much appreciated :)

- vin (@th0ma7)




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux