From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58113 invoked by alias); 12 Feb 2018 23:10:22 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 58100 invoked by uid 89); 12 Feb 2018 23:10:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FREEMAIL_REPLY,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:D*ch X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 23:10:20 +0000 Received: from manfred-laptop.site ([31.164.97.50]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lmb2Z-1eC2Lq18MN-00aHgc; Tue, 13 Feb 2018 00:10:09 +0100 Subject: Re: gfortran -static on MACs To: "Sewell, Granville" , "fortran@gcc.gnu.org" References: <70d853eea5aa46e5b2410afece89c43a@ITDSRVMBX000.utep.edu> From: Manfred Schwarb Message-ID: Date: Mon, 12 Feb 2018 23:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <70d853eea5aa46e5b2410afece89c43a@ITDSRVMBX000.utep.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-UI-Out-Filterresults: notjunk:1;V01:K0:l5j7JOrhwMw=:rvTYlD7RuWa6b6MyHao4jA HeMcibkjC5c41UK7jJViselb07h8/68YQd6NZYQCLfu+ymhwvh7U6ES970S7iSB8FkbCnbNRH +/bBfOeI1PSGyI0KLhgTUKNJGNc9G+roYaVX2C5Mzl775om1gv/HkQ+buPI/rEa3nGMOr92VO EpZQm5ChiAl0jycUTBLzS5IBdm2Ml7PoT2S9+bJbipfwUpY8Jr8HR8lUHjAYGdtVgtGliuqZ4 26HNyInNLB1rNGL6/qdlZFo+P9cbFbHOoZ+SJzuGhCIaad8cN0nXCR7GbOnakFBJl96ngfBp3 su3BmmdMNSHUrQ3xfK2ryYIos21brDaXK0SDpkTbB8NqNooQTPNxKoNuYekKEhYIGW5M3YpcW MEwZZ7FY3gpOYMX9pw+CZDAx+S7J88+dlx3tgOLxm5B29UEyWj1cjr/LZuyHjFsi44iqFAH9y I1upf5usrJB+kGXzQWkA6O7JGtjdgACpANHHUFDOiMeOuGq9uJ/h8pqfN1Mt6NGOPiJAxQT8Z VHxhC0ejnHCOXNuShb36x+se7e0SVkFjZIih47Eg1xXvUElzRzt3X6pO2BXXrfD7jyJ0orgkZ jpdmYH0FAwQtSUdfDIqqjWMN5TEjTezu7gLku9sazwkomwsg6o0/saOzJUaZP0BUZscY3KKPR w2B5pH/nDsrt625qvRErXiWDgEv+8CouzXNOKfs5gkfH3lYjH8lIqtBRLo9lEJnyQLC8jJTyp xAC4n2wkPYt+Fpbe8jANB0V7J6rkCgQ4RIf3AmBl9uRWC9NYZNW3V7+78MhNGrC9ncKR5KKK8 LpLsXXtjDyVIJWumDGjq7q4V2DL+GMYRYeLTLQfQgoz+JBhqSk= X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00076.txt.bz2 Sewell, Am 12.02.2018 um 22:43 schrieb Sewell, Granville: > Janus and Manfred, > > As you can tell, I'm a bit ignorant, don't understand very well even the difference between static and dynamic libraries, > but from the developer.apple.com link you gave me it appears that static-linked binaries are simply not supported on MAC OSX; > if that is the case, what is the point of the patches to libgfortran.spec suggested by Manfred, and other users in the > link Janus sent me, I thought that was precisely to help me create a static-linked binary. Obviously I am missing something > important. Bottom line is I simple want to create an executable from my Fortran program that people on other MAC OSX > systems can run without having gfortran installed. If that is really impossible, I'd at least like to create an executable > that will work on MAC OSX systems where a different version of gfortran is installed. But I haven't had any success even > with this, I created an executable using "gfortran -static-libgfortran -o prog.exe prog.f" but when a user tries to run > it on a system with an earlier version of gfortran installed, they get "libquadmath.dylib not found" (approximately). > No, fully static linkage (static binary) seems not to work on Mac OSX. I thought that partial static linking does work on OSX, thus my provided patch. The thing is, portability-wise core c-libraries are normally less problematic than the gfortran and quadmath libraries, so the idea was to only statically compile in these more volatile libraries. But I was wrong, the OSX linker is not clever enough for this, you can't switch between static and dynamic within a single link command (And the GNU linker seems not to work on OSX, you have to use the system linker). The only thing that seems to work is to link to static libraries by means of indicating the full path to the static libraries, i.e. ld mymainprogram.dylib /usr/local/lib/mylibrary.a -o mymainprogram.exe or, when the compiler invokes the linker: gfortran mymainprogram.f /usr/local/lib/mylibrary.a -o mymainprogram.exe So for OSX, I think you are mostly out of luck, I guess. You could try to change your libgfortran.spec to read *lib: /my/path/to/libquadmath.a -lm %(libgcc) %(liborig) as last line, but I'm a bit pessimistic. Cheers, Manfred > Thanks for you patience. > > Granville > ________________________________________ > From: jaydub66@gmail.com [jaydub66@gmail.com] on behalf of Janus Weil [janus@gcc.gnu.org] > Sent: Monday, February 12, 2018 1:12 PM > To: Manfred Schwarb > Cc: Sewell, Granville; fortran@gcc.gnu.org > Subject: Re: gfortran -static on MACs > >> Am 10.02.2018 um 14:40 schrieb Sewell, Granville: >>> >>> The Linux and Windows versions of Gfortran work with >>> >>> gfortran -static -o prog.exe prog.f >>> >>> to produce an executable that can be run on other systems where gfortran is not installed. >>> >>> But the -static option does not seem to work with gfortran on a MAC, I get >>> ld: library not found for -lcrt0.o >>> and another person with a different version of gfortran on his MAC gets the same results. > > Statically linked executables are not supported on Mac OS, see: > https://developer.apple.com/library/content/qa/qa1118/_index.html > > > >>> gfortran -static-libgfortran prog.f >>> >>> works, but the executable does not even seem to run on other systems with a different version of gfortran. >>> >> >> probably the following patch will help somewhat. You have to patch all files named >> "libgfortran.spec" in the path of your _installed_ compiler. With this change >> "-static-libgfortran" will imply static linking to libquadmath. >> >> --- libgfortran.spec.old 2017-05-29 21:46:01.036867084 +0000 >> +++ libgfortran.spec 2017-08-08 12:04:01.500558409 +0000 >> @@ -5,4 +5,4 @@ >> # >> >> %rename lib liborig >> -*lib: %{static-libgfortran:--as-needed} -lquadmath %{static-libgfortran:--no-as-needed} -lm %(libgcc) %(liborig) >> +*lib: %{static-libgfortran:-Bstatic} -lquadmath %{static-libgfortran:-Bdynamic} -lm %(libgcc) %(liborig > > > A -static-libquadmath flag has been proposed in the past, but > apparently the patch has never been committed: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539 > > Would certainly be good to have this. > > Cheers, > Janus >