From: Uros Bizjak <ubizjak@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Miguel Ojeda <ojeda@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, mm-commits@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] MM updates for 6.14-rc1
Date: Mon, 27 Jan 2025 00:27:40 +0100 [thread overview]
Message-ID: <CAFULd4aDuPA3rig9BzD_P1Y62S0Y5Yv_8AxpjtwTddv4OPNoHg@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wjmThGBZCxmBTypng2NEczY7cdJi2Dotf7ygun=hu_EGQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
On Sun, Jan 26, 2025 at 11:00 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Sun, 26 Jan 2025 at 11:47, Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > > #if __clang_major__ >= 19
> > > # define CC_HAS_TYPEOF_UNQUAL 1
> > > #endif
> >
> > It is available in gcc-14.
>
> Ok, let's take that approach, instead of messing with CONFIG_CC_HAS_xyz.
Please find attached an incremental patch that implements the proposed approach.
The detection is put in include/linux/compiler.h where we can
consolidate checks for both compilers:
--cut here--
/*
* Declare compiler support for __typeof_unqual__() operator.
*
* bindgen uses LLVM even if our C compiler is gcc, so we cannot
* rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL.
*
* XXX: Remove test for __CHECKER__ once
* sparse learns about __typeof_unqual__.
*/
#if ((defined(__GNUC__) && __GNUC__ >= 14) || \
(defined(__clang__) && __clang_major__ >= 19)) && \
!defined(__CHECKER__)
# define CC_HAS_TYPEOF_UNQUAL 1
#endif
/*
* Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof
* operator when available, to return an unqualified type of the exp.
*/
#if defined(CC_HAS_TYPEOF_UNQUAL)
# define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp)
#else
# define TYPEOF_UNQUAL(exp) __typeof__(exp)
#endif
--cut here--
The above also consolidates checks for __CHECKER__, resulting in a
much simpler compile check in arch/x86/include/percpu.h.
I have tested the new patch series with a bunch of compilers, works as
expected, but it is getting a bit late here. I'll resend the series
tomorrow, after some more testing.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 2416 bytes --]
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 1ef08289e667..9f0831a5e712 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -95,12 +95,7 @@
#endif /* CONFIG_SMP */
-/*
- * XXX: Remove test for __CHECKER__ once
- * sparse learns about __typeof_unqual__.
- */
-#if defined(CONFIG_USE_X86_SEG_SUPPORT) && \
- defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__)
+#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(CC_HAS_TYPEOF_UNQUAL)
# define __my_cpu_type(var) typeof(var)
# define __my_cpu_ptr(ptr) (ptr)
# define __my_cpu_var(var) (var)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index eac58025ecfc..7a52bea4ba76 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -314,13 +314,25 @@ static inline void *offset_to_ptr(const int *off)
#define prevent_tail_call_optimization() mb()
/*
- * Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof
- * operator when available, to return unqualified type of the exp.
+ * Declare compiler support for __typeof_unqual__() operator.
+ *
+ * bindgen uses LLVM even if our C compiler is gcc, so we cannot
+ * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL.
*
* XXX: Remove test for __CHECKER__ once
* sparse learns about __typeof_unqual__.
*/
-#if defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__)
+#if ((defined(__GNUC__) && __GNUC__ >= 14) || \
+ (defined(__clang__) && __clang_major__ >= 19)) && \
+ !defined(__CHECKER__)
+# define CC_HAS_TYPEOF_UNQUAL 1
+#endif
+
+/*
+ * Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof
+ * operator when available, to return an unqualified type of the exp.
+ */
+#if defined(CC_HAS_TYPEOF_UNQUAL)
# define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp)
#else
# define TYPEOF_UNQUAL(exp) __typeof__(exp)
diff --git a/init/Kconfig b/init/Kconfig
index a1507b8714e4..7fe82a46e88c 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -897,9 +897,6 @@ config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
config CC_HAS_INT128
def_bool !$(cc-option,$(m64-flag) -D__SIZEOF_INT128__=0) && 64BIT
-config CC_HAS_TYPEOF_UNQUAL
- def_bool $(success,echo 'int foo (int a) { __typeof_unqual__(a) b = a; return b; }' | $(CC) -x c - -S -o /dev/null)
-
config CC_IMPLICIT_FALLTHROUGH
string
default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)
next prev parent reply other threads:[~2025-01-26 23:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-25 0:22 Andrew Morton
2025-01-25 22:09 ` Linus Torvalds
2025-01-26 5:00 ` Andrew Morton
2025-01-26 7:34 ` Linus Torvalds
2025-01-26 8:27 ` Stephen Rothwell
2025-01-26 12:10 ` Uros Bizjak
2025-01-26 9:57 ` Uros Bizjak
2025-01-26 17:21 ` Uros Bizjak
2025-01-26 18:29 ` Linus Torvalds
2025-01-26 19:46 ` Uros Bizjak
2025-01-26 20:06 ` Uros Bizjak
2025-01-26 21:59 ` Linus Torvalds
2025-01-26 23:27 ` Uros Bizjak [this message]
2025-01-27 0:08 ` Linus Torvalds
2025-01-27 7:29 ` Uros Bizjak
2025-01-26 20:28 ` Miguel Ojeda
2025-01-26 21:19 ` Matthew Wilcox
2025-01-26 21:35 ` Miguel Ojeda
2025-01-26 20:58 ` Miguel Ojeda
2025-01-29 20:10 ` John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFULd4aDuPA3rig9BzD_P1Y62S0Y5Yv_8AxpjtwTddv4OPNoHg@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mm-commits@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox