From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 6D2263858004 for ; Sat, 3 Apr 2021 21:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D2263858004 Received: by mail-wm1-x336.google.com with SMTP id g18-20020a7bc4d20000b0290116042cfdd8so707674wmk.4 for ; Sat, 03 Apr 2021 14:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=aaNIW5yDgkZH6dYpxoRDgL6P6NNxRtSMokhooUP4ZLw=; b=sY5Qjefbtz5vuFGpEP5D0EmBYO6MZNLjc+qrXJpeo19UKvQfoucP3RGxx15Z5PhCIn bVoK+O5H7UloHHigBPfkcv0OzJU4ssgGlr0YYiaCLANTC5012l62nlGII7LXOyqvRC55 YCB1M8bx+6ZsQqpb2IEjNeLtcxgxDSoGS4+6KRdTfGpWyTrEgjIS83OLMANUJhNpcCk0 1jEoxb0QGQ7FghjRzo9VgDAYJjfHelVfQJ47Fn3xzHy92d8FtDDAQxnHlxeaHVpUmPm7 7btiWefOx5GsMq3GrvqN6hR55DlZEY+AuuOreeAIhX1SkQwrKQTdzv3jwJyYeEQAbeqa W/MQ== X-Gm-Message-State: AOAM532DdVi42QYZsRBTRZldjGL+GNZGOPy3HNhkIXCfvo+36DYGzjJP MogW/kbgMF5g/bWYo4XFVV0= X-Google-Smtp-Source: ABdhPJzx+31VE9nKMCrcFc06XkzoV8/bhgW91A620IYtTECIKcQik9XH2srjtqdSVa/ctO8ZlCk9tg== X-Received: by 2002:a7b:ce8f:: with SMTP id q15mr2976700wmj.37.1617485094451; Sat, 03 Apr 2021 14:24:54 -0700 (PDT) Received: from GXS20-B.weghof (193-154-138-37.adsl.highway.telekom.at. [193.154.138.37]) by smtp.gmail.com with ESMTPSA id y17sm4002493wmo.42.2021.04.03.14.24.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Apr 2021 14:24:53 -0700 (PDT) Date: Sat, 03 Apr 2021 23:24:52 +0200 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: gfortran, OpenMP and static linking To: Harald Anlauf , Harald Anlauf via Fortran , fortran CC: Jakub Jelinek , Bernhard Reutner-Fischer From: Bernhard Reutner-Fischer Message-ID: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sat, 03 Apr 2021 21:24:56 -0000 On 3 April 2021 20:55:39 CEST, Harald Anlauf via Fortran 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=2E Not sure if static linking with glibc is still discouraged (it was, at lea= st in former times) or if thread cancellation still is supposed to work in = a pure static build=2E As said, maybe Jakub can help=2E thanks, > >A tiny example seems to fail for me with all gfortran versions: > >program p >!$omp parallel >!$omp end parallel >end > >% gfortran -fopenmp foo=2Ef90 -g -static >% OMP_NUM_THREADS=3D1 =2E/a=2Eout > >Program received signal SIGSEGV: Segmentation fault - invalid memory >reference=2E >[=2E=2E=2E] > >Running under gdb: > >Program received signal SIGSEGV, Segmentation fault=2E >0x0000000000000000 in ?? () >(gdb) bt >#0 0x0000000000000000 in ?? () >#1 0x0000000000405198 in __gthread_mutex_destroy (__mutex=3D0x72ced8) > at =2E=2E/libgcc/gthr-default=2Eh:739 >#2 destroy_unit_mutex (u=3D0x72ce00) at >=2E=2E/=2E=2E/=2E=2E/libgfortran/io/unit=2Ec:252 >#3 close_unit_1 (u=3D0x72ce00, locked=3Dlocked@entry=3D1) at >=2E=2E/=2E=2E/=2E=2E/libgfortran/io/unit=2Ec:743 >#4 0x0000000000405202 in _gfortrani_close_units () at >=2E=2E/=2E=2E/=2E=2E/libgfortran/io/unit=2Ec:780 >#5 0x000000000044c53c in __libc_csu_fini () at elf-init=2Ec:100 >#6 0x0000000000452ef0 in __run_exit_handlers (status=3D0, listp=3D0x7206= 30 ><__exit_funcs>, >run_list_atexit=3Drun_list_atexit@entry=3Dtrue, >run_dtors=3Drun_dtors@entry=3Dtrue) at exit=2Ec:83 >#7 0x0000000000452f4a in exit (status=3D) at exit=2Ec:105 >#8 0x000000000044bdc6 in __libc_start_main (main=3D0x4030bd
, >argc=3D1, >argv=3D0x7fffffffc348, init=3D0x44c470 <__libc_csu_init>, fini=3D0x44c510 ><__libc_csu_fini>, > rtld_fini=3D0x0, stack_end=3D0x7fffffffc338) at =2E=2E/csu/libc-start= =2Ec:342 >#9 0x0000000000402fba in _start () at =2E=2E/sysdeps/x86_64/start=2ES:12= 0 > > >I suspect either a locking issue for unit_root in unit=2Ec, or maybe bad >initialization of it, but haven't stared long enough at the code=2E >According to git blame almost all related references date back to 2005=2E > >Shall I open a PR against libfortran? Or is there something I am >missing? > >Thanks, >Harald