From patchwork Mon Sep 12 21:45:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 42572 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5D11E27BBEA; Mon, 12 Sep 2022 22:47:16 +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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 165AE27BBE9 for ; Mon, 12 Sep 2022 22:47:16 +0100 (BST) Received: from localhost ([::1]:38838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXrGs-0003ut-8I for patchwork@mira.cbaines.net; Mon, 12 Sep 2022 17:47:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXrGi-0003u4-40 for guix-patches@gnu.org; Mon, 12 Sep 2022 17:47:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oXrGh-00041a-RF for guix-patches@gnu.org; Mon, 12 Sep 2022 17:47:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oXrGh-0004Ln-Kn for guix-patches@gnu.org; Mon, 12 Sep 2022 17:47:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57730] [PATCH] syscalls: Adjust for glibc 2.34 and later. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 12 Sep 2022 21:47:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57730 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Marius Bakke Cc: 57730@debbugs.gnu.org Received: via spool by 57730-submit@debbugs.gnu.org id=B57730.166301916316550 (code B ref 57730); Mon, 12 Sep 2022 21:47:03 +0000 Received: (at 57730) by debbugs.gnu.org; 12 Sep 2022 21:46:03 +0000 Received: from localhost ([127.0.0.1]:48217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXrFi-0004In-Lc for submit@debbugs.gnu.org; Mon, 12 Sep 2022 17:46:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57180) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXrFg-0004I2-QI for 57730@debbugs.gnu.org; Mon, 12 Sep 2022 17:46:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXrFa-0003rh-HX for 57730@debbugs.gnu.org; Mon, 12 Sep 2022 17:45:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=JZEAG3yXPEHu8b37aradw06Cko7c68P3XkvVFTe3mKg=; b=e70Em7y/ejj2VGn6r65r s43h9mNASIIHPaKkdVzMk10Rg/LeUW/1LJbfwvvlmytVATYvhdfyy1EMOVoA7494Iqtum4/HRGxwE SSjMY0MT41vXFb2pv/Mr+GNBMagkMiZB5wZ5mTCP5g33VpdXGofkDP5kKDqSt36lRjnK9t6AF04ne dxAvvcCUgL43/93Ekx6cZtJhTwL5hkAXXKyK0RFfhwjyq1rjfYC2LZ14wj/syELaJNuTc5tvxxwbQ oDZf/YA/akAAQiswzimP0HsLOWglUnNutCNm0qS/Sz5PpOGDvMcLL3HOd7KkWQ7hdM+rcjiPgI83k AMUczfD7Wh/vqA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:56508 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXrFV-000324-V0; Mon, 12 Sep 2022 17:45:50 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= References: <20220911105051.16901-1-marius@gnu.org> Date: Mon, 12 Sep 2022 23:45:47 +0200 In-Reply-To: <20220911105051.16901-1-marius@gnu.org> (Marius Bakke's message of "Sun, 11 Sep 2022 12:50:51 +0200") Message-ID: <87illsb71w.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi, Marius Bakke skribis: > This is a re-implementation of 3c8b6fd94ceb1e898216929e8768fb518dbf1de9 that > works with new and old libc's. > > * guix/build/syscalls.scm (openpty, login-tty): Wrap in exception handlers and > retry with libutil if the first call is unsuccessful. [...] > (define openpty > - (let ((proc (syscall->procedure int "openpty" '(* * * * *) > - #:library "libutil"))) > - (lambda () > - "Return two file descriptors: one for the pseudo-terminal control side, > + (lambda* (#:optional library) > + "Return two file descriptors: one for the pseudo-terminal control side, > and one for the controlled side." > + (let ((proc (syscall->procedure int "openpty" '(* * * * *) > + #:library library))) In general, we must ensure that ‘syscall->procedure’ is called only once per procedure, because it’s expensive compared to the function we’re wrapping (it’s doing dlopen, dlsym, and all that). Anyway, I think this should work: WDYT? Thanks, Ludo’. diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 7842b0a9fc..e081aaca44 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -445,9 +445,14 @@ (define* (syscall->procedure return-type name argument-types the returned procedure is called." (catch #t (lambda () + ;; Note: When #:library is set, try it first and fall back to libc + ;; proper. This is because libraries like libutil.so have been subsumed + ;; by libc.so with glibc >= 2.34. (let ((ptr (dynamic-func name (if library - (dynamic-link library) + (or (false-if-exception + (dynamic-link library)) + (dynamic-link)) (dynamic-link))))) ;; The #:return-errno? facility was introduced in Guile 2.0.12. (pointer->procedure return-type ptr argument-types