From owner-freebsd-ports@freebsd.org Sat May 20 22:12:07 2017 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37C25D76A28 for ; Sat, 20 May 2017 22:12:07 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2284517A9; Sat, 20 May 2017 22:12:07 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id v4KMC6F5033671 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 20 May 2017 15:12:06 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id v4KMC6EY033670; Sat, 20 May 2017 15:12:06 -0700 (PDT) (envelope-from sgk) Date: Sat, 20 May 2017 15:12:06 -0700 From: Steve Kargl To: Johannes M Dieterich Cc: freebsd-ports@freebsd.org Subject: Re: devel/flang can't link static images Message-ID: <20170520221206.GA33611@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20170520164737.GA32175@troutmask.apl.washington.edu> <20170520175742.34937a0c@manray.ogolem.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170520175742.34937a0c@manray.ogolem.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 May 2017 22:12:07 -0000 On Sat, May 20, 2017 at 05:57:42PM -0400, Johannes M Dieterich wrote: > Dear Steve, > > thanks for your comments! As you noticed, the port is in a very early > stage (so is flang itself, I think). Yes, I know it new. Thanks for packaging it up. My attempt at building flang did not go to well. :-/ > 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. I tried modifying your script to use LD_LIBRARY_PATH and LS_RUN_PATH. It seems flang doesn't understand these environmental variable. > > % 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? I'll haven't checked, but was hoping that -w would disable all warnings and then a user could specific warnings afterward. > > 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. Thanks. This will fix problems of building software out-of-box. > > 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' > > > 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. > With static linking order of libaries matter. I see if I can work around the problem. I use static linking with OpenMPI programs. I can broadcast the statically linked executable to modes in my cluster and things just work. Otherwise, I need to make sure all nodes see the shared libraries across the network. BTW, do you prefer emails to freebsd-ports and cc to jmd@ or simply direct emails to jmd@ with devel/flang? -- Steve 20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4 20161221 https://www.youtube.com/watch?v=IbCHE-hONow