Skip to content

Commit c3f35ec

Browse files
Avineshekyooo
authored andcommitted
clang: Add microsoft extensions build flags
Starting in Linux 6.19, `struct ns_common` fields were moved into an anonymous nested forward declaration (`struct ns_tree;`) within a union.[1] This causes Clang to throw a `[-Wmissing-declarations]` warning and fail with missing member errors. This affects tools pulling in `<linux/pid_namespace.h>` directly or transitively (e.g. filetop, runqlat) Errors encountered: include/linux/ns/ns_common_types.h:117:3: warning: declaration does not declare anything [-Wmissing-declarations] 117 | struct ns_tree; | ^~~~~~~~~~~~~~ In file included from /virtual/main.c:5: In file included from include/linux/pid_namespace.h:11: include/linux/ns_common.h:25:23: error: no member named 'ns_id' in 'struct ns_common' 25 | VFS_WARN_ON_ONCE(ns->ns_id == 0); | ~~ ^ include/linux/ns_common.h:26:13: error: no member named 'ns_id' in 'struct ns_common' 26 | return ns->ns_id <= NS_LAST_INIT_ID; | ~~ ^ include/linux/ns_common.h:60:26: error: no member named '__ns_ref_active' in 'struct ns_common' 60 | return atomic_read(&ns->__ns_ref_active); This patch fixes the issue globally by turning on microsoft extensions flags. These flags have already been in the linux kernel. [2] [1] torvalds/linux@a657bc8 [2] torvalds/linux@c4781dc Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com> Fixes: iovisor#5488
1 parent 88c4e54 commit c3f35ec

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/cc/frontends/clang/kbuild_helper.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ int KBuildHelper::get_flags(const char *uname_machine, vector<string> *cflags) {
137137
cflags->push_back("-Wno-pointer-sign");
138138
cflags->push_back("-fno-stack-protector");
139139

140+
// Align with Linux kernel's -fms-extensions flags adopted since v6.19
141+
cflags->push_back("-fms-extensions");
142+
cflags->push_back("-Wno-microsoft-anon-tag");
143+
140144
/*
141145
* kernel is usually build with gcc and the kernel devel header
142146
* reflects that fact. However we build with clang and this must be

0 commit comments

Comments
 (0)