WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: troubleshooting compilation of gfortran  (Read 4858 times)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #15 on: December 27, 2020, 01:27:03 PM »
Did you check config.log in the appropriate sub-directory to see why cpp fails the sanity check?

On x86_64, for example, it is often because it cannot find the loader, /lib/ld-*

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #16 on: December 28, 2020, 08:47:29 PM »
Hi Rich, thanks for the link. I used these CFLAGS/CXXFLAGS, since I thought I had to use armv7l for the armv8 Raspberry Pi 4 CPU on a 32-bit system. I was actually under the impression armv6xx flags would not work on armv7x but clearly that's not the case.
Code: [Select]
export CFLAGS="gcc -march=armv7l -0s -pipe"
export CXXFLAGS="g++ -march=armv7l -0s -pipe"
but was configuring with only these tags:
Code: [Select]
--prefix=/usr/local --enable-languages=c,c++,fortran --disable-multilib --disable-bootstrap --with-system-zlib --libexecdir=/usr/local/libSo I tried again with:
Code: [Select]
export CFLAGS="-O2 -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp"
export CXXFLAGS="-O2 -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp"
--prefix=/usr/local --libdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --disable-libstdcxx-pch --enable-cloog-backend=isl --with-isl=/usr --with-system-zlib --enable-frame-pointer --disable-bootstrap --enable-lto --with-pkgversion=piCore --with-arch=armv6zk --with-tune=arm1176jzf-s -with-fpu=vfp --with-float=hard --with-gxx-include-dir=/usr/include/c++/9.2.0

And make -j4 ran for about 20 minutes, then I lost SSH connection, CPU temp started to decrease, and it did not finish compiling (I left it idle for another hour before restarting)

Juanito, I saved the config.log from the root directory-- I did not for /libcpp/, admittedly I didn't realize each subfolder had it's own log and have since overwritten that build. I can try that ./configure again, but since the ./configure Rich referenced seems not to have the error I would guess I had simply not configured it appropriately.

Not sure how to diagnose a hard crash like this without an error. I do have the config.log files, but have not found anything that looks like an error yet. The CLI output from right before the crash was:
Code: [Select]
GENERIC decision tree has 3162 leafs, maximum depth 13 and a total number of 13042 nodes
removed 2119 duplicate tails
/bin/bash /mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../move-if-change tmp-gimple-match.c gimple-match.c
/bin/bash /mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../move-if-change tmp-generic-match.c generic-match.c

echo timestamp > s-match
g++ -std=gnu++98 -fno-PIE -c   -g -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-n  arrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-  long -Wno-variadic-macros -Wno-overlength-strings -fno-common -Wno-unused -DHAVE_CONFIG_H -I. -I. -I/mnt/mmcblk0p2/bu  ild/gcc/gcc-10.2.0/gcc -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/. -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../inclu  de -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libcpp/include  -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libdecnu  mber -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I/mnt/mmcblk0p2/build/gcc/gcc-1  0.2.0/gcc/../libbacktrace -I/usr/include  -o gimple-match.o -MT gimple-match.o -MMD -MP -MF ./.deps/gimple-match.TPo   gimple-match.c
g++ -std=gnu++98 -fno-PIE -c   -g -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-n  arrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-  long -Wno-variadic-macros -Wno-overlength-strings -fno-common -Wno-unused -DHAVE_CONFIG_H -I. -I. -I/mnt/mmcblk0p2/bu  ild/gcc/gcc-10.2.0/gcc -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/. -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../inclu  de -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libcpp/include  -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libdecnu  mber -I/mnt/mmcblk0p2/build/gcc/gcc-10.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I/mnt/mmcblk0p2/build/gcc/gcc-1  0.2.0/gcc/../libbacktrace -I/usr/include  -o generic-match.o -MT generic-match.o -MMD -MP -MF ./.deps/generic-match.T  Po generic-match.c

I am currently running headless but I'll try again with a display on it and see if I can get any additional error information. Looking at the piCore 12 aarch64 repo, looks like all the packages I care about are already there... so if I can't get any extra error info I'll try building on 12.x instead.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #17 on: December 29, 2020, 01:24:32 AM »
If you are looking for error messages, it would be better to use make single threaded rather than "make -j4", which interleaves terminal output.

If you're planning to create gfortran and gfortran-lib extensions to work with the existing gcc extension, then you need to use the same compiler flags and configure switches as the existing gcc and compile to the same install location (/usr/local).

I presume you are compiling on permanent storage (you will run out of ram otherwise)?

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #18 on: December 29, 2020, 11:53:09 AM »
I was planning to just build and replace both. I actually managed to compile everything I need and test my dashboard on Rasbian Lite without any issues, but I already know I can't live with it-- piCore is bespoken for my purposes, but at least I have a working gadget until I can build everything here. Wasn't able to get any extra error info with a display-- it simply freezes right after referencing the decision tree. I'll try piCore 12 now. With all this great guidance I stand a far better shot of making it work ;D

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #19 on: December 30, 2020, 01:56:05 AM »
With piCore12 this should work:
Code: [Select]
$ tce-load -i compiletc mpc-dev zstd-dev python3.8 texinfo

$ wget ftp://ftp.lip6.fr/pub/gcc/releases/gcc-10.1.0/gcc-10.1.0.tar.xz

$ cd gcc-10.1.0

$ mkdir build
$ cd build

$ CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" ../configure --prefix=/usr/local --enable-languages=c,c++,fortran --disable-multilib --disable-bootstrap --with-system-zlib --libexecdir=/usr/local/lib --with-float=hard --with-fpu=vfp

$ find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
$ find . -name Makefile -type f -exec sed -i 's/-O2 -g//g' {} \;
$ find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \;

$ make
$ sudo make install

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #20 on: December 30, 2020, 05:55:55 AM »
gfortran posted to piCore-12.x armv7 repo

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #21 on: January 01, 2021, 09:50:55 AM »
Juanito, very kind of you to go out of your way to do that! Seems like getting a toolchain is the hardest part of this process. I actually wanted to try the aarch64 version of piCore 12, so I tried to build a piCore 12.x aarch64 version using the gcc build notes from the repo-- had to use -march=armv8-a instead of armv8.1-a+crc, and use the ./download_prerequisites gcc script for source instead of flagging local gmp, mpc, and mpfr libs of the same version to avoid errors, but it seems to have worked.

Oddly on my first reboot after the make, I got a
Code: [Select]
wpa_supplicant: error while loading shared libraries: libnl-3.so.200 during wifi autoconnect, which failed. It didn't happen again after a 2nd reboot and wifi now works fine again :o Did not call filetool.sh -b between setting up wifi, and making gfortran.

I would like to submit gfortran and some of the other packages I'll build, e.g. scipy, to the piCore-12.x aarch64 repo. There's a dead link to tcztools in the Creating Extensions page of the wiki that sounds very useful-- is it still around and working somewhere? If not I can use the extensive build notes as a guide-- I just don't want to make a mistake in the process, some of the commands are still over my linux noob head =)
« Last Edit: January 01, 2021, 09:54:45 AM by xenodius »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #22 on: January 01, 2021, 12:23:39 PM »
Are you sure that you didn’t mistype something, gcc will compile using the build notes and the gmp/isl/mpc/mpfr-dev extensions.

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #23 on: January 01, 2021, 04:35:09 PM »
I don't think i did, I tried it cut/pasted via SSH first changing only enable-languages then repeated it directly on the pi;
Code: [Select]
export CFLAGS="-O2 -march=armv8-a+crc -mtune=cortex-a53 -use-ld=gold -lpthread"
export CXXFLAGS="-O2 -march=armv8-a+crc -mtune=cortex-a53 -use-ld=gold"
../configure \
--libdir=/usr/lib \
--enable-shared \
--enable-threads=posix \
--enable-__cxa_atexit \
--enable-c99 \
--enable-long-long \
--enable-clocale=gnu \
--enable-languages=fortran \
--disable-multilib \
--disable-libstdcxx-pch \
--enable-cloog-backend=isl \
--with-isl=/usr/local \
--with-mpfr=/usr/local \
--with-gmp=/usr/local \
--with-mpc=/usr/local \
--with-system-zlib \
--enable-frame-pointer \
--disable-bootstrap \
--enable-lto \
--with-pkgversion=piCore64 \
--with-arch=armv8-a+crc \
--enable-fix-cortex-a53-843419 \
--with-gxx-include-dir=/usr/include/c++/10.1.0

