From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2.nber.org (mail2.nber.org [198.71.6.79]) by sourceware.org (Postfix) with ESMTP id 8FC89385783D for ; Fri, 19 Mar 2021 22:11:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8FC89385783D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nber.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=feenberg@nber.org Received: from mail2.nber.org (mail2.nber.org [198.71.6.79]) by mail2.nber.org (8.15.2/8.15.2) with ESMTPS id 12JMBA7V072131 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Mar 2021 18:11:11 -0400 (EDT) (envelope-from feenberg@nber.org) Date: Fri, 19 Mar 2021 18:11:10 -0400 (EDT) From: Daniel Feenberg To: Tobias Burnus cc: fortran@gcc.gnu.org, Daniel Feenberg Subject: Re: gfortran static linking under OS X (was: Re: ) In-Reply-To: Message-ID: <73d99495-1edf-9c54-ad8d-5db0c5e0dafd@nber.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Status: not scanned, disabled by settings X-KLMS-AntiSpam-Interceptor-Info: not scanned X-KLMS-AntiPhishing: Clean, 1970/01/01 00:00:00 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2021/03/19 15:16:00 #12102696 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Mar 2021 22:11:14 -0000 On Fri, 19 Mar 2021, Tobias Burnus wrote: > Hi, > > I am not sure whether it helps, but I want to point out that libm is the math > library which is on Linux usually GLIBC and I assume on OS X it is provided > by the OS vendor. > > Additionally, that libm is linked dynamically. > > This seems to be a OS X issue ? and I have no idea about OS X, but I found > the following: > > https://github.com/fxcoudert/gfortran-for-macOS/issues/12 > It is certainly an OS X issue. There is no problem in Linux, FreeBSD or Windows with the same compiler. As I understand it, OS X doesn't allow true dynamic linking, but it does allow a compiler/linker to produce an executable binary which only requires OS supplied libraries at execution time, and which includes all the compiler specific libraries. So I wouldn't actually expect libm to be statically linked. Apparently the problem arises because the authors of libquadm don't want users to use it in statically linked binaries, and did something to prevent that from happening. Unfortunately, it means that specialized knowledge is required to statically link gfortran programs, even if they don't use quad precision math. Daniel Feenberg > which suggests that there is a mismatch of the XCode / MacOS X SDK version. > > As work around, it seems to work to set MACOSX_DEPLOYMENT_TARGET and/or to > ensure that you have the same xcode version as the one used by gfortran, e.g. > by "xcode-select --install". > > In some other thread, the suggestion was to use -L/usr/lib but I assume that > won't help. Looking at https://github.com/xianyi/OpenBLAS/issues/3032 ? it > seems as if you can use 'gfortran -v taxsim.for' to see the SDK version used > when building GCC. > > At least that example had some |string like: > ||-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/| > > |If you had installed 11.0 instead, ||MACOSX_DEPLOYMENT_TARGET=11.0 would > work.| > > |I hope it helps. If not, you need to find someone else as I have no idea > about OS X.| > > |Good luck!| > > |Tobias > | > > On 19.03.21 21:22, Daniel Feenberg via Fortran wrote: > >> Is there a way to make a statically linked binary with fortran in OS >> X? For much of the past year I have been using: >> >> gfortran taxsim.for -static-libgfortran -static-libgcc >> >> but since January I only get the error message; >> >> ld: library not found for -lm. >> collect2: error: ld returned 1 exit status? >> >> This is OS X 11,2,3 Big Sur and fortran version 6.3.0. I need static >> linking because my users are not developers and do not have Xcode or >> gcc installed. This is free software. I have seen postings from 2015 >> suggesting that I rename libquadmath.0.dylib, which I did try but >> which did not help. >> >> Of course I have no need for lquad precision variables, which I >> understand is the source of the problem. >> >> Daniel Feenberg >> NBER >