Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails on macOS #678

Open
trifud opened this issue Feb 26, 2019 · 15 comments
Open

Compilation fails on macOS #678

trifud opened this issue Feb 26, 2019 · 15 comments

Comments

@trifud
Copy link

trifud commented Feb 26, 2019

I am trying to build flang (and more specifically libpgmath) on macOS 10.13 but I get a build error:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/llvm-6.0 -DCMAKE_CXX_COMPILER=/usr/local/gcc-8.3.0/bin/g++ -DCMAKE_C_COMPILER=/usr/local/gcc-8.3.0/bin/gcc -DCMAKE_ASM_COMPILER=/usr/local/yasm-1.3.0/bin/yasm ..

make

[  0%] Building ASM object lib/x86_64/relaxed/CMakeFiles/x86_64_relaxed.dir/relaxedmath.S.o
yasm: FATAL: unrecognized object format `omit-frame-pointer'
make[2]: *** [lib/x86_64/relaxed/CMakeFiles/x86_64_relaxed.dir/relaxedmath.S.o] Error 1
make[1]: *** [lib/x86_64/relaxed/CMakeFiles/x86_64_relaxed.dir/all] Error 2
make: *** [all] Error 2

Is the issue with the assembler or with the build environment? What assembler is recommended for building flang? How can I workaround this issue?

@d-parks
Copy link

d-parks commented Feb 26, 2019

As far as I know, we have never tried building libpgmath with yasm. Could you use either the gnu or clang assembler?

@trifud
Copy link
Author

trifud commented Feb 26, 2019

I tried the GNU assembler from binutils-2.32:
as: unrecognized option -PG_PIC

When using the LLVM assembler, I get a different error:

llvm-as: Unknown command line argument '-DOSX86'.  Try: '/usr/local/llvm-6.0/bin/llvm-as -help'
llvm-as: Did you mean '-debug'?
llvm-as: Unknown command line argument '-DPG_PIC'.  Try: '/usr/local/llvm-6.0/bin/llvm-as -help'
llvm-as: Did you mean '-debug'?
...

Then I figured out that Xcode ships with an assembler and it worked (the build errors from above were treated as warnings). But it seems that AVX-512 stuff doesn't work on macOS even with GCC 8.3.0:

[  7%] Building C object lib/common/CMakeFiles/common_mth_cmplx.dir/cdabs.c.o
/var/folders/w2/62r_94rj2m31sfbps28z0tgm0001gp/T//ccQeWacg.s:28:2: error: instruction requires: AVX-512 ISA
        vmovaps %zmm0, -176(%rbp)
        ^

Is my GCC build incomplete? Is it possible to build flang on macOS at all?

@d-parks
Copy link

d-parks commented Feb 26, 2019

I don't know the official status of FLANG on OSX - Steve S or Gary K will have to chime in here. I have been able to build libpgmath (in house) on OSX - but that has been a few months. Let me try building that again and give you and update.

@gklimowicz
Copy link
Contributor

We would like to have Flang build on macOS, but it's not been a high priority.

@jwhowarth
Copy link

It really merits a higher priority since, as of macOS Catalina and Xcode 11, macOS users won't be able to build FSF gcc (due to the absence of support for the availability attribute).

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90835

So flang could become the de facto fortran compiler on macOS 10.15 if it would only build.

@d-parks
Copy link

d-parks commented Aug 4, 2019

With your build environment, would you be able to enumerate all the libpgmath failures? Maybe make -k?

Thanks

@jwhowarth
Copy link

The build doesn't get as far as libpgmath. Using either Xcode 10.2's clang, llvm 7.0's clang or llvm 6.0's clang, I get the 20 errors of the form...

[ 36%] Building CXX object lib/CrossTU/CMakeFiles/clangCrossTU.dir/CrossTranslationUnit.cpp.o In file included from /Users/howarth/flang_dir/flang-driver/lib/CrossTU/CrossTranslationUnit.cpp:19: In file included from /Users/howarth/flang_dir/flang-driver/include/clang/Frontend/CompilerInstance.h:18: /Users/howarth/flang_dir/flang-driver/include/clang/Frontend/Utils.h:63:1: error: declaration conflicts with target of using declaration already in scope class StringRef; ^ /Users/howarth/flang_dir/flang-driver/include/clang/Basic/LLVM.h:29:9: note: target of using declaration class StringRef; ^ /Users/howarth/flang_dir/flang-driver/include/clang/Basic/LLVM.h:73:15: note: using declaration using llvm::StringRef; ^
Are any folks on linux actually building with the clang compilers and its libc++?

@isuruf
Copy link
Collaborator

isuruf commented Aug 16, 2019

FWIW, I built the flang-driver a few months ago using clang 4.0.1 on macOS and it built fine.

@jwhowarth
Copy link

jwhowarth commented Aug 16, 2019

Is that clang 4.0.1, the Apple Clang from Xcode 9? IMHO, it is rather embarrassing that Flang is claimed to be based on the llvm 7.0 release yet it is unbuildable by that very compiler. I get that it needs its own patched llvm but it at least should be coded to match the compiler syntax restrictions of the same llvm release.

@isuruf
Copy link
Collaborator

isuruf commented Aug 16, 2019

Is that clang 4.0.1, the Apple Clang from Xcode 9?

No, vanilla clang.

@jwhowarth
Copy link

As I said, it really should be coded to be compatible with the clang from the llvm it claims to be based on, otherwise it will never get merged into the main llvm repos.

@jwhowarth
Copy link

I see the same failure with llvm 5.0.2 clang compiler. I can't test llvm 4.0 on Mojave because MacPorts reports that as an unsupported for that macOS release.

@isuruf
Copy link
Collaborator

isuruf commented Aug 16, 2019

@jwhowarth, can you build clang on your system? flang-driver is basically clang with a few changes.

@jwhowarth
Copy link

FYI, I can reproduce the same exact failure under Ubuntu Disco when using the Ubuntu clang-7 and clang++-7 compilers in the build-flang-driver.sh script rather than gcc and g++. So this is generic breakage when the flang-driver is built against recent clang.

@jwhowarth
Copy link

Okay, with the patch proposed in https://github.com/flang-compiler/flang/issues/779 flang-driver builds on macOS but the resulting build of flang fails at...

Scanning dependencies of target pgmath
[100%] Linking CXX shared library libpgmath.dylib
Undefined symbols for architecture x86_64:
"___mth_i_dceil", referenced from:
_mth_intrins_defs in dispatch.c.o
_fptr2name in dispatch.c.o
(maybe you meant: ___mth_i_dceil_sse)
"___mth_i_dfloor", referenced from:
_mth_intrins_defs in dispatch.c.o
_fptr2name in dispatch.c.o
(maybe you meant: ___mth_i_dfloor_sse)
"___mth_i_floor", referenced from:
_mth_intrins_defs in dispatch.c.o
_fptr2name in dispatch.c.o
(maybe you meant: ___mth_i_floor_sse)
ld: symbol(s) not found for architecture x86_64
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants