zephyr-rust icon indicating copy to clipboard operation
zephyr-rust copied to clipboard

Build for native posix fails

Open PwnVerse opened this issue 1 year ago • 1 comments

There seems to be an issue with how syscalls are being handled in the gen_syscalls.py.

Here is the compilation log, kindly let me know if there's anything obvious I'm missing here -

 west build -p auto -b native_posix tests/rust                                        

-- west build: generating a build system
CMake Warning at /home/ritvik/zephyrproject/zephyr/cmake/app/boilerplate.cmake:20 (message):
  Loading of Zephyr boilerplate.cmake directly is deprecated, please use
  'find_package(Zephyr)'
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)


Loading Zephyr default modules (Zephyr base).
-- Application: /home/ritvik/zephyrproject/zephyr/zephyr-rust/tests/rust
-- CMake version: 3.27.7
-- Found Python3: /usr/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/ritvik/.cache/zephyr
-- Zephyr version: 3.5.0-rc3 (/home/ritvik/zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: native_posix
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.3 (/home/ritvik/zephyr-sdk-0.16.3)
-- Found toolchain: host (gcc/ld)
-- Found Dtc: /home/ritvik/zephyr-sdk-0.16.3/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/ritvik/zephyrproject/zephyr/boards/posix/native_posix/native_posix.dts
-- Generated zephyr.dts: /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/dts.cmake

warning: Deprecated symbol CPLUSPLUS is enabled.

Parsing /home/ritvik/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/ritvik/zephyrproject/zephyr/boards/posix/native_posix/native_posix_defconfig'
Merged configuration '/home/ritvik/zephyrproject/zephyr/zephyr-rust/tests/rust/prj.conf'
Configuration saved to '/home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/.config'
Kconfig header saved to '/home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /usr/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/gcc
Rust  target: i686-unknown-zephyr
Clang target: i686-unknown-linux-gnu
-- Configuring done (3.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ritvik/zephyrproject/zephyr/zephyr-rust/build
-- west build: building application
[1/120] Preparing syscall dependency handling

[3/120] Generating include/generated/version.h
-- Zephyr version: 3.5.0-rc3 (/home/ritvik/zephyrproject/zephyr), build: v3.5.0-rc3-5-g90b9809c6f55
[99/120] Building C object zephyr/subsys/testsuite/ztest/CMakeFiles/subsys__testsuite__ztest.dir/src/ztest.c.obj
/home/ritvik/zephyrproject/zephyr/subsys/testsuite/ztest/src/ztest.c: In function ‘test_main’:
/home/ritvik/zephyrproject/zephyr/subsys/testsuite/ztest/src/ztest.c:512:9: warning: ‘ztest_run_registered_test_suites’ is deprecated [-Wdeprecated-declarations]
  512 |         ztest_run_registered_test_suites(NULL);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ritvik/zephyrproject/zephyr/subsys/testsuite/ztest/src/ztest.c:463:5: note: declared here
  463 | int ztest_run_registered_test_suites(const void *state)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ritvik/zephyrproject/zephyr/subsys/testsuite/ztest/src/ztest.c:513:9: warning: ‘ztest_verify_all_registered_test_suites_ran’ is deprecated [-Wdeprecated-declarations]
  513 |         ztest_verify_all_registered_test_suites_ran();
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ritvik/zephyrproject/zephyr/subsys/testsuite/ztest/src/ztest.c:493:6: note: declared here
  493 | void ztest_verify_all_registered_test_suites_ran(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[105/120] Generating ../../zephyr/include/generated/all_syscalls.h, ../../zephyr/include/generated/syscall_thunks.c
FAILED: zephyr/include/generated/all_syscalls.h zephyr/include/generated/syscall_thunks.c /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/all_syscalls.h /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/syscall_thunks.c 
cd /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/modules/zephyr-rust && /usr/bin/python3 /home/ritvik/zephyrproject/zephyr/zephyr-rust/scripts/gen_syscalls.py --json-file /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/misc/generated/syscalls.json --thunks /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/syscall_thunks.c --all-syscalls /home/ritvik/zephyrproject/zephyr/zephyr-rust/build/zephyr/include/generated/all_syscalls.h
Traceback (most recent call last):
  File "/home/ritvik/zephyrproject/zephyr/zephyr-rust/scripts/gen_syscalls.py", line 183, in <module>
    main()
  File "/home/ritvik/zephyrproject/zephyr/zephyr-rust/scripts/gen_syscalls.py", line 150, in main
    for match_group, fn in syscalls:
ValueError: too many values to unpack (expected 2)
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/ritvik/zephyrproject/zephyr/zephyr-rust/build

PwnVerse avatar Oct 14 '23 16:10 PwnVerse

Stick to a Zephyr release. 3.4 is known to work.

This commit added a field to the generated syscalls.json which is the current error. https://github.com/zephyrproject-rtos/zephyr/commit/80e78208e6cda603c9c909e934fbdf49d23c181e

I tried to quickly get past that error and got other errors related to multiple definitions of posix types like pthread_t and 'sys/timespec.h' file not found. So it needs more investigation.

I'll leave this open for 3.5 support.

diff --git a/scripts/gen_syscalls.py b/scripts/gen_syscalls.py
index 90c9dea..4885643 100755
--- a/scripts/gen_syscalls.py
+++ b/scripts/gen_syscalls.py
@@ -147,8 +147,10 @@ def main():
     whitelist = set(["kernel.h", "kobject.h", "device.h", "uart.h", "mutex.h", "errno_private.h", "eeprom.h", "time.h"])
     includes = ["kernel.h", "device.h", "drivers/uart.h", "sys/mutex.h", "sys/errno_private.h", "drivers/eeprom.h", "posix/time.h"]
 
-    for match_group, fn in syscalls:
-        if fn not in whitelist:
+    for match_group, fn, *rest in syscalls:
+        # Zephyr > 3.4 has a 3rd field to supress individual calls
+        to_emit = rest[0] if rest else True
+        if fn not in whitelist or not to_emit:
             continue
         include = "syscalls/%s" % fn
         invocation, declaration = analyze_fn(match_group)

tylerwhall avatar Oct 15 '23 23:10 tylerwhall