Message ID | 20220920124010.21646-1-ngraves@ngraves.fr |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 856BE27BBEA; Tue, 20 Sep 2022 15:59:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5463A27BBE9 for <patchwork@mira.cbaines.net>; Tue, 20 Sep 2022 15:59:29 +0100 (BST) Received: from localhost ([::1]:36302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) id 1oaeie-0006wL-Fm for patchwork@mira.cbaines.net; Tue, 20 Sep 2022 10:59:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oacZf-0000aS-4B for guix-patches@gnu.org; Tue, 20 Sep 2022 08:42:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oacZe-0003ni-Fb for guix-patches@gnu.org; Tue, 20 Sep 2022 08:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oacZe-0002k4-6U for guix-patches@gnu.org; Tue, 20 Sep 2022 08:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57954] [PATCH] gnu: clapack: Use position-independent code for use as a library. Resent-From: Nicolas Graves <ngraves@ngraves.fr> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 20 Sep 2022 12:42:02 +0000 Resent-Message-ID: <handler.57954.B.166367766410436@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57954 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57954@debbugs.gnu.org Cc: ngraves@ngraves.fr X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166367766410436 (code B ref -1); Tue, 20 Sep 2022 12:42:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Sep 2022 12:41:04 +0000 Received: from localhost ([127.0.0.1]:56500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1oacYg-0002iD-EG for submit@debbugs.gnu.org; Tue, 20 Sep 2022 08:41:04 -0400 Received: from lists.gnu.org ([209.51.188.17]:47592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ngraves@ngraves.fr>) id 1oacYb-0002hd-OJ for submit@debbugs.gnu.org; Tue, 20 Sep 2022 08:41:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ngraves@ngraves.fr>) id 1oacYL-0008Fu-Ru for guix-patches@gnu.org; Tue, 20 Sep 2022 08:40:55 -0400 Received: from 7.mo560.mail-out.ovh.net ([188.165.48.182]:40655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ngraves@ngraves.fr>) id 1oacYJ-0003b8-Bf for guix-patches@gnu.org; Tue, 20 Sep 2022 08:40:41 -0400 Received: from player761.ha.ovh.net (unknown [10.110.171.250]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id C19E12296C for <guix-patches@gnu.org>; Tue, 20 Sep 2022 12:40:26 +0000 (UTC) Received: from ngraves.fr (met42-h01-213-44-161-47.dsl.sta.abo.bbox.fr [213.44.161.47]) (Authenticated sender: ngraves@ngraves.fr) by player761.ha.ovh.net (Postfix) with ESMTPSA id ADA5D2ECA01BD; Tue, 20 Sep 2022 12:40:23 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-100R003c06c9d96-c8b2-4d9e-bacd-e7f340360662, 095BAD70F3E0D06F3AFA600BCF498C8F56D5D919) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 213.44.161.47 Date: Tue, 20 Sep 2022 14:40:10 +0200 Message-Id: <20220920124010.21646-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 13022721275844092642 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepkeffgeetfffgffejgeejvdffgfdtvdeuueetgfefuedvjeegvdegjeejveeuueevnecukfhppedtrddtrddtrddtpddvudefrdeggedrudeiuddrgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrhejiedurdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepghhuihigqdhprghttghhvghssehgnhhurdhorhhgpdfovfetjfhoshhtpehmohehiedt Received-SPF: pass client-ip=188.165.48.182; envelope-from=ngraves@ngraves.fr; helo=7.mo560.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> Reply-to: Nicolas Graves <ngraves@ngraves.fr> X-ACL-Warn: , Nicolas Graves via Guix-patches <guix-patches@gnu.org> From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#57954] gnu: clapack: Use position-independent code for use as a library.
|
|
Commit Message
Nicolas Graves
Sept. 20, 2022, 12:40 p.m. UTC
* gnu/packages/maths.scm (clapack): Use position-independent code for use as a library. --- gnu/packages/maths.scm | 1 + 1 file changed, 1 insertion(+)
Comments
I am trying to get a vosk package to work for guix. The build process is a bit tricky with replaced dependencies etc. The team from vosk uses a version where they replace fortran by having both openblas and clapack in libraries (which is incompatible in the base kaldi configuration, so they have their own fork). I don't know why exactly the library should be called from another place, but when compiling kaldi with clapack, I get the following message (and siblings): ld: /gnu/store/yvc2w9mg554y6i4frvahjhacj0np9c7s-clapack-3.2.1/lib/liblapack.a(ssptrf.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC I actually does work when recompiling with this flag, but I've also read that it might make the package a bit slower. In case it might help to answer, here's where I am for this package, although not done yet (I still do have to untangle some ffi segmentation fault issue) : https://git.sr.ht/~ngraves/dotfiles/tree/main/item/packages/vosk.scm What is the best option / course of action ?
On 20-09-2022 14:58, Nicolas Graves via Guix-patches via wrote: > > I am trying to get a vosk package to work for guix. > The build process is a bit tricky with replaced dependencies etc. > > The team from vosk uses a version where they replace fortran by having > both openblas and clapack in libraries (which is incompatible in the > base kaldi configuration, so they have their own fork). > > I don't know why exactly the library should be called from another > place, but when compiling kaldi with clapack, I get the following > message (and siblings): > > ld: /gnu/store/yvc2w9mg554y6i4frvahjhacj0np9c7s-clapack-3.2.1/lib/liblapack.a(ssptrf.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC > > I actually does work when recompiling with this flag, but I've also read > that it might make the package a bit slower. > > In case it might help to answer, here's where I am for this package, > although not done yet (I still do have to untangle some ffi segmentation > fault issue) : > https://git.sr.ht/~ngraves/dotfiles/tree/main/item/packages/vosk.scm > > What is the best option / course of action ? 'kaldi' is compiled as a shared library. However, going by the error message, it is linked to the (static!) clapack. IIUC, this is not a problem per se (the static library would be embedded into the shared library IIUC) -- however, shared libraries must be position-independent, whereas static libraries aren't by default. As such, there appear to be three potential solutions: * compile the static library as -fPIC (your patch) * let kaldi link to a shared clapack (which is -fPIC by default) * let 'kaldi' (and its dependent, vosk) be a static library instead of a shared library. Is likely problematic due to 'python-vosk' though. Both 'real' solutions have -fPIC (explicit or implied), so I don't think we have to worry about performance. My default option for deciding between static and shared is 'shared' (makes 'clapack' graftable, and better interaction with "guix build --repair" and "guix gc --references"). Hence, my proposed (and untested) solution is to make 'kaldi' link to a shared clapack. Greetings, Maxime.
> * compile the static library as -fPIC (your patch) > * let kaldi link to a shared clapack (which is -fPIC by default) > Hence, my proposed (and untested) solution is to make 'kaldi' link to a > shared clapack. Thanks Maxime for your quick answer. Just to be sure of what that would imply (using the second answer here: https://stackoverflow.com/questions/2649735/how-to-link-static-library-into-dynamic-library-in-gcc): 1) We keep the version of clapack patched for -fPIC. 2) I need to make a package providing a shared version of clapack based on this version of clapack compiled with -fPIC. Also, my original patch is wrong, I'll send a corrected one once I understand the process.
On 24-09-2022 10:37, Nicolas Graves wrote: > >> * compile the static library as -fPIC (your patch) >> * let kaldi link to a shared clapack (which is -fPIC by default) > >> Hence, my proposed (and untested) solution is to make 'kaldi' link to a >> shared clapack. > > Thanks Maxime for your quick answer. > > Just to be sure of what that would imply (using the second answer here: > https://stackoverflow.com/questions/2649735/how-to-link-static-library-into-dynamic-library-in-gcc): > > 1) We keep the version of clapack patched for -fPIC. > 2) I need to make a package providing a shared version of clapack based > on this version of clapack compiled with -fPIC. > > Also, my original patch is wrong, I'll send a corrected one once I > understand the process. That should do it AFAIK. However, going by https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html#variable:BUILD_SHARED_LIBS , you can ask CMake to do these steps instead. Also, going by the descriptio of 'clapack': ‘"The CLAPACK library was built using a Fortran to C conversion utility called f2c. The entire Fortran 77 LAPACK library is run through f2c to obtain C code, and then modified to improve readability. CLAPACK's goal is to provide LAPACK for someone who does not have access to a Fortran compiler.’ ... it sounds like clapack could be replaced with lapack without any problems (and even removed), and our 'lapack' package already makes shared libraries, which seems like a simpler course of action. Greetings, Maxime
> ... it sounds like clapack could be replaced with lapack without any > problems (and even removed), and our 'lapack' package already makes > shared libraries, which seems like a simpler course of action. You're absolutely right about this. I replaced clapack by lapack and discarded the flag -lf2c during the build phase. Everything works fine. I'm closing the issue. The resulting packages are available in issue 58140.
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm index 72d5e9a83a..0c4b7ada03 100644 --- a/gnu/packages/maths.scm +++ b/gnu/packages/maths.scm @@ -968,6 +968,7 @@ (define-public clapack (build-system cmake-build-system) (arguments `(#:configure-flags '("-DCMAKE_C_FLAGS=-fcommon -O2") + #:make-flags '("-fPIC") #:phases (modify-phases %standard-phases ;; These tests use a lot of stack variables and segfault without