arch/posix: Remove support for CONFIG_NATIVE_APPLICATION

CONFIG_NATIVE_APPLICATION, which represents the way in which
native_posix and its kin were built, was deprecated in 4.1 after the
introduction of native_sim and CONFIG_NATIVE_LIBRARY.

We remove support for it now for 4.3.

Let's remove the architecture layer adaptation code and cmake support.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2025-06-30 14:56:19 +02:00 committed by Alberto Escolar
parent 35ba7dbdf7
commit e150ffb92c
5 changed files with 38 additions and 378 deletions

View File

@ -71,53 +71,43 @@ zephyr_compile_options(
${ARCH_FLAG}
)
if (CONFIG_NATIVE_APPLICATION)
zephyr_compile_options(
-fvisibility=hidden
)
# While doing the partial linking of the native library, some symbols will be missing
# which are provided by the native simulator runner
zephyr_ld_options(
-Wl,--unresolved-symbols=ignore-all
)
if (NOT CONFIG_EXTERNAL_LIBC)
# Get the *compiler* include path, that is where the *compiler* provided headers are (not the
# default libC ones). This includes basic headers like stdint.h, stddef.h or float.h
# We expect something like
# /usr/lib/gcc/x86_64-linux-gnu/12/include or /usr/lib/llvm-14/lib/clang/14.0.0/include
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=include/stddef.h
OUTPUT_VARIABLE _OUTPUT
COMMAND_ERROR_IS_FATAL ANY
)
get_filename_component(COMPILER_OWN_INCLUDE_PATH "${_OUTPUT}" DIRECTORY)
# Do not use the C library from this compiler/host,
# but still use the basic compiler headers,
# remove all operating system specific predefined macros,
# no_builtin to avoid the compiler using builtin replacements for std library functions
zephyr_compile_options(
-include ${ZEPHYR_BASE}/arch/posix/include/posix_cheats.h
)
# About this -include directive: The reason to do it this way, is because in this
# manner it is transparent to the application. Otherwise posix_cheats.h needs to
# be included in all the applications' files which define main( ), and in any
# app file which uses any of the APIs renamed in that header.
elseif (CONFIG_NATIVE_LIBRARY)
zephyr_compile_options(
-fvisibility=hidden
-nostdinc
-isystem ${COMPILER_OWN_INCLUDE_PATH}
"SHELL:-include ${ZEPHYR_BASE}/arch/posix/include/undef_system_defines.h"
$<TARGET_PROPERTY:compiler,freestanding>
$<TARGET_PROPERTY:compiler,no_builtin>
)
endif()
# While doing the partial linking of the native library, some symbols will be missing
# which are provided by the native simulator runner
zephyr_ld_options(
-Wl,--unresolved-symbols=ignore-all
)
if (NOT CONFIG_EXTERNAL_LIBC)
# Get the *compiler* include path, that is where the *compiler* provided headers are (not the
# default libC ones). This includes basic headers like stdint.h, stddef.h or float.h
# We expect something like
# /usr/lib/gcc/x86_64-linux-gnu/12/include or /usr/lib/llvm-14/lib/clang/14.0.0/include
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=include/stddef.h
OUTPUT_VARIABLE _OUTPUT
COMMAND_ERROR_IS_FATAL ANY
)
get_filename_component(COMPILER_OWN_INCLUDE_PATH "${_OUTPUT}" DIRECTORY)
# Do not use the C library from this compiler/host,
# but still use the basic compiler headers,
# remove all operating system specific predefined macros,
# no_builtin to avoid the compiler using builtin replacements for std library functions
zephyr_compile_options(
-nostdinc
-isystem ${COMPILER_OWN_INCLUDE_PATH}
"SHELL:-include ${ZEPHYR_BASE}/arch/posix/include/undef_system_defines.h"
$<TARGET_PROPERTY:compiler,freestanding>
$<TARGET_PROPERTY:compiler,no_builtin>
)
endif()
if (CONFIG_COMPILER_WARNINGS_AS_ERRORS)
target_compile_options(native_simulator INTERFACE $<TARGET_PROPERTY:compiler,warnings_as_errors>)
endif()
if (CONFIG_COMPILER_WARNINGS_AS_ERRORS)
target_compile_options(native_simulator INTERFACE $<TARGET_PROPERTY:compiler,warnings_as_errors>)
endif()
if(CONFIG_EXTERNAL_LIBC)
@ -143,13 +133,6 @@ if (CONFIG_GPROF)
target_link_options(native_simulator INTERFACE "-pg")
endif()
if (CONFIG_NATIVE_APPLICATION)
zephyr_ld_options(
-ldl
-pthread
)
endif()
#
# Support for the LLVM Sanitizer toolchain instrumentation frameworks
# (supported by current gcc's as well)
@ -187,9 +170,6 @@ list(JOIN LLVM_SANITIZERS "," LLVM_SANITIZERS_ARG)
if(NOT ${LLVM_SANITIZERS_ARG} STREQUAL "")
set(LLVM_SANITIZERS_ARG "-fsanitize=${LLVM_SANITIZERS_ARG}")
zephyr_compile_options("${LLVM_SANITIZERS_ARG}")
if (CONFIG_NATIVE_APPLICATION)
zephyr_link_libraries("${LLVM_SANITIZERS_ARG}")
endif()
target_link_options(native_simulator INTERFACE ${LLVM_SANITIZERS_ARG})
target_compile_options(native_simulator INTERFACE ${LLVM_SANITIZERS_ARG})

