Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable custom toolchain cross-compile workflow #1287

Closed
emersonknapp opened this issue Dec 2, 2019 · 4 comments
Closed

Enable custom toolchain cross-compile workflow #1287

emersonknapp opened this issue Dec 2, 2019 · 4 comments
Labels
breaking-change Issue requires a breaking change to remediate. wontfix We have determined that we will not resolve the issue.

Comments

@emersonknapp
Copy link

emersonknapp commented Dec 2, 2019

We use a custom toolchain file to cross-compile projects for a target SBC that has a custom minimal linux distribution. Our compilation uses the Linaro 6.5 compiler, pointed against the corresponding sysroot for cross compilation.

This project doesn't respect the CMAKE_TOOLCHAIN_FILE argument properly.

The target board does not have compilers or headers installed, since it is a production device image.

What platform/OS are you using?

Ubuntu Bionic x86_64 as the host platform
Targeting custom linux distro on aarch64

Which version of the SDK?

Any

What compiler are you using? what version?

Linaro 6.5

What are your CMake arguments?

-DCMAKE_TOOLCHAIN_FILE=$(pwd)/linaro-toolchain.cmake
@KaibaLopez
Copy link
Contributor

Hi @emersonknapp ,
You're correct, the sdk uses TARGET_ARCH as a variable for the os.
But sadly, it would be a breaking change to rename it at this point, so I'm afraid we won't be doing that for the time being.
It'd be up to you to do this kind of customization to the sdk.

@KaibaLopez KaibaLopez added breaking-change Issue requires a breaking change to remediate. wontfix We have determined that we will not resolve the issue. labels Dec 3, 2019
@singku
Copy link
Contributor

singku commented Dec 3, 2019

This project doesn't respect the CMAKE_TOOLCHAIN_FILE argument properly.

Would you mind sharing more details?
CMAKE_TOOLCHAIN_FILE is actually what we used to do cross-platform compilation either for Android or mips linux.

@emersonknapp
Copy link
Author

Hi, I've been trying again but this time it seems to be working... so I feel a little silly!

cmake .. -DCMAKE_TOOLCHAIN_FILE=linaro-toolchain.cmake -DBUILD_ONLY="kinesis" -DENABLE_TESTING=FALSE -DCPP_STANDARD=11

The toolchain file

if("$ENV{TARGET_ARCH}" STREQUAL "" OR
   "$ENV{CROSS_COMPILE}" STREQUAL "" OR
   "$ENV{SYSROOT}" STREQUAL "" OR
   "$ENV{ROS2_INSTALL_PATH}" STREQUAL "" 
)
    message(FATAL_ERROR "Target environment variables not defined")
endif()

set(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER $ENV{CROSS_COMPILE}gcc)
set(CMAKE_CXX_COMPILER $ENV{CROSS_COMPILE}g++)

set(CMAKE_SYSROOT $ENV{SYSROOT})
set(CMAKE_FIND_ROOT_PATH $ENV{ROS2_INSTALL_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(THREADS_PTHREAD_ARG "0" CACHE STRING "Result from TRY_RUN" FORCE)

I realize that's not reproducible without the sysroot or exact cross-compiler version.

So I don't know what I was doing wrong before - I'm going to close this for now since I think I'm ok, the above can be some context.

@singku
Copy link
Contributor

singku commented Dec 3, 2019

Glad you figured it out at this stage, feel free to leave more comments if you have further problems.
Anyway, I just posted an example here #1288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Issue requires a breaking change to remediate. wontfix We have determined that we will not resolve the issue.
Projects
None yet
Development

No branches or pull requests

3 participants