From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 4EFD93858C60 for ; Mon, 10 Jan 2022 17:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EFD93858C60 Received: by mail-wm1-x334.google.com with SMTP id a83-20020a1c9856000000b00344731e044bso310616wme.1 for ; Mon, 10 Jan 2022 09:24:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6a8aEoPlddrO9XAM4RbLTwQT3PL/bwTZzHmtNDzXoaU=; b=C0vN5dU36wSDGE0km+ad+6/ks3MTCY+Q5y7Fzwvq1omUtJBcCdTrDk9mvgWPH6ZRGF Jr8GPBkf8iyLNh+ITtomkCFAy6DedzJRnEX8EPFmtM1ySoPPWthoLykvkaUfoyEfCYGz 9x5sWrxGE+SkRCcEiNLzhBoaWFkCiKRu8v1LApxZIJSq6K3JvsFTg8USCjGlSs6hii7N 3WBVGL3GpgWsl8X8OvU89MuNpPMx/e/j7cuxWGzfpQ3iFEzn5G11+gg84J4rZFt0uAjL ZGGm73SMup8dlDInqZzfrWdn7DPIl7RLm3Xs6jOeUY8FPC6d/vp4FHsv9oiei8pGIPg1 JDKw== X-Gm-Message-State: AOAM532vTJVNA6BrL7AGJ/KKWM47LT566xgIHcmKLpdWEn/6ZBg7pMfk scUMeVUg+upRs/zOFY0+QOUu3xlp4v9ChZuvcfg= X-Google-Smtp-Source: ABdhPJy9imhRhrQ/lS3VdqPXbk1oqoO8KUkEsXH+PxW+EE6TaHhSHroEG4a+Hrlci/Xfs0/uClq47vd7q/4EKp9DD6w= X-Received: by 2002:a05:600c:384c:: with SMTP id s12mr423117wmr.108.1641835492255; Mon, 10 Jan 2022 09:24:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Mon, 10 Jan 2022 17:24:40 +0000 Message-ID: Subject: Re: Compiling GCC 11 for Windows targeting ARM on Linux To: Thomas Sobczynski Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2022 17:24:55 -0000 On Mon, 10 Jan 2022 at 16:49, Thomas Sobczynski via Gcc-help wrote: > > I would appreciate insight on a compilation error while building GCC 11 t= o run on Windows, targeting bare metal ARM, from a GNU/Linux build environm= ent (specifically Ubuntu via WSL2). > > I have a current (within a few days) clone of the Git repo at the HEAD of= releases/gcc-11. > > > *** Source tree: > $ git status > On branch releases/gcc-11 > Your branch is up to date with 'origin/releases/gcc-11'. > > > *** Build environment: > $ gcc -v > Using built-in specs. > COLLECT_GCC=3Dgcc > COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper > OFFLOAD_TARGET_NAMES=3Dnvptx-none:hsa > OFFLOAD_TARGET_DEFAULT=3D1 > Target: x86_64-linux-gnu > Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 9.3.0-17= ubuntu1~20.04' --with-bugurl=3Dfile:///usr/share/doc/gcc-9/README.Bugs --en= able-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=3D/u= sr --with-gcc-major-version-only --program-suffix=3D-9 --program-prefix=3Dx= 86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=3D/u= sr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/= lib --enable-nls --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-l= ibstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-= object --disable-vtable-verify --enable-plugin --enable-default-pie --with-= system-zlib --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enab= le-multiarch --disable-werror --with-arch-32=3Di686 --with-abi=3Dm64 --with= -multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --ena= ble-offload-targets=3Dnvptx-none=3D/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/t= mp-nvptx/usr,hsa --without-cuda-driver --enable-checking=3Drelease --build= =3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu > Thread model: posix > gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) > > > For better or worse, I'm using GNU Make to drive the build process from t= he next level up from the GCC source tree, i.e. my Make is calling $(MAKE) = to invoke the GCC build. Extracting the recipe steps, here is how I'm attem= pting to build GCC: > > Recipe steps: > > # Obtain GCC source for the release branch of interest. > # > # "If you do not intend to make changes to the source, you can avoid inst= alling these build tools by running contrib/gcc_update." > # https://gcc.gnu.org/git.html > > git clone --branch releases/gcc-11 --depth 1 git://gcc.gnu.org/git/gcc.gi= t $(COMPILER_ROOT)/gcc > cd $(COMPILER_ROOT)/gcc && contrib/gcc_update > > # "If you also intend to build binutils (either to upgrade an existing in= stallation or for use in place of the corresponding tools of your OS), unpa= ck the binutils distribution ... in the same directory..." > # https://gcc.gnu.org/install/download.html > # https://www.gnu.org/software/binutils/ > > git clone --branch binutils-2_37 --depth 1 git://sourceware.org/git/binut= ils-gdb.git $(COMPILER_ROOT)/gcc/binutils > > # "Likewise the GMP, MPFR and MPC libraries can be automatically built to= gether with GCC. You may simply run the contrib/download_prerequisites scri= pt in the GCC source directory to set up everything." > > cd $(COMPILER_ROOT)/gcc && contrib/download_prerequisites > > # Configuration > # https://gcc.gnu.org/install/configure.html > # > # "The build machine is the system which you are using, the host machine = is the system where you want to run the resulting compiler (normally the bu= ild machine), and the target machine is the system for which you want the c= ompiler to generate code." > # We're going to use WSL + Ubuntu + GCC to build a toolchain to run on Wi= ndows targeting ARM. > > cd $(COMPILER_ROOT)/build && $(COMPILER_ROOT)/gcc/configure --host=3Dx86_= 64-w64-mingw32 --target=3Darm-none-eabi --prefix=3D${TOOLCHAIN_ROOT} --enab= le-vtable-verify --with-multilib-list=3Daprofile,rmprofile --enable-target-= optspace --enable-languages=3Dc,c++,lto --enable-large-address-aware > [snip] > /bin/bash: arm-none-eabi-gcc: command not found > make[3]: *** [Makefile:2165: specs] Error 127 > make[3]: Leaving directory '/home/tsobczynski/Compiler/build/gcc' > make[2]: *** [Makefile:4458: all-gcc] Error 2 > make[2]: Leaving directory '/home/tsobczynski/Compiler/build' > make[1]: *** [Makefile:983: all] Error 2 > make[1]: Leaving directory '/home/tsobczynski/Compiler/build' > make: *** [Makefile:53: /home/tsobczynski/Compiler/build/foo] Error 2 > > > > Granting that I am proceeding from a position of ignorance, I am not expe= cting an attempted invocation of "arm-none-eabi-gcc". My reasoning is that = the build process is taking place on GNU/Linux, while "arm-none-eabi-gcc" i= s the name I expect for one of the compiler executables that will run on Wi= ndows. Just prior to the error, the GCC build copies xgcc.exe to gcc-cross.= exe, which I presume is the compiler executable that will ultimately corres= pond to "arm-none-eabi-gcc.exe". But that .exe can only run on the --host system, i.e. on Windows. To build the target libs for the --target system (i.e. arm) you need an arm compiler that runs on the --build host (i.e. x86_64 Linux). So to build this combination you need to already have an arm cross compiler to run on your build system.