public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Harald Anlauf <anlauf@gmx.de>,
	Harald Anlauf via Fortran <fortran@gcc.gnu.org>,
	fortran <fortran@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
	Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Subject: Re: gfortran, OpenMP and static linking
Date: Sat, 03 Apr 2021 23:24:52 +0200	[thread overview]
Message-ID: <B5AA2806-6447-442F-A26A-F1D7EC91945E@gmail.com> (raw)
In-Reply-To: <trinity-eaa64ba6-a7b8-4d45-a567-1885b8a72b54-1617476139063@3c-app-gmx-bs02>

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.

As said, maybe Jakub can help.
thanks,
>
>A tiny example seems to fail for me with all gfortran versions:
>
>program p
>!$omp parallel
>!$omp end parallel
>end
>
>% gfortran -fopenmp foo.f90 -g -static
>% OMP_NUM_THREADS=1 ./a.out
>
>Program received signal SIGSEGV: Segmentation fault - invalid memory
>reference.
>[...]
>
>Running under gdb:
>
>Program received signal SIGSEGV, Segmentation fault.
>0x0000000000000000 in ?? ()
>(gdb) bt
>#0  0x0000000000000000 in ?? ()
>#1  0x0000000000405198 in __gthread_mutex_destroy (__mutex=0x72ced8)
>    at ../libgcc/gthr-default.h:739
>#2  destroy_unit_mutex (u=0x72ce00) at
>../../../libgfortran/io/unit.c:252
>#3  close_unit_1 (u=0x72ce00, locked=locked@entry=1) at
>../../../libgfortran/io/unit.c:743
>#4  0x0000000000405202 in _gfortrani_close_units () at
>../../../libgfortran/io/unit.c:780
>#5  0x000000000044c53c in __libc_csu_fini () at elf-init.c:100
>#6  0x0000000000452ef0 in __run_exit_handlers (status=0, listp=0x720630
><__exit_funcs>,
>run_list_atexit=run_list_atexit@entry=true,
>run_dtors=run_dtors@entry=true) at exit.c:83
>#7  0x0000000000452f4a in exit (status=<optimized out>) at exit.c:105
>#8  0x000000000044bdc6 in __libc_start_main (main=0x4030bd <main>,
>argc=1,
>argv=0x7fffffffc348, init=0x44c470 <__libc_csu_init>, fini=0x44c510
><__libc_csu_fini>,
>    rtld_fini=0x0, stack_end=0x7fffffffc338) at ../csu/libc-start.c:342
>#9  0x0000000000402fba in _start () at ../sysdeps/x86_64/start.S:120
>
>
>I suspect either a locking issue for unit_root in unit.c, or maybe bad
>initialization of it, but haven't stared long enough at the code.
>According to git blame almost all related references date back to 2005.
>
>Shall I open a PR against libfortran?  Or is there something I am
>missing?
>
>Thanks,
>Harald


  reply	other threads:[~2021-04-03 21:24 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 [this message]
2021-04-04 10:46   ` Bernhard Reutner-Fischer
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=B5AA2806-6447-442F-A26A-F1D7EC91945E@gmail.com \
    --to=rep.dot.nop@gmail.com \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /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).