NCS v3.0.2: Zephyr's fuzzing sample not working

Hello, I have discovered that Zephyr's fuzzing sample: https://docs.zephyrproject.org/latest/samples/subsys/debug/fuzz/README.html is not working with NCS v3.0.2.

Reproduction path:

(btp2_ncs) t14@ThinkPad ~/Desktop/GCX/BT_PLATFORM/btplatform2/test $ export ZEPHYR_TOOLCHAIN_VARIANT=llvm

(btp2_ncs) t14@ThinkPad ~/Desktop/GCX/BT_PLATFORM/btplatform2/test $ west build --no-sysbuild -b native_sim/native/64 zephyr/samples/subsys/debug/fuzz
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/samples/subsys/debug/fuzz
-- CMake version: 3.30.2
-- Found Python3: /home/t14/.virtualenvs/btp2_ncs/bin/python (found suitable version "3.12.3", minimum required is "3.10") found components: Interpreter
-- Cache files will be written to: /home/t14/.cache/zephyr
-- Zephyr version: 4.0.99 (/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr)
-- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
-- Board: native_sim, qualifiers: native/64
-- Found host-tools: zephyr 0.17.0 (/home/t14/zephyr-sdk-0.17.0)
-- Found toolchain: llvm (clang/ld)
-- Found Dtc: /home/t14/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/boards/native/native_sim/native_sim_64.dts
-- Generated zephyr.dts: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.dts
-- Generated pickled edt: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/edt.pickle
-- Generated zephyr.dts: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/dts.cmake
Parsing /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/samples/subsys/debug/fuzz/Kconfig
Loaded configuration '/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/boards/native/native_sim/native_sim_64_defconfig'
Merged configuration '/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/samples/subsys/debug/fuzz/prj.conf'
Configuration saved to '/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/.config'
Kconfig header saved to '/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/include/generated/zephyr/autoconf.h'
-- Found LlvmLld: /usr/lib/llvm-14/bin/ld.lld (found suitable version "14.0.6", minimum required is "14.0.0")
-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is GNU 13.3.0
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /home/t14/.local/bin/clang
-- Configuring done (5.1s)
-- Generating done (0.1s)
-- Build files have been written to: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build
-- west build: building application
[1/96] Preparing syscall dependency handling

[5/96] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr), build: v4.0.99-ncs1-2
[94/96] Linking C executable zephyr/zephyr.elf
Generating files from /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.elf for board: native_sim
[95/96] Building native simulator runner, and linking final executable
FAILED: zephyr/CMakeFiles/native_runner_executable zephyr/zephyr.exe /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/CMakeFiles/native_runner_executable /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.exe
cd /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr && /usr/bin/make -f /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/scripts/native_simulator/Makefile all --warn-undefined-variables -r NSI_CONFIG_FILE=/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/NSI/nsi_config
/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/NSI/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.elf.loc_cpusw.o: file not recognized: file format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/zephyr/scripts/native_simulator/Makefile:131: /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build/zephyr/zephyr.exe] Error 1
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/t14/Desktop/GCX/BT_PLATFORM/btplatform2/test/build

I'd like to mention it is still working with mainline Zephyr.

BR,

Jakub

Parents Reply Children
  • It haven't worked either:

    $west build -t run -b native_sim/native/64 zephyr/samples/subsys/debug/fuzz -- -DCONFIG_LLVM_USE_LD=y
    
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: /home/t14/.virtualenvs/btp2_ncs/bin/python (found suitable version "3.12.3", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: /home/t14/.cache/zephyr
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: native_sim, qualifiers: native/64
    Parsing /home/t14/Desktop/GCX/prj/zephyr/share/sysbuild/Kconfig
    Loaded configuration '/home/t14/Desktop/GCX/prj/build/_sysbuild/empty.conf'
    Merged configuration '/home/t14/Desktop/GCX/prj/build/_sysbuild/empty.conf'
    Configuration saved to '/home/t14/Desktop/GCX/prj/build/zephyr/.config'
    Kconfig header saved to '/home/t14/Desktop/GCX/prj/build/_sysbuild/autoconf.h'
    --
       **************************
       * Running CMake for fuzz *
       **************************
    
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/t14/Desktop/GCX/prj/zephyr/samples/subsys/debug/fuzz
    -- CMake version: 3.30.2
    -- Found Python3: /home/t14/.virtualenvs/btp2_ncs/bin/python (found suitable version "3.12.3", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: /home/t14/.cache/zephyr
    -- Zephyr version: 4.0.99 (/home/t14/Desktop/GCX/prj/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: native_sim, qualifiers: native/64
    -- Found host-tools: zephyr 0.17.0 (/home/t14/zephyr-sdk-0.17.0)
    -- Found toolchain: llvm (clang/ld)
    -- Found Dtc: /home/t14/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
    -- Found BOARD.dts: /home/t14/Desktop/GCX/prj/zephyr/boards/native/native_sim/native_sim_64.dts
    -- Generated zephyr.dts: /home/t14/Desktop/GCX/prj/build/fuzz/zephyr/zephyr.dts
    -- Generated pickled edt: /home/t14/Desktop/GCX/prj/build/fuzz/zephyr/edt.pickle
    -- Generated zephyr.dts: /home/t14/Desktop/GCX/prj/build/fuzz/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/t14/Desktop/GCX/prj/build/fuzz/zephyr/include/generated/zephyr/devicetree_generated.h
    -- Including generated dts.cmake file: /home/t14/Desktop/GCX/prj/build/fuzz/zephyr/dts.cmake
    Parsing /home/t14/Desktop/GCX/prj/zephyr/samples/subsys/debug/fuzz/Kconfig
    Loaded configuration '/home/t14/Desktop/GCX/prj/zephyr/boards/native/native_sim/native_sim_64_defconfig'
    Merged configuration '/home/t14/Desktop/GCX/prj/zephyr/samples/subsys/debug/fuzz/prj.conf'
    Merged configuration '/home/t14/Desktop/GCX/prj/build/fuzz/zephyr/misc/generated/extra_kconfig_options.conf'
    Merged configuration '/home/t14/Desktop/GCX/prj/build/fuzz/zephyr/.config.sysbuild'
    Configuration saved to '/home/t14/Desktop/GCX/prj/build/fuzz/zephyr/.config'
    Kconfig header saved to '/home/t14/Desktop/GCX/prj/build/fuzz/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: /usr/bin/ld.bfd (found version "2.42")
    -- The C compiler identification is Clang 14.0.6
    -- The CXX compiler identification is GNU 13.3.0
    -- The ASM compiler identification is Clang with GNU-like command-line
    -- Found assembler: /home/t14/.local/bin/clang
    -- Configuring done (12.4s)
    -- Generating done (0.2s)
    -- Build files have been written to: /home/t14/Desktop/GCX/prj/build/fuzz
    -- Configuring done (15.2s)
    -- Generating done (0.0s)
    -- Build files have been written to: /home/t14/Desktop/GCX/prj/build
    -- west build: running target run
    ninja: error: unknown target 'run', did you mean 'fuzz'?
    FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/t14/Desktop/GCX/prj/build --target run

  • Actually calling the build command with --no-sysbuild fixed the problem after adding CONFIG_LLVM_USE_LD=y
    . Thanks a lot !

Related