Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3330891rwb; Mon, 16 Jan 2023 06:45:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXuz6Rsms2uMUH8ROaqlQmLkl9Bx3aAqeHRkCWvu65MClZhV2q/7jG9uZgD2BwT+Z+XkrSVI X-Received: by 2002:a17:902:bf03:b0:194:9480:fbc4 with SMTP id bi3-20020a170902bf0300b001949480fbc4mr3935588plb.30.1673880310049; Mon, 16 Jan 2023 06:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673880310; cv=none; d=google.com; s=arc-20160816; b=QaVnQPHO0NYN11IvpEA6r3hlCNkOfEkVVnKeA2tc25zrFRxFu5Dw3EN9YFkvnijS9Y tohTszPSB/RnrIlfFiNYlu/al/vABaxRRq1yXht3l3+PoaXr/U6wqBS4X9uYxU4wI4O5 2cNjhbcS+9W8JwUXJY4RrfC9zEaov+0S7+7oP5D4L315JI7Ts/g+peNaavN3ITMc9iNZ Cxhar7BmeCSsCq6+3iSh5/Rv44HkrdWjUH7usO6Ti+VU1uAPqub4KsUIe4EQvJF+0BYj OaZjlxepXLtoDyb656cB6ctlUAuAiHKBgH5eXo3Ejp6pcKgQqx2IHHP3aqvHqFfkJ+tG QDrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TBoDphuNCDySScS7SyukZve12GMO2mkaU2aol7I4nyc=; b=ty20lLgDYuP6q5ycw4fxIbc5eNBI25jhrmkqyuuAIenBNxMk5C/8XGhguzRjMtDFc+ yOzAmCR+8NdDKBAjySXN9i6H6hy06gyMzUUGKg2L/qGrGQXpN/nhqBD6n1FgCNQJeH+R WiWETrzcpnmgAVT0yJl2PQzPD6WjdgbQN9KHsqcQCS4el/sgnTdRuIaYKIlxX5Zo9E8F vHU11hJnYqdcLQBDYch10EjST6C4x68g+VQXKSUrBShj3lznA/+r7HTwsy83o7gnRPnX psatRo4WzrYI7Y3d+uO5JqJevFJXdtslwgvjXbE7kU2WkeYkNsxc07gZcq66Y+qS/S6g BWaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SZPQmfeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a170902cf4a00b00194767a784fsi9075154plg.396.2023.01.16.06.44.34; Mon, 16 Jan 2023 06:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SZPQmfeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjAPOGY (ORCPT + 50 others); Mon, 16 Jan 2023 09:06:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbjAPOFE (ORCPT ); Mon, 16 Jan 2023 09:05:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3CEB227A8; Mon, 16 Jan 2023 06:03:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5161460FD3; Mon, 16 Jan 2023 14:03:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 229CFC433D2; Mon, 16 Jan 2023 14:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877794; bh=fbIIfrqgLnFzf7qmBh7osG4T9uei9BB7Woeb6fp4REI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZPQmfeIVXopShbBUfaDdCFJSdwQySAC9+VrEGe0eW6yduvr9IopyjV/DMbpovy0W o5I9M6kelYdHFC6plY48J/i27gnrzot2V4cimeMnSLMBxgUEHqrpT+Ya4xlVhfr9Nl 1B/7lJ/n/yQktq65Y52VgI7EqA69nljE3UljpdxXHwGgo07WrwUzGUMhiK00fTtFuR ceI7e/Wd2AH8pkgsfVwBFDkPogNVgAaZOIr1e76MWDXZcfKfNX/mVGjZXTmGxm/o88 9vpuv/Fj+liF4nvhxE8UuCLwtXHNkIOOXsiq0oY9fo7dm6+tJVfrIhhF97Cze1EG45 pvbbQjLSUImUQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Willy Tarreau , "Paul E . McKenney" , Sasha Levin Subject: [PATCH AUTOSEL 6.1 29/53] tools/nolibc: fix missing includes causing build issues at -O0 Date: Mon, 16 Jan 2023 09:01:29 -0500 Message-Id: <20230116140154.114951-29-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230116140154.114951-1-sashal@kernel.org> References: <20230116140154.114951-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Willy Tarreau [ Upstream commit 55abdd1f5e1e07418bf4a46c233a92f83cb5ae97 ] After the nolibc includes were split to facilitate portability from standard libcs, programs that include only what they need may miss some symbols which are needed by libgcc. This is the case for raise() which is needed by the divide by zero code in some architectures for example. Regardless, being able to include only the apparently needed files is convenient. Instead of trying to move all exported definitions to a single file, since this can change over time, this patch takes another approach consisting in including the nolibc header at the end of all standard include files. This way their types and functions are already known at the moment of inclusion, and including any single one of them is sufficient to bring all the required ones. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- tools/include/nolibc/ctype.h | 3 +++ tools/include/nolibc/errno.h | 3 +++ tools/include/nolibc/signal.h | 3 +++ tools/include/nolibc/stdio.h | 3 +++ tools/include/nolibc/stdlib.h | 3 +++ tools/include/nolibc/string.h | 3 +++ tools/include/nolibc/sys.h | 2 ++ tools/include/nolibc/time.h | 3 +++ tools/include/nolibc/types.h | 3 +++ tools/include/nolibc/unistd.h | 3 +++ 10 files changed, 29 insertions(+) diff --git a/tools/include/nolibc/ctype.h b/tools/include/nolibc/ctype.h index e3000b2992d7..6f90706d0644 100644 --- a/tools/include/nolibc/ctype.h +++ b/tools/include/nolibc/ctype.h @@ -96,4 +96,7 @@ int ispunct(int c) return isgraph(c) && !isalnum(c); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_CTYPE_H */ diff --git a/tools/include/nolibc/errno.h b/tools/include/nolibc/errno.h index 06893d6dfb7a..9dc4919c769b 100644 --- a/tools/include/nolibc/errno.h +++ b/tools/include/nolibc/errno.h @@ -24,4 +24,7 @@ static int errno; */ #define MAX_ERRNO 4095 +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_ERRNO_H */ diff --git a/tools/include/nolibc/signal.h b/tools/include/nolibc/signal.h index ef47e71e2be3..137552216e46 100644 --- a/tools/include/nolibc/signal.h +++ b/tools/include/nolibc/signal.h @@ -19,4 +19,7 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_SIGNAL_H */ diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index a3cebc4bc3ac..96ac8afc5aee 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -303,4 +303,7 @@ void perror(const char *msg) fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STDIO_H */ diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 92378c4b9660..a24000d1e822 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -419,4 +419,7 @@ char *u64toa(uint64_t in) return itoa_buffer; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STDLIB_H */ diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index ad97c0d522b8..0932db3817d2 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -285,4 +285,7 @@ char *strrchr(const char *s, int c) return (char *)ret; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STRING_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index ce3ee03aa679..78473d34e27c 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1243,5 +1243,7 @@ ssize_t write(int fd, const void *buf, size_t count) return ret; } +/* make sure to include all global symbols */ +#include "nolibc.h" #endif /* _NOLIBC_SYS_H */ diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h index d18b7661fdd7..84655361b9ad 100644 --- a/tools/include/nolibc/time.h +++ b/tools/include/nolibc/time.h @@ -25,4 +25,7 @@ time_t time(time_t *tptr) return tv.tv_sec; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_TIME_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index f1d64fca7cf0..fbbc0e68c001 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -209,4 +209,7 @@ struct stat { }) #endif +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_TYPES_H */ diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h index 1c25e20ee360..1cfcd52106a4 100644 --- a/tools/include/nolibc/unistd.h +++ b/tools/include/nolibc/unistd.h @@ -51,4 +51,7 @@ int tcsetpgrp(int fd, pid_t pid) return ioctl(fd, TIOCSPGRP, &pid); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_UNISTD_H */ -- 2.35.1