Consistently got this error on make:
Code: [Select]
sh: AARCH64_FL_CRC: unknown operand
Unknown extension used in --with-arch=armv8-a+crc

And got the same error with these flags and tuning to my pi4b cpu:
Code: [Select]
export CC="gcc -march=armv8-a+crc -mtune=cortex-a72 -Os -pipe"
export CXX="g++ -march=armv8-a+crc -mtune=cortex-a72 -Os -pipe -fno-exceptions -fno-rtti"
OR
export CFLAGS="-O2 -march=armv8-a+crc -mtune=cortex-a72 -use-ld=gold -lpthread"
export CXXFLAGS="-O2 -march=armv8-a+crc -mtune=cortex-a72 -use-ld=gold

The 'mismatch' error I got from mpfr only happened when specifying mpfr|gmp|mpc=/usr/local in configure after running download_prerequisites, I loaded it in one of several tests with the CRC error. Re-extracted and rebuilt with mpfr|gmp|mpc=/usr/local instead of same source using --with-arch=armv8-a option successfully.

The gcc documentation states:
Code: [Select]
The value ‘armv8.1-a’ implies ‘armv8-a’ and enables compiler support for the ARMv8.1-A architecture extension. In particular, it enables the ‘+crc’, ‘+lse’, and ‘+rdma’ features.
So for one test I tried replacing armv8-a+crc with armv8.1-a+crc in CFLAGS/CXXFLAGS/configure. This returned a similar error:
Code: [Select]
sh: AARCH64_FL_CRC: unknown operand
Unknown extension used in --with-arch=armv8.1-a+crc

Obviously it has worked so there's probably some difference in our setup, but as best I can google the Cortex-A72 on my pi4B doesn't support armv8.1 and gcc doesn't seem to support +crc with anything less than armv8.1 so I think it's okay. I'll try to compile scipy with it and run some tests on the package to double check before I send it in.
« Last Edit: January 01, 2021, 04:55:27 PM by xenodius »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #24 on: January 02, 2021, 04:02:09 AM »
If your build does not use the gmp, isl, mpc and mpfr extensions from the repo and the same compiler flags then there is the risk of problems with applications compiled with it.

I'm note sure where you got the build notes from, but using the last build of gcc from here: http://tinycorelinux.net/12.x/aarch64/releases/RPi/src/toolchain/compile_tc12_aarch64 gives the following configure switches:
Code: [Select]
LD=ld CFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -Os -pipe" CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -Os -pipe" ../configure --prefix=/usr/local --enable-languages=c,c++,fortran --disable-multilib --disable-bootstrap --with-system-zlib --enable-fix-cortex-a53-843419 --libexecdir=/usr/local/lib --with-mpfr=/usr/local --with-gmp=/usr/local --with-mpc=/usr/local
..and it compiles natively without errors.
« Last Edit: January 02, 2021, 06:12:27 AM by Juanito »

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #25 on: January 02, 2021, 09:10:26 AM »
As always you're right, I got them from here.  The build I tested only lacked the +crc flag (Realized I could use local gmp, mpc, and mpfr extensions once I removing the source from download-prerequisites, leftover from testing other flags) but doesn't seem to work properly.

I will try using that toolchain log, and I am also putting the gfortran package you so kindly compiled on the armv7l repo to work so I can share plug-and-play ready images with broader compatibility <3




Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14488
Re: troubleshooting compilation of gfortran
« Reply #26 on: January 03, 2021, 02:07:00 AM »
gfortran posted to aarch64 repo

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: troubleshooting compilation of gfortran
« Reply #27 on: January 03, 2021, 07:15:36 AM »
Please let me know where to send your cake.  ;D ;D ;D Thank you so much!
« Last Edit: January 03, 2021, 07:21:20 AM by xenodius »