From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A5EF386449 for ; Tue, 7 Apr 2026 11:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775559775; cv=none; b=N3bMEiI0QQKtjojFsXOnvyQzsVWfnblDdsXgCKYEInPMushEE1f/ycHTOEa/9fRd6ZYIx2oSXKdJvzQ3+2ulbywoGBH5dFsOSnuzH0LQ5O8yrM2q0/obJmWpvIc+JsmDV/tM2Ex5DH5UYozcY8vXledVTbd6vDzfRAxMOWPjh7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775559775; c=relaxed/simple; bh=hQ5uEfxMHS4hH1Kt/B6gRHkrU/wi7nq6bjycwC9QSuI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kysTOwFwDwQNEUH0e+ksKhh+6y7xwmz4XmdoRJHPlWVfXk21IAPknHo8/zHEow1fIkYRFSUOnNpJOMRIzJHQ4aFEYJ82yE4Sb1hH3lMMC58t7cBN9vtFcGgPO4aBhhVMlT9UznhnPHu5ZX/LjucPGEDkud3gj6rBl8VgxpLwu2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TpF3Wa4/; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TpF3Wa4/" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-43d02a71526so2845141f8f.3 for ; Tue, 07 Apr 2026 04:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775559772; x=1776164572; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=eOF7QEiIZnMxT61Qm6XC+xVS8uAZXf1PaboQoIhqgXE=; b=TpF3Wa4/CXWmO4sF4tJe07IZI3Okv0OgX7zoVvyZAvX8GXTBfY9Lrb9TJdOoBPVDXD g7HOf66VqAHSjUgzYpn9Y7V73xs5tILb2MyFEAaityq92jYYD7dNS0WOxkqXM3CMtRV9 ap26j32yzBtVU4GUJ1xhJQlpY0tJOM4VSY34Q3q6ghTildCKBqBhqtBxWmY2i2+pXwG+ zXiq20VdAHlhSej/1QwKfPORKrXLN0IRolcI/C6NdNoNRC2TeYbqk4FgLPGLmMYL6en2 IENt5QhuQgjhr0cYAvVhjAsczXIPG8awwCW6BgrOblPwE+5dae7vrJBU9X6cVHISD+qK p6QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775559772; x=1776164572; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eOF7QEiIZnMxT61Qm6XC+xVS8uAZXf1PaboQoIhqgXE=; b=o5z2TvHFrbKT22Ip7WrTjH62rlbxK4T/vFGO9THUB0i8WQrPXItChgL4GrmwOmgY2/ d8BpMrjIhL7F/RURpYaDtvW/5VGiebe02ClY00QkhB2ZA2OC+txgzaXOqaGt6Yx3jdk9 uhoIf8Ih/pUmgRoeziW5nePQDLm+Xdpl8Ag9OTTg7wdOlvZnDIOkipoPHGYyE8K3eD31 xIYfugCVj/2AhanglctOabaCAD6XlywZ64jpa/k40T5ZPk597+M0tIgpDDmtnn95eHyH hD7YB7YVwiIr7x8YQnnPA+gRPxwxa+KufOXMSEfMjnJKmJ1EOIIfzSj+8nhNaQHZNeFA 4Ypg== X-Forwarded-Encrypted: i=1; AJvYcCVR2Tg28091CDDsocrWinoQfKBT6N0WjX/dRnSo7g0LlRBuUwGRohm6WqnPs2J4u7kM3SeLGXdCfHK9Bk8=@vger.kernel.org X-Gm-Message-State: AOJu0YxbxLuIyid44BrV3Rm4AyWDPiX5PPj3w1KZXHeUf4o/61L2Bfjj aj129AfamMnGNIx2cCC/JsMx97T2/UnIuJPRdAMgYmvVdDuqN/DJzH5d X-Gm-Gg: AeBDieuzEW+z3AH9zV8/DsLN7Xjmf5ZShiGIHEPYQtSI2MsXCg79PE8hClL2+QKR2Q3 HgSOFOI5MIdLFiPZSboQWyFZqsOmRhkdHIPJds5ROOsHsxbCU84tIsoCxbYyibVxboT5szYUXL1 t1k5CIgFZUjUug1HjBHoFXacJSfAMT/wm+Bc9kw3qeyHhKbZEGi97IHsotAXg/TNubOwfl3+vxx DHBsBqHxeAqo4I5hLg+XUkZN+zP88BRpJ+O0LYij8cR165OsJ3q6XQIwn28gZ7cXsMJseBQUfZH +OEPcEdwfBpg9aW0zr0IScME4ySq0EFaFU1xoXyswAOaTwewj2K21v5MP7MwFltqcQLh0M6077i q4wexiRWFeXIx3NJavQT8+XrXjQAePWt3nDMmjBswT+ppbmZmlR5CgOrTRisQYj7cxlUA+5vbFz EgTwZjvPtGR0+eWdkuGPAqBah9wuozh6L6HxZiw967HI7U+HSQB7zsRQdPTxEULQs1 X-Received: by 2002:a05:600c:c8f:b0:487:243f:dc3e with SMTP id 5b1f17b1804b1-488996d23e7mr195386775e9.6.1775559771781; Tue, 07 Apr 2026 04:02:51 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488a4b2e111sm282027815e9.1.2026.04.07.04.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 04:02:51 -0700 (PDT) Date: Tue, 7 Apr 2026 12:02:50 +0100 From: David Laight To: Willy Tarreau Cc: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , linux-kernel@vger.kernel.org Subject: Re: [PATCH] tools/nolibc: make __nolibc_enosys() a compile time error Message-ID: <20260407120250.515db167@pumpkin> In-Reply-To: References: <20260404-nolibc-enosys-v1-1-e0aba47bdee4@weissschuh.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 7 Apr 2026 09:15:28 +0200 Willy Tarreau wrote: > Hi Thomas, >=20 > On Sat, Apr 04, 2026 at 05:26:05PM +0200, Thomas Wei=C3=9Fschuh wrote: > > Functions which are known at compile-time to result in ENOSYS can be > > surprising to the user. For example using old UAPI headers might mean > > that stat() will always fail although the kernel would have the system > > call available at runtime. Nowadays __nolibc_enosys() should never be > > called for normal applications. > >=20 > > Switch the silent ENOSYS return into a compile-time error, so the user > > is aware about the issue. Prefer the 'error' attribute as it provides > > the best diagnostics. If the users defines NOLIBC_COMPILE_TIME_ENOSYS > > the old, silent fallback is kept. > >=20 > > Also add a test which validates that the error can be optimized away. > >=20 > > Reported-by: Willy Tarreau > > Closes: https://lore.kernel.org/lkml/acizRIq2xrFUNHNS@1wt.eu/ > > Signed-off-by: Thomas Wei=C3=9Fschuh > > --- > > This should probably go into the next cycle. > > --- > > tools/include/nolibc/sys.h | 18 ++++++++++++++++-- > > tools/testing/selftests/nolibc/nolibc-test.c | 18 ++++++++++++++++++ > > 2 files changed, 34 insertions(+), 2 deletions(-) > >=20 > > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h > > index 6335fd51f07f..fd7a2ee780e8 100644 > > --- a/tools/include/nolibc/sys.h > > +++ b/tools/include/nolibc/sys.h > > @@ -45,16 +45,30 @@ > > : __sysret_arg; /* return original value */ \ > > }) > > =20 > > -/* Syscall ENOSYS helper: Avoids unused-parameter warnings and provide= s a > > - * debugging hook. > > +/* Syscall ENOSYS helper: Avoids unused-parameter warnings, provides c= ompile > > + * time validation and a debugging hook. > > */ > > =20 > > +#if defined(NOLIBC_COMPILE_TIME_ENOSYS) > > static __inline__ int __nolibc_enosys(const char *syscall, ...) > > { > > (void)syscall; > > return -ENOSYS; > > } > > =20 > > +#elif __nolibc_has_attribute(error) > > +__attribute__((error("system call not implemented"))) > > +extern int __nolibc_enosys(const char *syscall, ...); =20 >=20 > I didn't know it was possible to force the error message like this, > I like it! Look at __compiletime_assert() in include/linux/compiler_types.h If you try a bit harder it should be possible to get the system call name into the error message. Perhaps something like: #define __nolibc__enosys(syscall, name, ...) ({ \ void __nolibc_enosys_##name(...) __attribute__((error("system call " #name= " not implemented"))); \ __nolibc_enosys_##name(__VA_ARGS__); \ -ENOSYS; \ }) David