From patchwork Sat May 6 18:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1778075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=rQ+Kbi7g; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=00eF4yuC; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDGgv0v5bz1ydV for ; Sun, 7 May 2023 04:44:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EC1703CBF7E for ; Sat, 6 May 2023 20:44:52 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 760813C9BF5 for ; Sat, 6 May 2023 20:44:51 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B16F610001B7 for ; Sat, 6 May 2023 20:44:50 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3C7D21F750; Sat, 6 May 2023 18:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1683398688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qYDu+tt1zwdVQLrZIxu1kFQYTyQov3y1Y+nxPZOg9t4=; b=rQ+Kbi7gmYu59ndc9AES7GVKZkByKK/iTj5Udhk01Id7Ee4msAqB4SPc+oYrIzNO8btnOF gPS2W7tvhB9SkwpTaLzKnvZ8mR0cGkD0dXrpO7Rv35Uoe4utzsoODUSqVBCn5LTdTIZiYX 3YkknC4jesY+oLzLubYDVrSvu9D1Sfg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1683398688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qYDu+tt1zwdVQLrZIxu1kFQYTyQov3y1Y+nxPZOg9t4=; b=00eF4yuC1LPq2eBAq5L7kf/iZRSx+OYAaBr3ZrqB2ZfONVIl5X+BMgowWRWVBye6tsdL9Y 0Ux1btpPlv5f28DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C909A1346B; Sat, 6 May 2023 18:44:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oENWLh6gVmQ8IgAAMHmgww (envelope-from ); Sat, 06 May 2023 18:44:46 +0000 From: Petr Vorel To: ltp@lists.linux.it Date: Sat, 6 May 2023 20:44:24 +0200 Message-Id: <20230506184424.105501-1-pvorel@suse.cz> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [RFC PATCH v2 1/1] lapi: Add sysinfo.h to fix build with older MUSL toolchain X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Petr Vorel When building LTP with older MUSL based toolchains without kernel fix a85cbe6159ff ("uapi: move constants from to ") from 5.11 build fails due indirect include when using some network headers: or others -> -> . This indirect include causes on MUSL redefinition of struct sysinfo when included both and some of UAPI headers: In file included from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5, from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11: x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here a85cbe6159ff was merged into stable versions, but Buildroot projects reports still older MUSL toolchains not using it. Therefore they asked to require 5.11 headers for musl, which mean no LTP for many toolchains. Signed-off-by: Petr Vorel --- Hi, I posted this patch 3 years ago [1]. Later my fix in kernel was merged, but still Buildroot asks for this patch. I'm ok to maintain it downstream, unless you are ok to have it in upstream LTP. I'm not sure for how long it will be needed, at least now the official Buildroot MUSL toolchains are 4.9 based. Kind regards, Petr [1] https://lore.kernel.org/ltp/20201001231256.6930-1-petr.vorel@gmail.com/ include/lapi/sysinfo.h | 22 +++++++++++++++++++ include/tst_safe_macros.h | 2 +- lib/safe_macros.c | 2 +- lib/tst_memutils.c | 2 +- testcases/kernel/mem/mtest01/mtest01.c | 2 +- testcases/kernel/syscalls/madvise/madvise06.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo01.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo02.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo03.c | 4 ++-- .../interfaces/pthread_cond_broadcast/1-2.c | 2 +- 10 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 include/lapi/sysinfo.h diff --git a/include/lapi/sysinfo.h b/include/lapi/sysinfo.h new file mode 100644 index 000000000..ab4e4c62a --- /dev/null +++ b/include/lapi/sysinfo.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Petr Vorel + */ + +#ifndef SYSINFO_H__ + +/* + * Don't use as it breaks build MUSL toolchain. + * Use instead. + * + * Some kernel UAPI headers do indirect include: + * or others -> -> + * + * This indirect include causes on MUSL redefinition of struct sysinfo when + * included both and some of UAPI headers: + */ +#include + +#define SYSINFO_H__ + +#endif /* SYSINFO_H__ */ diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 0cf3d7878..43da18e2a 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/safe_macros.c b/lib/safe_macros.c index af6dd0716..e38ff1c43 100644 --- a/lib/safe_macros.c +++ b/lib/safe_macros.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include "lapi/fcntl.h" +#include "lapi/sysinfo.h" #include "test.h" #include "safe_macros.h" diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c index 6fc9f6a93..a52b46a71 100644 --- a/lib/tst_memutils.c +++ b/lib/tst_memutils.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include "lapi/sysinfo.h" #include #define TST_NO_DEFAULT_MAIN diff --git a/testcases/kernel/mem/mtest01/mtest01.c b/testcases/kernel/mem/mtest01/mtest01.c index fb991ce8b..0fccd5405 100644 --- a/testcases/kernel/mem/mtest01/mtest01.c +++ b/testcases/kernel/mem/mtest01/mtest01.c @@ -20,7 +20,6 @@ */ #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include "lapi/abisize.h" +#include "lapi/sysinfo.h" #include "tst_test.h" #define FIVE_HUNDRED_MB (500ULL*1024*1024) diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c index be22318ea..32fdff740 100644 --- a/testcases/kernel/syscalls/madvise/madvise06.c +++ b/testcases/kernel/syscalls/madvise/madvise06.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include "lapi/sysinfo.h" #include "tst_test.h" #define CHUNK_SZ (400*1024*1024L) diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo01.c b/testcases/kernel/syscalls/sysinfo/sysinfo01.c index 2ea44a2be..a237345ef 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo01.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo01.c @@ -69,7 +69,7 @@ #include #include #include -#include +#include "lapi/sysinfo.h" #include "test.h" diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo02.c b/testcases/kernel/syscalls/sysinfo/sysinfo02.c index 7ad0e8bdc..61fa1ab75 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo02.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo02.c @@ -65,7 +65,7 @@ #include #include #include -#include +#include "lapi/sysinfo.h" #include #include "test.h" diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo03.c b/testcases/kernel/syscalls/sysinfo/sysinfo03.c index 6b8f0aef7..0b6ffb49b 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo03.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo03.c @@ -13,10 +13,10 @@ */ -#include #include "lapi/posix_clocks.h" -#include "tst_test.h" #include "lapi/sched.h" +#include "lapi/sysinfo.h" +#include "tst_test.h" static int offsets[] = { 10, diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c index 22e7c3638..572701f9f 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c @@ -43,7 +43,7 @@ #include #include #ifdef __linux__ -#include +#include "lapi/sysinfo.h" #endif #include "../testfrmw/testfrmw.h"