How to cross compile with the ADSP Sharc Toolchain

Hello

I would like to cross compile a static library using the ADSP Sharc Toolchain

Host platform: Windows
Cmake version: 3.29
Ninja version: 1.11.1
Analog Device CrossCore version: 2.12.0

I’ve managed to generate a static library with success but encountered a minor issue.

The generated static library hax suffix .a , instead of the .dlb suffix normally expected by the Sharc linker. The library is still functional though.

Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.29)
project(myproject LANGUAGES C)
add_library(titi STATIC)
target_sources(titi PRIVATE titi.c)

Here are the options I passed to cmake

cd build
cmake -G Ninja -DCMAKE_SYSTEM_NAME=ADSP -DCMAKE_SYSTEM_PROCESSOR=21565 ..

The ninja invocation works fine.

Here are my questions:

  • do you confirm my CMakeLists.txt and options passed to cmake are correct ?
  • is there a correct way to specify .dlb suffix, aside from setting CMAKE_STATIC_LIBRARY_SUFFIX_C ?

I updated my CMakeLists.txt to customize the .dlb suffix. Not sure it’s very elegant or correct though.

cmake_minimum_required(VERSION 3.27)

if(CMAKE_SYSTEM_NAME MATCHES "ADSP")
    set(CMAKE_STATIC_LIBRARY_SUFFIX_C .dlb)
endif()

project(myproject LANGUAGES C)
add_library(titi STATIC)
target_sources(titi PRIVATE titi.c)

I think you need to set the suffix after languages have been enabled. If you set it beforehand (such as in a toolchain file), CMake’s platform files may overwrite it. I last mentioned this in this comment in CMake’s issue tracker. That has links to related discussion on the topic.

1 Like