From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 30D323858D1E for ; Sat, 31 Dec 2022 20:30:34 +0000 (GMT) Received: by mail-oi1-x22e.google.com with SMTP id v70so22001511oie.3 for ; Sat, 31 Dec 2022 12:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q/mW+uQFlQ0BzPWwfVN2b+F9Ul2gUuomZ03A7QY3sy8=; b=QPzhNJ9NLlU8C+dumvB17GXNNzbYqifXZdlnPt33bhLAN/7Bj55onKYSVy89qK0ljw tqEDQJBfs+gVQam4brx/wx6WL0xcJXeoW4kvdFuDdwdrIbVZKyrLe99c1BxR9iC90KJ2 eo8jtS0w/Ig0SROyPxniGK+qeONceSeuIf/XWNWPJGpGJGYhpX/XGlZ897RXN6YbhJlf QKd9X+2732LxWGPTq6CVqiqJGoQSB7kWrS2lSs97jLmoyGz6lTGAaQ7FziYb4oWQmCFj 7OufkbhrE1NpHKtjW8XQrLILTbQ23dD/UFegTUkC37bZhdqq1UNVqh1DAZoJjZyfDVt6 EM9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q/mW+uQFlQ0BzPWwfVN2b+F9Ul2gUuomZ03A7QY3sy8=; b=ZXtOw7sQITc+/CV+wV83xk80+Zxxkq68hlKMkeVikwcFu/coGx6c7j4d/R2kAW8ISX fJnWpHv6jMp822FIjrlG/8Vo2tEVK8TR7rCILv4oxSpDZPxgqdbWmOwB7QAfUWo5euGB 2DpVoM+1V783QQWoAkhrOPW1OpwGq43Q7jMEMxHoTIgebNgGgBteM6tD7iDHDyl2QzSp BVOsNblqSoweB6Z72xqxwJ7YD1Xh5p/vdhKjKecFtxBsifS1K/N34wPJYWISYiJfKMll hhUW13y1YElIl6TL02h7KcXdsxg/kvuGhxSAxbMNi8ZYrDOxZMFvbg/6+l2Z4q2K1KMA yvDA== X-Gm-Message-State: AFqh2kpcbvajYV0OmvxKm0BKGKKq7Isr2i3GDPyia7jk7uDXqTAYcDm6 jz+A03xxjQ5Ot5j0FHxwEy/E2OwhxdrR3uBCK2TxOYm2stY= X-Google-Smtp-Source: AMrXdXuS/UjuSmwsXqC9mxAq3vk1i8vDOcKlH2KtLQj3wkg8Dfe1GkyH4K41oXEzeNck1WbivpXMIivk8Au/Vk2uSiA= X-Received: by 2002:a05:6808:2a0b:b0:35b:3f80:32e8 with SMTP id ez11-20020a0568082a0b00b0035b3f8032e8mr1204411oib.177.1672518633205; Sat, 31 Dec 2022 12:30:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Vincent Fortier Date: Sat, 31 Dec 2022 15:30:22 -0500 Message-ID: Subject: Re: help cross-compiling gcc To: Kai Ruottu Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Le sam. 31 d=C3=A9c. 2022, =C3=A0 07 h 05, Kai Ruottu a =C3=A9crit : > > 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=3Dc only when adding the relative kernel headers along with: # kernel headers ADDITIONAL_CFLAGS +=3D -I$(WORK_DIR)/linux-$(ARCH)-$(TCVERSION)/arch/$(ARCH)/include ADDITIONAL_CPPFLAGS +=3D -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 iss= ue. 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/.l= ibs > -L/home/src/gcc-8.5.0/build/i686-syno_r1000-linux-gnu/libstdc++-v3/libsup= c++/.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=3D1 -DHAVE_TIRPC_RPC_XDR_H=3D0 -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=3Dhidden -Wno-variadic-macros -I../../libstdc++-v3/include > -I../../libstdc++-v3/include/i686-syno_r1000-linux-gnu > -I../../../../libsanitizer/../libstdc++-v3/libsupc++ -std=3Dgnu++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: =E2=80=9DSCSI_IOCTL_TAGGED_DISABLE=E2=80=9D on esittelem=C3=A4tt= =C3=A4 t=C3=A4ll=C3=A4 n=C3=A4kyvyysalueella > unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE =3D SCSI_IOCTL_TAGGED_DISABL= E; > ^~~~~~~~~~~~~~~~~~~~~~~~~ > ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix= .cc:902:46: > huom: suggested alternative: =E2=80=9DIOCTL_SCSI_IOCTL_TAGGED_DISABLE=E2= =80=9D > unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE =3D SCSI_IOCTL_TAGGED_DISABL= E; > ^~~~~~~~~~~~~~~~~~~~~~~~~ > IOCTL_SCSI_IOCTL_TAGGED_DISABLE > ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix= .cc:903:45: > virhe: =E2=80=9DSCSI_IOCTL_TAGGED_ENABLE=E2=80=9D on esittelem=C3=A4tt=C3= =A4 t=C3=A4ll=C3=A4 n=C3=A4kyvyysalueella > unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE =3D SCSI_IOCTL_TAGGED_ENABLE; > ^~~~~~~~~~~~~~~~~~~~~~~~ > ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix= .cc:903:45: > huom: suggested alternative: =E2=80=9DIOCTL_SCSI_IOCTL_TAGGED_ENABLE=E2= =80=9D > unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE =3D 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/i68= 6-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/libci= lkrts/runtime/local_state.h:62, from /home/spksrc/gdb/spksrc/cross/gcc-4.9.4/work-apollolake-6.1/gcc-4.9.4/libci= lkrts/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: =E2=80=98struct timespec=E2=80=99 declared inside parameter list w= ill 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/libci= lkrts/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/libci= lkrts/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)