View File

@ -11,29 +11,9 @@ zephyr_library_sources(
)
if(CONFIG_ARCH_POSIX_TRAP_ON_FATAL)
if(CONFIG_NATIVE_LIBRARY)
target_sources(native_simulator INTERFACE fatal_trap.c)
else()
zephyr_library_sources(fatal_trap.c)
endif()
target_sources(native_simulator INTERFACE fatal_trap.c)
endif()
if(CONFIG_NATIVE_APPLICATION)
zephyr_include_directories(
nsi_compat/
${ZEPHYR_BASE}/scripts/native_simulator/common/src/include/
)
zephyr_library_sources(
posix_core_nsi.c
nsi_compat/nsi_compat.c
${ZEPHYR_BASE}/scripts/native_simulator/common/src/nct.c
${ZEPHYR_BASE}/scripts/native_simulator/common/src/nce.c
${ZEPHYR_BASE}/scripts/native_simulator/common/src/nsi_host_trampolines.c
)
zephyr_library_compile_definitions(_POSIX_C_SOURCE=200809L _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)
else()
zephyr_library_sources(
posix_core_nsi.c
)
endif()
zephyr_library_sources(
posix_core_nsi.c
)

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* This module exist to provide a basic compatibility shim
* from Native simulator components into the POSIX architecture.
*
* It is a transitional component, intended to facilitate
* the migration towards the Native simulator.
*/
#include <zephyr/arch/posix/posix_trace.h>
#include <zephyr/toolchain.h>
#include "posix_board_if.h"
void nsi_print_error_and_exit(const char *format, ...)
{
va_list variable_args;
va_start(variable_args, format);
posix_vprint_error_and_exit(format, variable_args);
va_end(variable_args);
}
void nsi_print_warning(const char *format, ...)
{
va_list variable_args;
va_start(variable_args, format);
posix_vprint_warning(format, variable_args);
va_end(variable_args);
}
void nsi_print_trace(const char *format, ...)
{
va_list variable_args;
va_start(variable_args, format);
posix_vprint_trace(format, variable_args);
va_end(variable_args);
}
FUNC_NORETURN void nsi_exit(int exit_code)
{
posix_exit(exit_code);
CODE_UNREACHABLE;
}

View File

@ -1,22 +0,0 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ARCH_POSIX_CORE_NSI_COMPAT_H
#define ARCH_POSIX_CORE_NSI_COMPAT_H
#include "nsi_tracing.h"
#include "nsi_safe_call.h"
#ifdef __cplusplus
extern "C" {
#endif
void nsi_exit(int exit_code);
#ifdef __cplusplus
}
#endif
#endif /* ARCH_POSIX_CORE_NSI_COMPAT_H */

