maintains the same semantics as Kernel’s module build
and compatible with Kconfiglib implementation.
The problem of kconfiglib not being able to use tri-states is this:
linux is here torvalds/linux@6dd85ff
The module option is extracted from one of the triate three states into a MODULE keyword.
Kconfiglib supports the default implementation of module to be MODULE for compatibility with the linux kernel, and triate degenerates into bool two states
Refer to this code: 061e71f7d7/kconfiglib.py (L4274-L4284)
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
change the extra library from a file to an import target;
this will avoid differences in the handling of static libraries
between different versions of cmake and different platforms.
after unifying as a target, extra libraries can be
handled as the same as other compiled libraries
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
fix SIM start crash on Ubuntu22,
becase the previous CMake linker script has missing handling of
C++ global constructor sections in the new Glibc version on ubuntu22
it will cause a prior c++ constructor call error:
0x00000000400317f6 in nxsched_get_stackinfo (pid=0, stackinfo=0x7fffffffdbc0) at /media/liujinye/ssd/vela-dev/nuttx/sched/sched/sched_get_stackinfo.c:101
0x000000004002de0d in tls_get_info () at /media/liujinye/ssd/vela-dev/nuttx/libs/libc/tls/tls_getinfo.c:61
0x000000004002ddc8 in task_get_info () at /media/liujinye/ssd/vela-dev/nuttx/libs/libc/tls/task_getinfo.c:50
0x000000004002c74e in atexit_register (type=4, func=0x40044eac <CHelloWorld::~CHelloWorld()>, arg=0x40061418 <g_HelloWorld>, dso=0x40060000)
at /media/liujinye/ssd/vela-dev/nuttx/libs/libc/stdlib/lib_atexit.c:68
0x000000004002ca34 in __cxa_atexit (func=0x40044eac <CHelloWorld::~CHelloWorld()>, arg=0x40061418 <g_HelloWorld>, dso_handle=0x40060000)
at /media/liujinye/ssd/vela-dev/nuttx/libs/libc/stdlib/lib_atexit.c:268
0x000000004004502b in __static_initialization_and_destruction_0 () at /media/liujinye/ssd/vela-dev/apps/examples/helloxx/helloxx_main.cxx:93
0x000000004004503e in _GLOBAL__sub_I_helloxx_main () at /media/liujinye/ssd/vela-dev/apps/examples/helloxx/helloxx_main.cxx:129
0x00007ffff7829ebb in call_init (env=<optimized out>, argv=0x7fffffffdd18, argc=1) at ../csu/libc-start.c:145
__libc_start_main_impl (main=0x40004dc8 <main>, argc=1, argv=0x7fffffffdd18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffdd08) at ../csu/libc-start.c:379
0x0000000040004285 in _start ()
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
There are 2 CMake compile errors during the protected build mode. One is forget to add library for nuttx_user, another is the wrong macro used when compile wqueue.
Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
Currently concerns only arm.
tools/ci/testlist/msys2.dat:
At the moment I only added the board nucleo-l152re:nsh
.github/workflows/build.yml:
Enabled cmake for msys2
FetchContent_Populate is depracated starting from CMake
3.30. Setting this policy to OLD allows clean CMake builds
for configurations that rely on CMake fetch content feature.
Signed-off-by: Daniel Jasinski <jasinskidaniel95szcz@gmail.com>
Cmake build provide absolute paths to compile files. If __FILE__
macros are used in the source code(ASSERT), the binary will be occupied
by many invalid paths.
This saves some memory, stops leaking user locations in binaries, makes
failure logs more deterministic and most importantly makes builds more
deterministic.
Debuggers usually have a path mapping feature to ensure the files are
still found.
Test config sabre-6quad/citest:
Before:
$ size build/nuttx
text data bss dec hex filename
279309 908 13652 293869 47bed build/nuttx
After:
$ size build/nuttx
text data bss dec hex filename
269313 908 13652 283873 454e1 build/nuttx
Signed-off-by: chao an <anchao@lixiang.com>
The link script of NuttX Simulator is generated through compilation
options. This PR will support configure special data sections in
kconfig to meet the support of 3rd party applications.
we need to follow the syntax of linker script. In 3rd-party applications, some data will be labeled as section:
| a.c:
| struct task_s a __attribute__((section(".data.custom.taska")));
| b.c:
| struct task_s b __attribute__((section(".data.custom.taskb")));
Data of the same type struct can be placed in a fixed location to reduce the overhead caused by searching:
| .data :
| {
| _custom_data_table_start = .;
| KEEP(*(.data.custom.*))
| _custom_data_table_end = .;
| }
Such section declare can be configured via Kconfig in the PR:
| CONFIG_SIM_CUSTOM_DATA_SECTION=" .data : { _custom_data_table_start = .; KEEP(*(.data.custom.*)) _custom_data_table_end = .; } "
Signed-off-by: chao an <anchao@lixiang.com>
when repeatedly enabling and disabling string-controlled configurations,
the generated toolchain configuration may be incorrect.
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
Because `set_source_files_properties` in cmake will overwrite the properties instead of appending them.
This module implements addition and deletion by
first `getting_source_file_property` and then `set_source_files_properties`
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
when declaring the target to be `nuttx`,create an empty allsyms source file for it;
when the target is declared as something else,the link behavior of the `nuttx` target is cloned
and added to actually generate the allsyms file.
finally use allsyms_nuttx to overwrite the already generated nuttx
and regenerate binary outputs
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
adjust link options for userspace elf
specify system libs and apps lib to only link with nuttx target in flat build mode
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
CMAKE_CXX_STANDARD is repeatedly defined in the two files, nuttx/CMakeLists(14) and libs/libxx/libcxx.cmake(17), and is defined to different values. Matter needs to use the new features(std::is_signed_v) of c++17,so delete the definition in nuttx/CMakeLists and retain the definition in libs/libxx/libcxx.cmake.
Signed-off-by: zhangjun21 <zhangjun21@xiaomi.com>
Currently only FLAT mode development can enjoy cmake build system. This
patch tries to add initial kernel mode support. It can build NuttX kernel
and libproxies.a, the latter will be further checked though.
This can already help to build an AMP remote node image as it can share
userland apps living in the AMP master node.
Major changes:
- in top folder:
- CMakeLists.txt adjust for KERNEL mode, separate from PROTECTED mode.
- in `syscall`:
- CMakeLists.txt add mksyscall target for stubs/proxies generation
- in `syscall/stubs`:
- CMakeLists.txt use dependency to mksyscall
- in `syscall/proxies`:
- CMakeLists.txt use dependency to mksyscall
- in `arch`:
- CMakeLists.txt separate KERNEL from PROTECTED mode.
- in `arch/risc-v/src`:
- CMakeLists.txt separate from PROTECTED mode, add sub folders.
- in `arch/risc-v/common`:
- CMakeLists.txt add sources and sub-folders for KERNEL mode.
- in `arch/risc-v/k230`:
- CMakeLists.txt add sources for KERNEL mode.
- in `boards/risc-v/k230/canmv230/src`:
- CMakeLists.txt adjust k230 specific scripts for kernel mode.
New additions:
- in `arch/risc-v/src/nuttsbi/` add CMakeLists.txt
- in `arch/risc-v/src/common/supervisor/` add CMakeLists.txt
Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
Define `NUTTX_DEFCONFIG` and `NUTTX_BOARD_ABS_DIR` instead of `BOARD_CONFIG`
when reconfiguring a custom configuration,
because ${BOARD_CONFIG} uses a relative path,
it will cause the following error:
CMake Error at CMakeLists.txt:134 (message)
No config file found at
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
Otherwise, it produces a lot of warnings like:
```
ld: warning: object file (/Users/yamamoto/git/nuttx/nuttx/build/libs/libxx/liblibcxx.a(d2s.cpp.o)) was built for newer macOS version (12.7) than being linked (12.0)
```
The mach-o support of objcopy is fragile at best and often results
in a broken output. It's better not to rely on it.
This matches what the non-cmake version does.
otherwise NUTTX_COMMON_DIR is empty if CONFIG_ARCH_BOARD_COMMON is set from menuconfig
Co-authored-by: hartmannathan <59230071+hartmannathan@users.noreply.github.com>
`nuttx_export_header` for applications global header file export
`nuttx_add_dependencies` is the wrapper to use import
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
------------------
How to test
From within nuttx/. Configure:
cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja
(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
--------------------------
2. cmake/build: reformat the cmake style by cmake-format
https://github.com/cheshirekow/cmake_format
$ pip install cmakelang
$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done
Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>