flang-compiler / flang

Flang is a Fortran language front-end designed for integration with LLVM.
Other
799 stars 134 forks source link

error: aliases are not supported on darwin #972

Open dnoan opened 3 years ago

dnoan commented 3 years ago

Hello, I am trying to build Flang on macOS 11 ('Apple Silicon') however I get error: aliases are not supported on darwin when compiling files mth_128defs.c and mth_vreturns.c. I use https://github.com/michalpasztamobica/classic-flang-llvm-project/tree/release_110 for LLVM. Ping @michalpasztamobica

Is there any way to workaround this issue?

michalpasztamobica commented 3 years ago

Hi @dnoan , the branch is not official and still under review, have you tried the official one: https://github.com/flang-compiler/classic-flang-llvm-project/tree/release_100?

dnoan commented 3 years ago

Hi @michalpasztamobica , yes, I have tried the official branch. See https://github.com/flang-compiler/flang/issues/958 There is no official working compiler on Apple Silicon yet so I will have to resort to beta/experimental toolchains for the time being.

michalpasztamobica commented 3 years ago

@dnoan , I am sorry, but I do not have an Apple platform to reproduce the issue. I was testing the builds on x86 architectures and they worked fine. If that helps you can send me the list of tools and versions you are using (CMake, make, gcc/clang compilers or anything else you can think of for comparison)

Unfortunately, at the moment we do not have the bandwidth to support Apple Silicon, but we will be very grateful for your contribution to the project if you manage to find the solution on your own.

dnoan commented 3 years ago

@michalpasztamobica , I use cmake-3.18.2 and GNU Make 3.81. C/C++ compiler is Apple clang version 12.0.0 which must be based on LLVM 10. There is no working GCC on the ARM version of macOS (otherwise I would use GFORTRAN).

I realize that the Flang project doesn't have infrastructure support for ARM macOS. Looking at one of the problematic files (mth_vreturns.c), it has the following code:

#if !defined(TARGET_OSX_X8664) && !defined(TARGET_WIN_X8664)
#if defined(TARGET_LINUX_ARM64)
/* some code that doesn't compile */
#endif
/* some code that doesn't compile */
#endif

This will be evaluated wrongly on Apple Silicon. The main Flang project seems to lack arm64 macOS support completely.

I understand that you don't have resources to support Apple Silicon. This is sad because Flang is the closest thing to a working Fortran compiler on Apple Silicon. LLVM Flang may take years to complete and it is not even clear if GCC will ever be supported on newer macOS versions.

d-parks commented 3 years ago

@dnoan - can you send me (or point me to) your build log for the math library? make -j1 VERBOSE=1 would be best.

dnoan commented 3 years ago

@d-parks , it seems that the build system detects macOS 11 + Apple Silicon as Linux x64:

[ 47%] Building C object lib/common/CMakeFiles/common.dir/mth_vreturns.c.o cd /Users/dnoan/fortran/flang/runtime/libpgmath/build/lib/common && /Users/dnoan/fortran/flang-11/bin/clang -DHOST_LINUX -DMAXCPUS=256 -DMAXCPUSL=8 -DMAXCPUSR=8 -DPG_PIC -DTARGET_64 -DTARGET_LINUX -DTARGET_LINUX_64 -DTARGET_LINUX_GENERIC -DTARGET_LLVM -DTARGET_LLVM_64 -DTARGET_LLVM_LINUX64 -I/Users/dnoan/fortran/flang/runtime/libpgmath/lib/common -I/Users/dnoan/fortran/flang/runtime/libpgmath/lib/generic -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fPIC -O3 -ffp-contract=fast -o CMakeFiles/common.dir/mth_vreturns.c.o -c /Users/dnoan/fortran/flang/runtime/libpgmath/lib/common/mth_vreturns.c

d-parks commented 3 years ago

@dnoan - TARGET_LLVM_LINUX64 and TARGET_LINUX_64 are just the object preprocessor macros that say we're building for a 64-bit OS.