View File

@ -1,228 +0,0 @@
/*
* Copyright (c) 2017 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Header to be able to compile the Zephyr kernel on top of a POSIX OS via the
* POSIX ARCH
*
* This file is only used in the POSIX ARCH, and not in any other architecture
*
* Most users will be normally unaware of this file existence, unless they have
* a link issue in which their POSIX functions calls are reported in errors (as
* zap_<original_func_name>).
* If you do see a link error telling you that zap_something is undefined, it is
* likely that you forgot to select the corresponding Zephyr POSIX API.
*
* This header is included automatically when targeting old POSIX ARCH boards
* based on the CONFIG_NATIVE_APPLICATION architecture.
* It will be included in _all_ Zephyr and application source files
* (it is passed with the option "-include" to the compiler call)
*
* A few files (those which need to access the host OS APIs) will set
* NO_POSIX_CHEATS to avoid including this file. These are typically only
* the POSIX arch private files and some of the drivers meant only for the POSIX
* architecture.
* No file which is meant to run in an embedded target should set
* NO_POSIX_CHEATS
*/
#if !defined(ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CHEATS_H_) && !defined(NO_POSIX_CHEATS)
#define ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CHEATS_H_
/*
* Normally main() is the main entry point of a C executable.
* When compiling using CONFIG_NATIVE_APPLICATION, the Zephyr "application" is not the actual
* entry point of the executable but something the Zephyr OS calls during
* boot.
* Therefore we need to rename this application main something else, so
* we free the function name "main" for its normal purpose
*/
#ifndef main
#define main(...) _posix_zephyr_main(__VA_ARGS__)
#endif
#if defined(__cplusplus)
/* To be able to define main() in C++ code we need to have its prototype
* defined somewhere visibly. Otherwise name mangling will prevent the linker
* from finding it. Zephyr assumes an int main(void) prototype and therefore
* this will be the prototype after renaming:
*/
extern "C" int _posix_zephyr_main(void);
#endif
#ifdef CONFIG_POSIX_API
/*
* The defines below in this header exist only to enable the Zephyr POSIX API
* (include/posix/), and applications using it, to be compiled on top of
* the deprecated CONFIG_NATIVE_APPLICATION targets.
*
* Without this header, both the Zephyr POSIX API functions and the equivalent
* host OS functions would have the same name. This would result in the linker
* not picking the correct ones.
*
* Renaming these functions allows the linker to distinguish
* which calls are meant for the Zephyr POSIX API (zap_something), and
* which are meant for the host OS.
*
* The zap_ prefix should be understood as an attempt to namespace them
* into something which is unlikely to collide with other real functions
* (Any unlikely string would have done)
*
* If you want to link an external library together with Zephyr code for a
* CONFIG_NATIVE_APPLICATION based target, where that external library calls into the Zephyr
* POSIX API, you may want to include this header when compiling that library,
* or rename the calls to match the ones in the defines below.
*/
/* Condition variables */
#define pthread_cond_init(...) zap_pthread_cond_init(__VA_ARGS__)
#define pthread_cond_destroy(...) zap_pthread_cond_destroy(__VA_ARGS__)
#define pthread_cond_signal(...) zap_pthread_cond_signal(__VA_ARGS__)
#define pthread_cond_broadcast(...) zap_pthread_cond_broadcast(__VA_ARGS__)
#define pthread_cond_wait(...) zap_pthread_cond_wait(__VA_ARGS__)
#define pthread_cond_timedwait(...) zap_pthread_cond_timedwait(__VA_ARGS__)
#define pthread_condattr_init(...) zap_pthread_condattr_init(__VA_ARGS__)
#define pthread_condattr_destroy(...) zap_pthread_condattr_destroy(__VA_ARGS__)
/* Semaphore */
#define sem_destroy(...) zap_sem_destroy(__VA_ARGS__)
#define sem_getvalue(...) zap_sem_getvalue(__VA_ARGS__)
#define sem_init(...) zap_sem_init(__VA_ARGS__)
#define sem_post(...) zap_sem_post(__VA_ARGS__)
#define sem_timedwait(...) zap_sem_timedwait(__VA_ARGS__)
#define sem_trywait(...) zap_sem_trywait(__VA_ARGS__)
#define sem_wait(...) zap_sem_wait(__VA_ARGS__)
/* Mutex */
#define pthread_mutex_init(...) zap_pthread_mutex_init(__VA_ARGS__)
#define pthread_mutex_destroy(...) zap_pthread_mutex_destroy(__VA_ARGS__)
#define pthread_mutex_lock(...) zap_pthread_mutex_lock(__VA_ARGS__)
#define pthread_mutex_timedlock(...) zap_pthread_mutex_timedlock(__VA_ARGS__)
#define pthread_mutex_trylock(...) zap_pthread_mutex_trylock(__VA_ARGS__)
#define pthread_mutex_unlock(...) zap_pthread_mutex_unlock(__VA_ARGS__)
#define pthread_mutexattr_init(...) zap_pthread_mutexattr_init(__VA_ARGS__)
#define pthread_mutexattr_destroy(...) \
zap_pthread_mutexattr_destroy(__VA_ARGS__)
/* Barrier */
#define pthread_barrier_wait(...) zap_pthread_barrier_wait(__VA_ARGS__)
#define pthread_barrier_init(...) zap_pthread_barrier_init(__VA_ARGS__)
#define pthread_barrier_destroy(...) zap_pthread_barrier_destroy(__VA_ARGS__)
#define pthread_barrierattr_init(...) zap_pthread_barrierattr_init(__VA_ARGS__)
#define pthread_barrierattr_destroy(...) \
zap_pthread_barrierattr_destroy(__VA_ARGS__)
/* Pthread */
#define pthread_attr_init(...) zap_pthread_attr_init(__VA_ARGS__)
#define pthread_attr_destroy(...) zap_pthread_attr_destroy(__VA_ARGS__)
#define pthread_attr_getschedparam(...) \
zap_pthread_attr_getschedparam(__VA_ARGS__)
#define pthread_attr_getstack(...) zap_pthread_attr_getstack(__VA_ARGS__)
#define pthread_attr_getstacksize(...) \
zap_pthread_attr_getstacksize(__VA_ARGS__)
#define pthread_equal(...) zap_pthread_equal(__VA_ARGS__)
#define pthread_self(...) zap_pthread_self(__VA_ARGS__)
#define pthread_getschedparam(...) zap_pthread_getschedparam(__VA_ARGS__)
#define pthread_once(...) zap_pthread_once(__VA_ARGS__)
#define pthread_exit(...) zap_pthread_exit(__VA_ARGS__)
#define pthread_join(...) zap_pthread_join(__VA_ARGS__)
#define pthread_detach(...) zap_pthread_detach(__VA_ARGS__)
#define pthread_cancel(...) zap_pthread_cancel(__VA_ARGS__)
#define pthread_attr_getdetachstate(...) \
zap_pthread_attr_getdetachstate(__VA_ARGS__)
#define pthread_attr_setdetachstate(...) \
zap_pthread_attr_setdetachstate(__VA_ARGS__)
#define pthread_attr_setschedparam(...) \
zap_pthread_attr_setschedparam(__VA_ARGS__)
#define pthread_attr_setschedpolicy(...)\
zap_pthread_attr_setschedpolicy(__VA_ARGS__)
#define pthread_attr_getschedpolicy(...)\
zap_pthread_attr_getschedpolicy(__VA_ARGS__)
#define pthread_attr_setstack(...) zap_pthread_attr_setstack(__VA_ARGS__)
#define pthread_create(...) zap_pthread_create(__VA_ARGS__)
#define pthread_setcancelstate(...) zap_pthread_setcancelstate(__VA_ARGS__)
#define pthread_setschedparam(...) zap_pthread_setschedparam(__VA_ARGS__)
/* Scheduler */
#define sched_yield(...) zap_sched_yield(__VA_ARGS__)
#define sched_get_priority_min(...) zap_sched_get_priority_min(__VA_ARGS__)
#define sched_get_priority_max(...) zap_sched_get_priority_max(__VA_ARGS__)
#define sched_getparam(...) zap_sched_getparam(__VA_ARGS__)
#define sched_getscheduler(...) zap_sched_getscheduler(__VA_ARGS__)
/* Sleep */
#define sleep(...) zap_sleep(__VA_ARGS__)
#define usleep(...) zap_usleep(__VA_ARGS__)
/* Clock */
#define clock_gettime(...) zap_clock_gettime(__VA_ARGS__)
#define clock_settime(...) zap_clock_settime(__VA_ARGS__)
#define gettimeofday(...) zap_clock_gettimeofday(__VA_ARGS__)
/* Timer */
#define timer_create(...) zap_timer_create(__VA_ARGS__)
#define timer_delete(...) zap_timer_delete(__VA_ARGS__)
#define timer_gettime(...) zap_timer_gettime(__VA_ARGS__)
#define timer_settime(...) zap_timer_settime(__VA_ARGS__)
/* Read/Write lock */
#define pthread_rwlock_destroy(...) zap_pthread_rwlock_destroy(__VA_ARGS__)
#define pthread_rwlock_init(...) zap_pthread_rwlock_init(__VA_ARGS__)
#define pthread_rwlock_rdlock(...) zap_pthread_rwlock_rdlock(__VA_ARGS__)
#define pthread_rwlock_unlock(...) zap_pthread_rwlock_unlock(__VA_ARGS__)
#define pthread_rwlock_wrlock(...) zap_pthread_rwlock_wrlock(__VA_ARGS__)
#define pthread_rwlockattr_init(...) zap_pthread_rwlockattr_init(__VA_ARGS__)
#define pthread_rwlock_timedrdlock(...)\
zap_pthread_rwlock_timedrdlock(__VA_ARGS__)
#define pthread_rwlock_timedwrlock(...)\
zap_pthread_rwlock_timedwrlock(__VA_ARGS__)
#define pthread_rwlock_tryrdlock(...)\
zap_pthread_rwlock_tryrdlock(__VA_ARGS__)
#define pthread_rwlock_trywrlock(...)\
zap_pthread_rwlock_trywrlock(__VA_ARGS__)
#define pthread_rwlockattr_destroy(...)\
zap_pthread_rwlockattr_destroy(__VA_ARGS__)
/* Pthread key */
#define pthread_key_create(...) zap_pthread_key_create(__VA_ARGS__)
#define pthread_key_delete(...) zap_pthread_key_delete(__VA_ARGS__)
#define pthread_setspecific(...) zap_pthread_setspecific(__VA_ARGS__)
#define pthread_getspecific(...) zap_pthread_getspecific(__VA_ARGS__)
/* message queue */
#define mq_open(...) zap_mq_open(__VA_ARGS__)
#define mq_close(...) zap_mq_close(__VA_ARGS__)
#define mq_unlink(...) zap_mq_unlink(__VA_ARGS__)
#define mq_getattr(...) zap_mq_getattr(__VA_ARGS__)
#define mq_receive(...) zap_mq_receive(__VA_ARGS__)
#define mq_send(...) zap_mq_send(__VA_ARGS__)
#define mq_setattr(...) zap_mq_setattr(__VA_ARGS__)
#define mq_timedreceive(...) zap_mq_timedreceive(__VA_ARGS__)
#define mq_timedsend(...) zap_mq_timedsend(__VA_ARGS__)
/* File system */
#define open zap_open
#define close zap_close
#define write zap_write
#define read zap_read
#define lseek zap_lseek
#define opendir zap_opendir
#define closedir zap_closedir
#define readdir zap_readdir
#define rename zap_rename
#define unlink zap_unlink
#define stat zap_stat
#define mkdir zap_mkdir
/* eventfd */
#define eventfd zap_eventfd
#define eventfd_read zap_eventfd_read
#define eventfd_write zap_eventfd_write
#endif /* CONFIG_POSIX_API */
#endif /* ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CHEATS_H_ */