]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arch: Add the macro COMPILE_OFFSETS to all the asm-offsets.c
authorMenglong Dong <menglong8.dong@gmail.com>
Wed, 17 Sep 2025 06:09:13 +0000 (14:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 2 Nov 2025 13:14:41 +0000 (22:14 +0900)
[ Upstream commit 35561bab768977c9e05f1f1a9bc00134c85f3e28 ]

The include/generated/asm-offsets.h is generated in Kbuild during
compiling from arch/SRCARCH/kernel/asm-offsets.c. When we want to
generate another similar offset header file, circular dependency can
happen.

For example, we want to generate a offset file include/generated/test.h,
which is included in include/sched/sched.h. If we generate asm-offsets.h
first, it will fail, as include/sched/sched.h is included in asm-offsets.c
and include/generated/test.h doesn't exist; If we generate test.h first,
it can't success neither, as include/generated/asm-offsets.h is included
by it.

In x86_64, the macro COMPILE_OFFSETS is used to avoid such circular
dependency. We can generate asm-offsets.h first, and if the
COMPILE_OFFSETS is defined, we don't include the "generated/test.h".

And we define the macro COMPILE_OFFSETS for all the asm-offsets.c for this
purpose.

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
20 files changed:
arch/alpha/kernel/asm-offsets.c
arch/arc/kernel/asm-offsets.c
arch/arm/kernel/asm-offsets.c
arch/arm64/kernel/asm-offsets.c
arch/csky/kernel/asm-offsets.c
arch/hexagon/kernel/asm-offsets.c
arch/loongarch/kernel/asm-offsets.c
arch/m68k/kernel/asm-offsets.c
arch/microblaze/kernel/asm-offsets.c
arch/mips/kernel/asm-offsets.c
arch/nios2/kernel/asm-offsets.c
arch/openrisc/kernel/asm-offsets.c
arch/parisc/kernel/asm-offsets.c
arch/powerpc/kernel/asm-offsets.c
arch/riscv/kernel/asm-offsets.c
arch/s390/kernel/asm-offsets.c
arch/sh/kernel/asm-offsets.c
arch/sparc/kernel/asm-offsets.c
arch/um/kernel/asm-offsets.c
arch/xtensa/kernel/asm-offsets.c

index 11c35cf45b4610f74f53d71fec17b65d927d161f..cb205f22096d7885887b388ccd5ee76d4bed165b 100644 (file)
@@ -4,6 +4,7 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/types.h>
 #include <linux/stddef.h>
index f77deb7991757ea477d8500f80f2d7c6431a4eea..2978da85fcb65b34fbbffb2bd665848d88c8fa7d 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  */
+#define COMPILE_OFFSETS
 
 #include <linux/sched.h>
 #include <linux/mm.h>
index 219cbc7e5d134b5bb0638d158266f809968977b6..3840e1e22b7517d8ed4d03c6b7329f31e7cebbc5 100644 (file)
@@ -7,6 +7,8 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
+#define COMPILE_OFFSETS
+
 #include <linux/compiler.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
index 5ff1942b04fcfd94e334b6b204f7f3885647c68d..ea2d740db81c523a3c347f9fa6b1b59f24553977 100644 (file)
@@ -6,6 +6,7 @@
  *               2001-2002 Keith Owens
  * Copyright (C) 2012 ARM Ltd.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/arm_sdei.h>
 #include <linux/sched.h>
index d1e9035794733dc03140c20fa07bd231a9c8c31b..5525c8e7e1d9ea827b21408d947a54875b86e124 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#define COMPILE_OFFSETS
 
 #include <linux/sched.h>
 #include <linux/kernel_stat.h>
index 03a7063f9456140d7a4e4577fe79d92a53842f11..50eea9fa6f1375443c4ce3983c086efaaf441549 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/compat.h>
 #include <linux/types.h>
index 8da0726777edb41ea66d47f640308c18435f4551..110afd3cc8f348c2c17e27ec942cb57c65afba6e 100644 (file)
@@ -4,6 +4,8 @@
  *
  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  */
+#define COMPILE_OFFSETS
+
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
index 906d73230537440fde199e779bd484683a0e8d9d..67a1990f9d748ff3cf3075356468b4de9e83e5d6 100644 (file)
@@ -9,6 +9,7 @@
  * #defines from the assembly-language output.
  */
 
+#define COMPILE_OFFSETS
 #define ASM_OFFSETS_C
 
 #include <linux/stddef.h>
index 104c3ac5f30c88785b21055b43f38e72cca24a11..b4b67d58e7f6aeff12f2ad4a53bb6959a6f4927d 100644 (file)
@@ -7,6 +7,7 @@
  * License. See the file "COPYING" in the main directory of this archive
  * for more details.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/init.h>
 #include <linux/stddef.h>
index cb1045ebab0621ad2c8c59eaebe96b13d47e4514..22c99a2cd5707b3502479e3ced3a779c1537a9e1 100644 (file)
@@ -9,6 +9,8 @@
  * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 2000 MIPS Technologies, Inc.
  */
+#define COMPILE_OFFSETS
+
 #include <linux/compat.h>
 #include <linux/types.h>
 #include <linux/sched.h>
index e3d9b7b6fb48aaa6f6cd014fbcce4c29bf1cbd8c..88190b503ce5de31f356932f8c84690ca0c0d660 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
  */
+#define COMPILE_OFFSETS
 
 #include <linux/stddef.h>
 #include <linux/sched.h>
index 710651d5aaae100f5e603cd26c34c8dfb5d775de..3cc826f2216b1042440cf2734da5884a8be4bd3a 100644 (file)
@@ -18,6 +18,7 @@
  * compile this file to assembler, and then extract the
  * #defines from the assembly-language output.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/signal.h>
 #include <linux/sched.h>
index 757816a7bd4b287d71592be356769bfbb1b0a3ab..9abfe65492c65eadbc69d7a6fa01b2fbab5ad285 100644 (file)
@@ -13,6 +13,7 @@
  *    Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org>
  *    Copyright (C) 2003 James Bottomley <jejb at parisc-linux.org>
  */
+#define COMPILE_OFFSETS
 
 #include <linux/types.h>
 #include <linux/sched.h>
index 2affd30468bc4c19cf38c35c655c4eb8515a22e3..e2cee2f2ededdb6075e8cd84e07ad8c72927c352 100644 (file)
@@ -8,6 +8,7 @@
  * compile this file to assembler, and then extract the
  * #defines from the assembly-language output.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/compat.h>
 #include <linux/signal.h>
index 6a992cba2f2876ab9318b62a6084c9627898507c..e4589457e6085d776301a3d26e6cc55421f2c770 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (C) 2012 Regents of the University of California
  * Copyright (C) 2017 SiFive
  */
+#define COMPILE_OFFSETS
 
 #include <linux/kbuild.h>
 #include <linux/mm.h>
index fa5f6885c74aa1f3b5d50b96ad0f633fe393b04a..73a989dcfe2082bcd022c25e88f36516974568c7 100644 (file)
@@ -4,6 +4,7 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
+#define COMPILE_OFFSETS
 
 #define ASM_OFFSETS_C
 
index a0322e8328456ef5b7d19d1b9e6df3431319b101..429b6a76314684bf57906d9cfb919347b88d10c9 100644 (file)
@@ -8,6 +8,7 @@
  * compile this file to assembler, and then extract the
  * #defines from the assembly-language output.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/stddef.h>
 #include <linux/types.h>
index 5784f2df489a4d7e1f204c61d8f2ccb313486801..f1e27a7f800f41b2d924e10c396339ebec78734d 100644 (file)
@@ -10,6 +10,7 @@
  *
  * On sparc, thread_info data is static and TI_XXX offsets are computed by hand.
  */
+#define COMPILE_OFFSETS
 
 #include <linux/sched.h>
 #include <linux/mm_types.h>
index 1fb12235ab9c8479a0c81aca2fd4b9d10ff20c69..a69873aa697f4f5ba1a4f529175c47f42a46fcd7 100644 (file)
@@ -1 +1,3 @@
+#define COMPILE_OFFSETS
+
 #include <sysdep/kernel-offsets.h>
index da38de20ae598b1a76b1785bb11a7cce53737d73..cfbced95e944a49c47c55aab5bed94307a45c21a 100644 (file)
@@ -11,6 +11,7 @@
  *
  * Chris Zankel <chris@zankel.net>
  */
+#define COMPILE_OFFSETS
 
 #include <asm/processor.h>
 #include <asm/coprocessor.h>