[PATCH] buildrun.cxx: Explicitly define macro KBUILD_MODNAME

wangxuewen 18810879172@163.com
Mon Mar 31 09:29:54 GMT 2025


From: wangxuewen <wangxuewen@kylinos.cn>

After kernel version v6.10-rc1, when the kernel opens CONFIG_MEM_LOLOC_PROFILING and CONFIG_CODE_TAGGING,
systemtap execution will report the following error:
[root@localhost systemtap]# /usr/bin/stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
Pass 1: parsed user script and 471 library scripts using 149048virt/106604res/10348shr/96480data kb, in 190usr/20sys/212real ms.
Pass 2: analyzed script: 1 probe, 1 function, 5 embeds, 0 globals using 415244virt/375280res/12304shr/362676data kb, in 2020usr/320sys/2343real ms.
Pass 3: translated to C into "/tmp/stapOwheJL/stap_64c6f2ed0f978c27bd67ce514d600b8d_2605_src.c" using 415244virt/376104res/13128shr/362676data kb, in 10usr/0sys/8real ms.
In file included from ./include/linux/percpu.h:5,
                 from ./include/linux/percpu_counter.h:14,
                 from ./include/linux/mm_types.h:21,
                 from ./include/linux/mmzone.h:22,
                 from ./include/linux/gfp.h:7,
                 from /usr/share/systemtap/runtime/linux/runtime_defines.h:20,
                 from /usr/share/systemtap/runtime/runtime_defines.h:8,
                 from /tmp/stapOwheJL/stap_64c6f2ed0f978c27bd67ce514d600b8d_2605_src.c:12:
./include/linux/alloc_tag.h:212:2: error: expected identifier or ‘(’ before ‘{’ token
  212 | ({
......                                                  \
In file included from /usr/share/systemtap/runtime/linux/runtime.h:318,
                 from /usr/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapOwheJL/stap_64c6f2ed0f978c27bd67ce514d600b8d_2605_src.c:21:
/usr/share/systemtap/runtime/linux/alloc.c: In function ‘_stp_alloc_percpu’:
/usr/share/systemtap/runtime/linux/alloc.c:473:34: error: macro "__alloc_percpu" requires 2 arguments, but only 1 given
  473 |         ret = __alloc_percpu(size);
      |                                  ^
./include/linux/percpu.h:143: note: macro "__alloc_percpu" defined here
  143 | #define __alloc_percpu(_size, _align)                                   \
      |
/usr/share/systemtap/runtime/linux/alloc.c:473:15: error: ‘__alloc_percpu’ undeclared (first use in this function); did you mean ‘alloc_percpu’?
  473 |         ret = __alloc_percpu(size);
      |               ^~~~~~~~~~~~~~
      |               alloc_percpu

Signed-off-by: wangxuewen <wangxuewen@kylinos.cn>
---
 buildrun.cxx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/buildrun.cxx b/buildrun.cxx
index 8881cd960..91468209b 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -311,6 +311,7 @@ compile_pass (systemtap_session& s)
   o << "CHECK_BUILD := $(CC) -DMODULE $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) "
     << "$(LINUXINCLUDE) $(_KBUILD_CFLAGS) $(CFLAGS_KERNEL) $(EXTRA_CFLAGS) "
     << "$(CFLAGS) -DKBUILD_BASENAME=\\\"" << s.module_name << "\\\" "
+    << "-DKBUILD_MODNAME=\\\"" << s.module_name << "\\\" "
     << "-Wmissing-prototypes "  // GCC14 prep, PR31288
     << "-Werror" << " -S -o /dev/null -xc " << endl;
   o << "stap_check_build = $(shell " << superverbose << " if $(CHECK_BUILD) $(1) "
-- 
2.25.1



More information about the Systemtap mailing list