diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt index 74103db4118..180d7090a7b 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 f443ecb0b39..4919a6204f9 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 5e01626c0e2..2be54de5a68 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 92224701f9b..964771d907c 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");