public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* static linking of gfortran libraries
@ 2016-01-18  8:23 Kay Diederichs
  2016-01-18  8:51 ` Janne Blomqvist
  2016-01-19  8:35 ` Kay Diederichs
  0 siblings, 2 replies; 3+ messages in thread
From: Kay Diederichs @ 2016-01-18  8:23 UTC (permalink / raw)
  To: fortran

Dear all,

on CentOS 6 one could use -static-libgcc -static-libgfortran to obtain a
binary which would run on other computers which don't have gfortran
installed.

On CentOS 7 one can install the libgfortran-static and
libquadmath-static RPMs but the resulting binary _still_ requires
/lib64/libquadmath.so as revealed by ldd. gfortran does not recognize an
option like -static-libquadmath . libquadmath is required even for tiny
programs which do not use high precision data types.

Heavy use of Google did not bring any result. I tried with linker
options -Wl,-Bstatic and so on, but without changes.
So, can anyone tell me how to compile/link with gfortran a binary which
does not have a requirement for libquadmath?
If this is not possible, why are there libgfortran-static and
libquadmath-static RPMs ?

thank you,

Kay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: static linking of gfortran libraries
  2016-01-18  8:23 static linking of gfortran libraries Kay Diederichs
@ 2016-01-18  8:51 ` Janne Blomqvist
  2016-01-19  8:35 ` Kay Diederichs
  1 sibling, 0 replies; 3+ messages in thread
From: Janne Blomqvist @ 2016-01-18  8:51 UTC (permalink / raw)
  To: Kay Diederichs; +Cc: Fortran List

On Mon, Jan 18, 2016 at 10:23 AM, Kay Diederichs
<kay.diederichs@uni-konstanz.de> wrote:
> Dear all,
>
> on CentOS 6 one could use -static-libgcc -static-libgfortran to obtain a
> binary which would run on other computers which don't have gfortran
> installed.
>
> On CentOS 7 one can install the libgfortran-static and
> libquadmath-static RPMs but the resulting binary _still_ requires
> /lib64/libquadmath.so as revealed by ldd. gfortran does not recognize an
> option like -static-libquadmath . libquadmath is required even for tiny
> programs which do not use high precision data types.
>
> Heavy use of Google did not bring any result. I tried with linker
> options -Wl,-Bstatic and so on, but without changes.
> So, can anyone tell me how to compile/link with gfortran a binary which
> does not have a requirement for libquadmath?

You might want to backport the patch for PR 50201,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50201, or file a bug
report to RedHat and hope that they will do it.

> If this is not possible, why are there libgfortran-static and
> libquadmath-static RPMs ?

That's something you have to ask RedHat. I guess they haven't tested
it and the bug has gone unnoticed.

-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: static linking of gfortran libraries
  2016-01-18  8:23 static linking of gfortran libraries Kay Diederichs
  2016-01-18  8:51 ` Janne Blomqvist
@ 2016-01-19  8:35 ` Kay Diederichs
  1 sibling, 0 replies; 3+ messages in thread
From: Kay Diederichs @ 2016-01-19  8:35 UTC (permalink / raw)
  To: fortran

On 2016-01-18 09:23, Kay Diederichs wrote:
> Dear all,
> 
> on CentOS 6 one could use -static-libgcc -static-libgfortran to obtain a
> binary which would run on other computers which don't have gfortran
> installed.
> 
> On CentOS 7 one can install the libgfortran-static and
> libquadmath-static RPMs but the resulting binary _still_ requires
> /lib64/libquadmath.so as revealed by ldd. gfortran does not recognize an
> option like -static-libquadmath . libquadmath is required even for tiny
> programs which do not use high precision data types.
> 
> Heavy use of Google did not bring any result. I tried with linker
> options -Wl,-Bstatic and so on, but without changes.
> So, can anyone tell me how to compile/link with gfortran a binary which
> does not have a requirement for libquadmath?
> If this is not possible, why are there libgfortran-static and
> libquadmath-static RPMs ?
> 
> thank you,
> 
> Kay
> 
> 

I found the following workaround: edit the file
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgfortran.spec and replace

*lib: %{static-libgfortran:--as-needed} -lquadmath
%{static-libgfortran:--no-as-
needed} -lm %(libgcc) %(liborig)

with

*lib: %{static-libgfortran:--as-needed} %{static-libgfortran:--no-as-
needed} -lm %(libgcc) %(liborig)

After doing this, I can now
gfortran -static-libgfortran -static-libgcc myfile.f90
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libquadmath.a

and it will happily compile a binary without the libquadmath shared
libraries.

Hope this helps somebody else,

Kay

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-19  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18  8:23 static linking of gfortran libraries Kay Diederichs
2016-01-18  8:51 ` Janne Blomqvist
2016-01-19  8:35 ` Kay Diederichs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).