From patchwork Mon Jun 27 16:44:16 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: 55449 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FC9C38312B9 for ; Mon, 27 Jun 2022 16:48:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FC9C38312B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656348496; bh=a0HfKoY42EDM4nDgEL1Fm1TmpMqVZQ6fOcyX7w8RsZs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=EfRmedRw7dr4/dPAwYYe84kU1gIsPLwBTawvUmXSXVgsBg/A5jFUJpK/hC/N8m3Wk eD/eNFUM9w1KY8i39vKGB/YpQd5waMLBR+gMwEIwBgsAu91Fln982N8jBtu8u04Ccs CrKrW+fF8WD5uNdTs43NAEZBoqQA0mbJ96RT/4TY= 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 ACCE6383D824; Mon, 27 Jun 2022 16:47:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ACCE6383D824 Received: from localhost (p200300f5ff05aa00712b1c152df96373.dip0.t-ipconnect.de [2003:f5:ff05:aa00:712b:1c15:2df9:6373]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id ef1127bd (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Mon, 27 Jun 2022 18:47:41 +0200 (CEST) To: gofrontend-dev@googlegroups.com Subject: [PATCH] mksysinfo: add support for musl libc Date: Mon, 27 Jun 2022 18:44:16 +0200 Message-Id: <20220627164415.8510-1-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 Cc: gcc-patches@gcc.gnu.org, iant@golang.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Sören Tempel This patch addresses two minor compatibility issues with musl libc: * On some architecture (e.g. PowerPC), musl has more than one field prefixed with st_{a,m,c}tim in struct stat. This causes the sed(1) invocation to not work correctly (since it will only replace the first occurrence) [1]. This can be fixed by passing the 'g' flag to replace all occurrences. * Since version 1.2.3, musl defines SYS_SECCOMP in signal.h [2]. This conflicts with mksysinfo extraction of syscall numbers [3]. By restricting the grep expression to only match lower case characters we can avoid a redefinition of SYS_SECCOMP. This is GCC PR 105225. This patch combines two Alpine Linux patches which have been written by Ariadne Conill and Natanael Copa. I haven't tested this with glibc but I strongly suspect that both changes should not introduce any issue with glibc. [1]: https://git.musl-libc.org/cgit/musl/tree/arch/powerpc/bits/stat.h [2]: https://git.musl-libc.org/cgit/musl/commit/?id=3dcbd896907d9d474da811b7c6b769342abaf651 [3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105225 Signed-off-by: Sören Tempel --- libgo/mksysinfo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 5aa30915..72044624 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then fi # The syscall numbers. We force the names to upper case. -grep '^const _SYS_' gen-sysinfo.go | \ +grep '^const _SYS_[a-z]' gen-sysinfo.go | \ sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ while read sys; do sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` @@ -506,7 +506,7 @@ fi # For historical reasons Go uses the suffix "timespec" instead of "tim" for # stat_t's time fields on NetBSD. -st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' +st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' if test "${GOOS}" = "netbsd"; then st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' fi