This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 2631d3e59 testing/ostest: build the perf test only where it can link
2631d3e59 is described below
commit 2631d3e59add05e4099ff1df7e6b0f20d0b4a979
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Jul 29 14:04:14 2026 +0200
testing/ostest: build the perf test only where it can link
perf_gettime() and perf_getfreq() are kernel functions, defined in
sched/clock/clock_perf.c. Neither appears in syscall.csv, and libc supplies
only perf_gettime(), under CONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS. So a
protected or kernel build cannot resolve either of them from user space:
ostest/perf_gettime.c:91: undefined reference to `perf_gettime'
ostest/perf_gettime.c:184: undefined reference to `perf_getfreq'
make[1]: *** [nuttx_user.elf] Error 1
The call in user_main() is guarded by CONFIG_ARCH_PERF_EVENTS &&
!CONFIG_ARCH_PERF_EVENTS_USER_ACCESS -- which is exactly the case where the
symbols are kernel-only -- so every such configuration fails to link.
mps3-an547:knsh is one: it sets CONFIG_SCHED_IRQMONITOR, which makes
ARCH_PERF_EVENTS default y. mps2-an521:knsh escapes only because it sets
neither monitor, leaving ARCH_PERF_EVENTS off, so the call compiles out and
the archive member is never pulled in.
Require CONFIG_BUILD_FLAT, where ostest links against the kernel's own copy.
No configuration that runs the test today stops running it.
Signed-off-by: Marco Casaroli <[email protected]>
Assisted-by: Claude Opus 5 (1M context) <[email protected]>
---
testing/ostest/CMakeLists.txt | 5 ++++-
testing/ostest/Makefile | 5 +++++
testing/ostest/ostest.h | 2 +-
testing/ostest/ostest_main.c | 3 ++-
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt
index 74103db41..180d7090a 100644
--- a/testing/ostest/CMakeLists.txt
+++ b/testing/ostest/CMakeLists.txt
@@ -161,7 +161,10 @@ if(CONFIG_TESTING_OSTEST)
list(APPEND SRCS nxevent.c)
endif()
- if(CONFIG_ARCH_HAVE_PERF_EVENTS)
+ # perf_gettime() and perf_getfreq() live in the kernel and are not system
+ # calls, so only a flat build can reach them from here.
+
+ if(CONFIG_ARCH_HAVE_PERF_EVENTS AND CONFIG_BUILD_FLAT)
list(APPEND SRCS perf_gettime.c)
endif()
diff --git a/testing/ostest/Makefile b/testing/ostest/Makefile
index f443ecb0b..4919a6204 100644
--- a/testing/ostest/Makefile
+++ b/testing/ostest/Makefile
@@ -164,9 +164,14 @@ CSRCS += nxevent.c
endif
endif
+# perf_gettime() and perf_getfreq() live in the kernel and are not system
+# calls, so only a flat build can reach them from here.
+
ifeq ($(CONFIG_ARCH_HAVE_PERF_EVENTS),y)
+ifeq ($(CONFIG_BUILD_FLAT),y)
CSRCS += perf_gettime.c
endif
+endif
ifeq ($(CONFIG_BUILD_FLAT),y)
CSRCS += wdog.c spinlock.c
diff --git a/testing/ostest/ostest.h b/testing/ostest/ostest.h
index 5e01626c0..2be54de5a 100644
--- a/testing/ostest/ostest.h
+++ b/testing/ostest/ostest.h
@@ -304,7 +304,7 @@ void spinlock_test(void);
/* perf_gettime.c ***********************************************************/
-#ifdef CONFIG_ARCH_HAVE_PERF_EVENTS
+#if defined(CONFIG_ARCH_HAVE_PERF_EVENTS) && defined(CONFIG_BUILD_FLAT)
void perf_gettime_test(void);
#endif
diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c
index 92224701f..964771d90 100644
--- a/testing/ostest/ostest_main.c
+++ b/testing/ostest/ostest_main.c
@@ -656,7 +656,8 @@ static int user_main(int argc, char *argv[])
check_test_memory_usage();
#endif
-#if defined(CONFIG_ARCH_PERF_EVENTS) &&
!defined(CONFIG_ARCH_PERF_EVENTS_USER_ACCESS)
+#if defined(CONFIG_ARCH_PERF_EVENTS) && \
+ !defined(CONFIG_ARCH_PERF_EVENTS_USER_ACCESS) && defined(CONFIG_BUILD_FLAT)
/* Verify performance event time counter */
printf("\nuser_main: performance event time counter test\n");