]> 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)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 25 Sep 2025 07:57:15 +0000 (09:57 +0200)
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>
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 e9dad60b147f33e23ea6f59de654df2c6ad52a28..1ebb058904992b68130befa2fa62fad3374b3526 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 123f4a8ef44660a39c4eff2a6e5fd86cb48fb572..2101938d27fcbccf9f3c3bf149e21ad43fe705cc 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 30d4bbe68661f45f9b32b13102c91538a4e38182..b6367ff3a49ca1efa9399200a0e9d6eea5d40a63 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 db1e4bb26b6a01a4da0d505af1554fbb0c311703..3017c7157600993b44245acc0abbfedd8dec54d8 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 1e29efcba46e57d58e727c91a2ad5dff63afd488..5debd9a3854a9e3003f1ca524baa2278c42d922b 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 b3048f6d3822c0c457f4aa2ccb5dc870495ba79b..a4bc80b30410ae6d2a468613e779e4af7677179f 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 6e8c0d6feae9e9b79e529fc86e3dd42467fea6ad..7d42d3b8a32a751c7bda1c89633f22f1b0ad602f 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 95ecad9c7d7d27e1633be20a9d10d8a0d51e2e45..a8915663e917faed4551276b64013ee073662cc9 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/kbuild.h>
 #include <linux/sched.h>
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 3d9b9855dce9174f913b9468a5334cebba78d07f..6e660bde48dd898034f0eedeef80076ed0a7599b 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>