Compile libgfortran for ARM iOS devices

Timo Meinen timomeinen@gmail.com
Mon Feb 1 08:55:00 GMT 2016


Dear list members,

I am trying to build libgfortran for ARM processors. My goal is to run
some Fortran-77 subroutines within iOS applications. The idea is to
use the DragonEgg [1] GCC plugin and LLVM as code generator. The
procedure is taken from an answer at stackexchange [2]. The idea given
here is roughly to use LLVM an DragonEgg to build libgfortran for
armv7. But how?

I was able to create the DragonEgg plugin and use it with gfortran to
create object files for armv7s and arm64. Unfortunately I am not able
to run the code on a real iOS device because I am not able to build
the corresponding libgfortran.3.dylib.

How can I build libgfortran for other architectures?

I am able to build GCC (including gfortran) with clang instead of GCC.
And I have already build the binutils for --target=arm-apple-darwin.
But I am totally stuck when it comes to cross-compiling the
libgfortran. I don't understand which flags are needed.

What is the correct order? Do I need to build GCC for arm-apple-darwin
target as well or is it possible to build libgfortran alone? I tried
the "make info-target-libgfortran" but it builds GCC as well. And
whenever I use a differnet --host or --target setting, configure fails
in gcc directory.

Different approaches I tried:

1. ../$GCCDIR/configure --host=arm-apple-darwin ...
make info-target-libgfortran
This yields in objdir/gcc/config.log:
*** Configuration arm-apple-darwin not supported
make: *** [configure-gcc] Error 1

conftest.c:169:28: error: use of undeclared identifier 'ldgetname'
char *(*pfn) = (char *(*)) ldgetname ;
                           ^
1 error generated.
configure:10510: $? = 1
configure: failed program was:
| /* confdefs.h */

The same happens for --target=arm-apple-darwin.


2. ../$GCCDIR/configure
But use CFLAGS for CLANG to create libraries for ARM:
export SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path)
export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT
-miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"
export LDFLAGS="-arch armv7 -miphoneos-version-min=$IOS_DEPLOY_TGT
-L$SDKROOT/usr/lib/"

Error message is:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.


Thank you for any new ideas.

Best regards,
Timo Meinen

References:
[1] http://dragonegg.llvm.org/
[2] http://apple.stackexchange.com/a/157502/40380



More information about the Fortran mailing list