Date: Sat, 20 May 2017 17:57:42 -0400 From: Johannes M Dieterich <jmd@freebsd.org> To: Steve Kargl <sgk@troutmask.apl.washington.edu> Cc: freebsd-ports@freebsd.org Subject: Re: devel/flang can't link static images Message-ID: <20170520175742.34937a0c@manray.ogolem.org> In-Reply-To: <20170520164737.GA32175@troutmask.apl.washington.edu> References: <20170520164737.GA32175@troutmask.apl.washington.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Dear Steve, thanks for your comments! As you noticed, the port is in a very early stage (so is flang itself, I think). The wrapper script is really more of a hack at the moment b/c the actual flang executable is unaware of the location of it's libraries and module files. So ideally I'd like ${PREFIX}/flang/bin/flang to "understand" where it's stuff is and what it needs. On Sat, 20 May 2017 09:47:37 -0700 Steve Kargl <sgk@troutmask.apl.washington.edu> wrote: > Testing the new devel/flang port shows a number of issues with the > /usr/local/bin/flang wrapper routine. The contents of the wrapper are > > #!/bin/sh > /usr/local/flang/bin/flang -L/usr/local/flang/lib -lflang -lflangmain > \ -lflangrti -lexecinfo $@ > > where I have wrapped the long line. > > 1) Compile only uses the -c option. > > % flang -c a.f90 > clang-3.9: warning: -lflang: 'linker' input unused > clang-3.9: warning: -lflangmain: 'linker' input unused > clang-3.9: warning: -lflangrti: 'linker' input unused > clang-3.9: warning: -lexecinfo: 'linker' input unused > clang-3.9: warning: argument unused during compilation: > '-L/usr/local/flang/lib' > > These warnings are complete nonsense and caused by the inclusion of > the libraries on the command line and the -L option. This noise > can be suppressed by inclusion of the -w option. Fully agreed on the nonsense part. Now -w suppresses all warnings, which I feel is more than the user may have bargained for? > 2) The port installs a number modules and include files in > /usr/local/flang/include. Flang cannot automatically find these > files, so simple programs of the form > > use iso_fortran_env > print *, real_kinds > end > > fail. > > % flang -o z a.f90 > F90-F-0004-Unable to open MODULE file iso_fortran_env.mod (a.f90: 1) > F90/x86-64 FreeBSD Flang - 1.5 2017-05-01: compilation aborted > > This can be fixed by requiring the user to know to add > -I/usr/local/flang/include to her command line. A better > fix would be to include this option in the wrapper, so flang > can find the intrinsic modules. Happy to add that with the next update. > 3) flang cannot link static images. > > % flang -o z -static a.f90 |& grep undefined | wc -l > 105 > > There are 105 undefined references because required libraries are > missing. Here's just a few > > /usr/ports/devel/flang/work/flang-a9ccdd7/runtime/flangrti/llcrit.c:(.text._mp_copyin_move_multiple+0x17): > undefined reference to > `__kmpc_global_thread_num' /usr/ports/devel/flang/work/flang-a9ccdd7/runtime/flangrti/llcrit.c:(.text._mp_copyin_move_multiple+0x45): > undefined reference to > `__kmpc_threadprivate_cached' /usr/ports/devel/flang/work/flang-a9ccdd7/runtime/flangrti/llcrit.c:(.text._mp_copyin_move_multiple+0x59): > undefined reference to > `__kmpc_threadprivate_cached' /usr/ports/devel/flang/work/flang-a9ccdd7/runtime/flangrti/llcrit.c:(.text._mp_copyin_move_multiple+0x8d): > undefined reference to `__kmpc_barrier' > > /root/tmp/a-0fe0a5.o: In function `MAIN_': > /root/tmp/a-353577.ll:(.text+0x37): undefined reference to > `f90io_print_init' /root/tmp/a-353577.ll:(.text+0x4b): undefined > reference to > `_iso_fortran_env_8_' /root/tmp/a-353577.ll:(.text+0x52): undefined > reference to `f90io_ldw_a' /root/tmp/a-353577.ll:(.text+0x5a): > undefined reference to `f90io_ldw_end' > > The undefined references with __kmpc prefixes appear to be > contained in /usr/local/flang/lib/libompstub.a. This library > should probably be included. I am happy to add libompstub in general. I will add that I did not succeed in getting flang to execute a trivial OpenMP in parallel yet (it does however compile it w/ -fopenmp. So that's also something I want to fix. Also, I did not succeed in getting flang to link static images even after adding a few more libraries. Looking forward to more feedback from you ! I have not yet put it to task trying to compile any of my non-trivial Fortran code bases. Johannes
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170520175742.34937a0c>