From ad3d6641c7cff9a8a8929555b0e1f9c965da1ab5 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Sat, 6 Jun 2026 12:00:00 +0000 Subject: [PATCH] build: Avoid forcing -include arch/config.h into global CFLAGS/AFLAGS Stop forcing -include arch/config.h into global CFLAGS/AFLAGS and instead include architecture-specific arch/config.h only when in the header which requires them. This prevents the build/language-server from seeing architecture-only headers unconditionally and fixes language-server failures and spurious parsing errors in IDEs caused by unconditional inclusion of architecture headers and missing arch config in certain builds. --- build/common.mk | 4 ++-- include/xtf/compiler.h | 6 ++++++ include/xtf/numbers.h | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build/common.mk b/build/common.mk index a6e270f5..c22ba9a6 100644 --- a/build/common.mk +++ b/build/common.mk @@ -59,8 +59,8 @@ define PERENV_setup AFLAGS_$($(1)_arch) := $$(COMMON_AFLAGS) $$(COMMON_AFLAGS-$($(1)_arch)) CFLAGS_$($(1)_arch) := $$(COMMON_CFLAGS) $$(COMMON_CFLAGS-$($(1)_arch)) -AFLAGS_$(1) := $$(AFLAGS_$($(1)_arch)) $$(COMMON_AFLAGS-$(1)) -DCONFIG_ENV_$(1) -include arch/config.h -CFLAGS_$(1) := $$(CFLAGS_$($(1)_arch)) $$(COMMON_CFLAGS-$(1)) -DCONFIG_ENV_$(1) -include arch/config.h +AFLAGS_$(1) := $$(AFLAGS_$($(1)_arch)) $$(COMMON_AFLAGS-$(1)) -DCONFIG_ENV_$(1) +CFLAGS_$(1) := $$(CFLAGS_$($(1)_arch)) $$(COMMON_CFLAGS-$(1)) -DCONFIG_ENV_$(1) link-$(1) := $(ROOT)/arch/x86/link-$(1).lds diff --git a/include/xtf/compiler.h b/include/xtf/compiler.h index 19d93492..35fb8c4d 100644 --- a/include/xtf/compiler.h +++ b/include/xtf/compiler.h @@ -1,6 +1,12 @@ #ifndef XTF_COMPILER_H #define XTF_COMPILER_H +#if defined(CONFIG_ENV_pv64) || defined(CONFIG_ENV_pv32pae) || \ + defined(CONFIG_ENV_hvm64) || defined(CONFIG_ENV_hvm32pae) || \ + defined(CONFIG_ENV_hvm32pse) || defined(CONFIG_ENV_hvm32) +#include +#endif + #ifdef __GNUC__ #include #endif diff --git a/include/xtf/numbers.h b/include/xtf/numbers.h index f5c73b7e..9b7747a9 100644 --- a/include/xtf/numbers.h +++ b/include/xtf/numbers.h @@ -6,6 +6,12 @@ #ifndef XTF_NUMBERS_H #define XTF_NUMBERS_H +#if defined(CONFIG_ENV_pv64) || defined(CONFIG_ENV_pv32pae) || \ + defined(CONFIG_ENV_hvm64) || defined(CONFIG_ENV_hvm32pae) || \ + defined(CONFIG_ENV_hvm32pse) || defined(CONFIG_ENV_hvm32) +#include +#endif + /** * Create an integer usable in both C and Assembly, even when @p suf is * needed.