From patchwork Mon Dec 19 16:59:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 34653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2501593wrn; Mon, 19 Dec 2022 09:00:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7erdYK5cgzMJmS88yCMJNQIxFXxonmGAbIJb4H5awMNUGG+59TWqEhTsZ1crUuN20jyz7C X-Received: by 2002:a17:906:70c7:b0:7bf:1072:2246 with SMTP id g7-20020a17090670c700b007bf10722246mr21674190ejk.38.1671469226514; Mon, 19 Dec 2022 09:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671469226; cv=none; d=google.com; s=arc-20160816; b=ol03E8QgqtP0F9x+ObWg5dd1QBAECRZW2olXeLNRDGNii0m9ENJG0AoTfGa7FDxVfo h6ZVlE3aj/jnj37RzL0/YeBNICn2Qz2zJyTHCYNfW7vBhWgMdDI4ZjR9HjL3vigBp+TH 8jkhwtIKHUIH8gL5z2fZiEhzy1yDUNlW6jMLyaRFsbib/jCCrSaDi7inPY625oQEEoAL /dgZR2/swDtVehXg9EIv1EZmineFROPSWMbjjYBmeYDM4d7dCp9S9ogbHLITeGgNxh/Y pDaS1K41uMH8VbjSA8jIjWzuyHLB+PyGxbkT8tHp9KK5QazG26PfkJKxd45HBJH/nHBI PWkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5Z9fX2/pm+Yj2TbD+Rm8O3vtz78Qj1q/zipC6jOp0co=; b=bxi52uf5aaoteNMHeqYkNyK+G51lu+jXy7rPAGrBlFNt60qi73uGxsIZLRxA7SR9K8 /b6OSCbIgNkNxcAnz4CymhW0vaJdyqCB+g5tWgfdsHpFNFeuct0ITTiKpvBTHM8fiFPT YOYeIs1SKISqir7MqAomm+P51RCX+GOJBHiHmVz3Gq32MBZXONQrX4YZLfCZnO+I2Azg wt6dbjvn5CZOW32GtJqaTGGwJ4dFNGgd7K+P0OY5JP3UfTuyCXVj4DKJDB1gUlvu3Y81 vb7550R42rM0Qp6KQtIEI8I2khWD4IuUVm65AgaXM24LT5EogF02MkfHu1XZQnAmJcyN 6SqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kxFDPs6A; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ne31-20020a1709077b9f00b007ae83c51922si11070325ejc.45.2022.12.19.09.00.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 09:00:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kxFDPs6A; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 912DB3858C83 for ; Mon, 19 Dec 2022 17:00:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 912DB3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671469225; bh=5Z9fX2/pm+Yj2TbD+Rm8O3vtz78Qj1q/zipC6jOp0co=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=kxFDPs6A3FYNkyXweBlP7dUarDIvD8amWc6noFIHsW9vRI0mQA0Mzpcb/6RHNxZmk CnhAHB2GqT16JGmXYUnCeYLPPh3ghqCSsAEblmCT0+gEaIQS2S+NK16Y9clfPi9du4 v9NwEQDcmdZ+526mzbCmSxayoPqxa28RWn12Y0+s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from magnesium.8pit.net (magnesium.8pit.net [45.76.88.171]) by sourceware.org (Postfix) with ESMTPS id 5C2283858D28; Mon, 19 Dec 2022 16:59:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C2283858D28 Received: from localhost ( [2a02:8109:3b40:22d0:5fe7:d6ed:6702:b1ac]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 5ecae41c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Mon, 19 Dec 2022 17:59:39 +0100 (CET) To: iant@golang.org Cc: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [PATCH] libgo: check if -lucontext is required for {make, set, get}context Date: Mon, 19 Dec 2022 17:59:22 +0100 Message-Id: <20221219165922.25443-1-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: soeren--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: soeren@soeren-tempel.net Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752662515774052201?= X-GMAIL-MSGID: =?utf-8?q?1752662515774052201?= From: Sören Tempel This patch is similar to the existing check for librt. If libucontext is installed and libucontext.a provides the aforementioned symbols, then it is added to $LIBS. If not, no error is emitted. We could, alternatively, also check libc.a for these symbols and thus prefer libc over libucontext if both are installed and provide the symbols. If deemed desirable, this could be achieved by changing the invocation to AC_SEARCH_LIBS([makecontext], [c ucontext]). This version of this patch has been tested on x86_64 Alpine Linux Edge (libucontext 1.2 + musl 1.2.3) and Arch Linux (glibc 2.36). On the latter, the check is a no-op and $LIBS is not modified. Signed-off-by: Sören Tempel --- libgo/configure | 178 +++++++++++++++++++++++++++++++++++++++++++++ libgo/configure.ac | 5 ++ 2 files changed, 183 insertions(+) diff --git a/libgo/configure b/libgo/configure index 460fdad7..ac9202dc 100755 --- a/libgo/configure +++ b/libgo/configure @@ -14818,6 +14818,184 @@ fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing makecontext" >&5 +printf %s "checking for library containing makecontext... " >&6; } +if test ${ac_cv_search_makecontext+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char makecontext (); +int +main (void) +{ +return makecontext (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ucontext +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_makecontext=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_makecontext+y} +then : + break +fi +done +if test ${ac_cv_search_makecontext+y} +then : + +else $as_nop + ac_cv_search_makecontext=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_makecontext" >&5 +printf "%s\n" "$ac_cv_search_makecontext" >&6; } +ac_res=$ac_cv_search_makecontext +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing getcontext" >&5 +printf %s "checking for library containing getcontext... " >&6; } +if test ${ac_cv_search_getcontext+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char getcontext (); +int +main (void) +{ +return getcontext (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ucontext +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_getcontext=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_getcontext+y} +then : + break +fi +done +if test ${ac_cv_search_getcontext+y} +then : + +else $as_nop + ac_cv_search_getcontext=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getcontext" >&5 +printf "%s\n" "$ac_cv_search_getcontext" >&6; } +ac_res=$ac_cv_search_getcontext +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing setcontext" >&5 +printf %s "checking for library containing setcontext... " >&6; } +if test ${ac_cv_search_setcontext+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char setcontext (); +int +main (void) +{ +return setcontext (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ucontext +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_setcontext=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_setcontext+y} +then : + break +fi +done +if test ${ac_cv_search_setcontext+y} +then : + +else $as_nop + ac_cv_search_setcontext=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_setcontext" >&5 +printf "%s\n" "$ac_cv_search_setcontext" >&6; } +ac_res=$ac_cv_search_setcontext +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sched_yield" >&5 $as_echo_n "checking for library containing sched_yield... " >&6; } if ${ac_cv_search_sched_yield+:} false; then : diff --git a/libgo/configure.ac b/libgo/configure.ac index 09554a37..cd1ef8f7 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -570,6 +570,11 @@ PTHREAD_LIBS= AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread) AC_SUBST(PTHREAD_LIBS) +dnl Test if -lucontext is required for makecontext, getcontext, or setcontext. +AC_SEARCH_LIBS([makecontext], [ucontext]) +AC_SEARCH_LIBS([getcontext], [ucontext]) +AC_SEARCH_LIBS([setcontext], [ucontext]) + dnl Test if -lrt is required for sched_yield or nanosleep or clock_gettime. AC_SEARCH_LIBS([sched_yield], [rt]) AC_SEARCH_LIBS([nanosleep], [rt])