From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63AFBC83F1F for ; Tue, 29 Aug 2023 10:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235085AbjH2KQm (ORCPT ); Tue, 29 Aug 2023 06:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235061AbjH2KQa (ORCPT ); Tue, 29 Aug 2023 06:16:30 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8762F9; Tue, 29 Aug 2023 03:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1693304185; bh=mdFDAQP5J31KOKjv/zKAqqp9gA/YCjsW8cCLllwIzmk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HvqgMnnRcwNXe54XUwiTbAEzI0Ld2EETfvX2rhE0SbBp6ZIpI8arNfNtxC4ufJD64 Ok7Zhte1pXx+2KS9gcNimPirqJ5QCXWx9SAwfxupO41kJ9cVMKfJzvNeuQHa2b8no7 AgvG0cypKRu7jcRnzcW9nle6ewPuK7eSiBGwaBto= Date: Tue, 29 Aug 2023 12:16:23 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Willy Tarreau Cc: Shuah Khan , Zhangjin Wu , Yuan Tan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 1/2] tools/nolibc: add stdarg.h header Message-ID: References: <20230827-nolibc-nostdinc-v1-0-995d1811f1f3@weissschuh.net> <20230827-nolibc-nostdinc-v1-1-995d1811f1f3@weissschuh.net> <2b6c62f1-c1f1-4f2c-ba0c-981e066f4268@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-08-29 11:26:19+0200, Willy Tarreau wrote: > On Tue, Aug 29, 2023 at 11:14:09AM +0200, Thomas Weißschuh wrote: > > Hi Willy! > > > > On 2023-08-29 08:28:27+0200, Willy Tarreau wrote: > > > On Sun, Aug 27, 2023 at 10:00:15AM +0200, Thomas Weißschuh wrote: > > > > This allows nolic to work with `-nostdinc` avoiding any reliance on > > > > system headers. > > > > > > > > The implementation has been lifted from musl libc 1.2.4. > > > > There is already an implementation of stdarg.h in include/linux/stdarg.h > > > > but that is GPL licensed and therefore not suitable for nolibc. > > > > > > I'm a bit confused because for me, stdarg was normally provided by the > > > compiler, but I could be mistaken. It's just that it reminds me not so > > > old memories. Therefore maybe we just need to include or define > > > "something" to use it. > > > > It is indeed provided by the compiler. > > OK. But then, doesn't it mean that if we don't provide our stdarg.h, > the compilers' will be used ? I'm asking because we're already using > va_list and va_args, for example in vfprintf() in stdio.h, which > precisely includes so it must indeed come from the compiler. It will be used *iff* -nostdinc is *not* passed. I think we need to clarify the definition of the word "provided". For me it means that the compiler ships an implementation of this header file in the compiler-specific include directory. If -nostdinc is passed this include directory is not actually usable. If a user wants to avoid the implicit usage of any system-provided headers they need to pass -nostdinc, as far as I know there is no flag to keep only the compiler-specific include directories. One usecase is in nolibc-test itself, where Zhangjin ran into weird and inconsistent behavior of system includes being pulled in. By using -nostdinc we avoid this. I can also see this being useful for normal users. > > I could not find anybody doing this differently. > > Using builtins seems to me to be the normal way to expose compiler > > implementation specifics. > > OK but it's already what the compiler does itself in its own stdarg that > is provided. That's why I don't understand what specific case we're trying > to cover here, I feel like we're providing an alternate stdarg in case the > compiler doesn't provide one except that I've not seen a compiler not > provide it (even tcc comes with it), it's like stddef. It's all about supporting -nostdinc. FYI stdint.h is also provided by nolibc, gcc and glibc.