Skip to content

Thread Support  #29

Description

@IronFist16

Hello All,

I was trying to test threading with this SDK, looks like I'm not able to wrap my head over the proper library and setup in the CMakeLists.txt file. Can anyone help me please?

The below is an example of my CMakeLists.txt file, which compiles fine except for the below warnings:


cmake_minimum_required(VERSION 3.15)

include(proj.conf)

find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)

find_package(Threads REQUIRED)

if(Threads_FOUND)
    message(STATUS "Thread Library found ${CMAKE_THREAD_LIBS_INIT}")
    if(CMAKE_USE_PTHREADS_INIT
    target_compile_options(app PRIVATE -pthread)
    target_link_options(app PRIVATE -pthread)
    message(STATUS "Pthread included !")
    else()
    message(WARNING "pthread not included !")
    endif()
endif()

target_link_libraries(app ${CMAKE_THREAD_LIBS_INIT})

sdk_set_main_file(main.c)

project(helloworld)

while I do #include <pthread.h> , I can see the below warning only message during compilation, which end successfully:

/usr/bin/toolchain_gcc_t-head_linux/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: CMakeFiles/helloworld_bl808_m0.elf.dir/main.c.o: in function `main':
/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/examples/helloworld/main.c:117: warning: pthread_create is not implemented and will always fail
/usr/bin/toolchain_gcc_t-head_linux/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: 
/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/examples/helloworld/main.c:122: warning: pthread_join is not implemented and will always fail

Later on, while searching for the reasons, I understood for that to work I will need to compile the code with Linux tool chain instead.

1-Is this correct?

Eventually, I downloaded the toolchain and setup the env. var then upon compilation, I face another issues:

/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/components/libc/newlib/port_memory.c:2:10: fatal error: reent.h: No such file or directory
    2 | #include <reent.h>
      |          ^~~~~~~~~

/home/ironfist/Documents/Robot/Docs/M1S_Dock/bl808_linux/bouffalo_sdk/components/libc/./sys/types.h:20:10: fatal error: _ansi.h: No such file or directory
   20 | #include <_ansi.h>
      |          ^~~~~~~~~

Which I assume it's due to the difference between the elf (Newlib) & linux (libc) tool chain.

2 - Is this also correct?

Probably I missed updating configuration in the make files or compilation flags,

3-Can you please explain to me how to properly migrate into the linuxtool chain in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions