slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

undefined reference to `rust_eh_personality' #4568

Closed MrMarteng closed 7 months ago

MrMarteng commented 7 months ago

I am getting a build error when compiling slint

[build]    Compiling slint-cpp v1.4.1 (/workspaces/2401_fs-picocore-imx8mm/build/_deps/slint-src/api/cpp)
[build]     Finished dev [unoptimized + debuginfo] target(s) in 2m 05s
[build] Copying byproducts `libslint_cpp.a` to /workspaces/2401_fs-picocore-imx8mm/build/_deps/slint-build
[build] [ 99%] Built target _cargo-build_slint-cpp
[build] [ 99%] Built target cargo-build_slint-cpp
[build] [100%] Generating helloworld_ui.h
[build] Consolidate compiler generated dependencies of target HelloSlint
[build] [100%] Building CXX object HelloSlint/CMakeFiles/HelloSlint.dir/main.cpp.o
[build] [100%] Linking CXX executable HelloSlint
[build] /usr/local/arm/fs-toolchain-11.2-armv8ahf/lib/gcc/aarch64-fs-linux-gnu/11.2.0/../../../../aarch64-fs-linux-gnu/bin/ld: ../_deps/slint-build/libslint_cpp.a(alloc-55c809a1b2d51fd2.alloc.15e63dbc03d82328-cgu.0.rcgu.o):(.data.DW.ref.rust_eh_personality[DW.ref.rust_eh_personality]+0x0): undefined reference to `rust_eh_personality'
[build] collect2: error: ld returned 1 exit status

Build target is a Cortex-A53 (aarch64) located on the SOM "PicoCore IMX8MM" from www.fs-net.de. FS is providing an according cross-compiler (aarch64-fs-linux-gnu-gcc). rustc V1.75 is installed:

dev@9dac07903b26:/workspaces/2401_fs-picocore-imx8mm$ aarch64-fs-linux-gnu-c++ --version 
aarch64-fs-linux-gnu-c++ (for F+S boards and modules) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

dev@9dac07903b26:/workspaces/2401_fs-picocore-imx8mm$ rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)

dev@9dac07903b26:/workspaces/2401_fs-picocore-imx8mm$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Host system is a Ubuntu Linux (arm64), running in a WSL2 docker environment:

Linux 9dac07903b26 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

For simplicity I added all SLINT definitions in the cmake file directly. Here is the full project configuraiton:

cmake_minimum_required(VERSION 3.21)
project(HelloSlint
    LANGUAGES CXX)

# Enable cross-compilation
set(Rust_CARGO_TARGET aarch64-unknown-linux-gnu)
set(Rust_CARGO_TARGET_ARCH aarch64)

# For Embedded targets
set(SLINT_FEATURE_FREESTANDING ON)
set(BUILD_SHARED_LIBS OFF)
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
set(DEFAULT_SLINT_EMBED_RESOURCES embed-for-software-renderer)

# enable wayland
set(SLINT_FEATURE_BACKEND_WINIT ON)
set(SLINT_FEATURE_BACKEND_WINIT_WAYLAND OFF)
set(SLINT_FEATURE_BACKEND_WINIT_QT OFF)

set(SLINT_BACKEND winit-skia-software)

# featch and guild Slint pacakge
include(FetchContent)
FetchContent_Declare(
    Slint
    GIT_REPOSITORY https://github.com/slint-ui/slint.git
    # `release/1` will auto-upgrade to the latest Slint >= 1.0.0 and < 2.0.0
    # `release/1.0` will auto-upgrade to the latest Slint >= 1.0.0 and < 1.1.0
    GIT_TAG release/1
    SOURCE_SUBDIR api/cpp
)
FetchContent_MakeAvailable(Slint)

add_executable(${PROJECT_NAME} main.cpp)
slint_target_sources(${PROJECT_NAME} helloworld_ui.slint)
target_link_libraries(${PROJECT_NAME} PRIVATE Slint::Slint)

The unresolved error only appears when trying to compile slint into the application (SLINT_FEATURE_FREESTANDING=ON)

Any idea what is causing this issue?

tronical commented 7 months ago

Hi Martin! Hah, I was just building Slint with Yocto for the imx8 board we have from you (using fsimx8mp-Y2023.09). You're targeting a Linux system, so you should not need SLINT_FEATURE_FREESTANDING=ON. Is there a particular reason for enabling it?

BTW, feel free to pop into our chat at https://chat.slint.dev/ - I had a few questions regarding your Yocto setup and am happy to offer help in exchange :)

ogoffart commented 7 months ago

SLINT_FEATURE_FREESTANDING is not compatible with SLINT_FEATURE_BACKEND_WINIT, but normally winit shouldn't be build if one enable the SLINT_FEATURE_FREESTANDING.

Also SLINT_BACKEND is not a cmake variable, and the skia renderer is not enabled by default and also not compatible with SLINT_FEATURE_FREESTANDING)

tronical commented 7 months ago

Tagging this as needs-info as it's unclear what the desired use of SLINT_FEATURE_FREESTANDING=ON is in a Linux target environment - perhaps we should throw an error if that's configured?