From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Harald Anlauf <anlauf@gmx.de>,
Harald Anlauf via Fortran <fortran@gcc.gnu.org>
Subject: Re: gfortran, OpenMP and static linking
Date: Sun, 4 Apr 2021 12:46:05 +0200 [thread overview]
Message-ID: <20210404124605.02773f74@nbbrfq> (raw)
In-Reply-To: <B5AA2806-6447-442F-A26A-F1D7EC91945E@gmail.com>
Harald,
On Sat, 03 Apr 2021 23:24:52 +0200
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> On 3 April 2021 20:55:39 CEST, Harald Anlauf via Fortran <fortran@gcc.gnu.org> wrote:
> >Dear all,
> >
> >is there a reason that one should not be able to statically link a
> >Fortran binary that has been compiled with -fopenmp?
>
> Maybe Jakub knows more on this.
>
> Not sure if static linking with glibc is still discouraged (it was, at least in former times) or if thread cancellation still is supposed to work in a pure static build.
You can try to get away with linking libpthread in like below.
However, glibc is (still) not supposed to be linked statically (don't
ask me, i didn't write it).
HTH,
$ cat omp.f90
use omp_lib
!$omp parallel
write(*,*) "thread ", omp_get_thread_num()
!$omp end parallel
end
$ gfortran -o omp -fopenmp omp.f90 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive && OMP_NUM_THREADS=2 ./omp
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/libgomp.a(target.o): in function `gomp_target_init':
(.text+0x358): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
thread 0
thread 1
next prev parent reply other threads:[~2021-04-04 10:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 18:55 Harald Anlauf
2021-04-03 21:24 ` Bernhard Reutner-Fischer
2021-04-04 10:46 ` Bernhard Reutner-Fischer [this message]
2021-04-04 20:17 ` Harald Anlauf
2022-09-16 22:51 Andrew Benson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210404124605.02773f74@nbbrfq \
--to=rep.dot.nop@gmail.com \
--cc=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).