-
Notifications
You must be signed in to change notification settings - Fork 407
Fix CMake Support and Enhance Newlib Targets #1112
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[ | ||
{ | ||
"description": "fixed CMake support for Android and newlib targets.", | ||
"type": "fixed", | ||
"issues": [1110] | ||
}, | ||
{ | ||
"description": "added C++ support for newlib targets.", | ||
"type": "added" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,12 +68,10 @@ main() { | |
retry cargo fetch | ||
# don't use xargo: should have native support just from rustc | ||
rustup toolchain add nightly | ||
"${CROSS[@]}" build --lib --target "${TARGET}" ${CROSS_FLAGS} | ||
cross_build --lib --target "${TARGET}" | ||
popd | ||
|
||
rm -rf "${td}" | ||
|
||
return | ||
fi | ||
|
||
# `cross build` test for the other targets | ||
|
@@ -83,7 +81,7 @@ main() { | |
pushd "${td}" | ||
cargo init --lib --name foo . | ||
retry cargo fetch | ||
"${CROSS[@]}" build --target "${TARGET}" ${CROSS_FLAGS} | ||
cross_build --target "${TARGET}" | ||
popd | ||
|
||
rm -rf "${td}" | ||
|
@@ -94,7 +92,7 @@ main() { | |
# test that linking works | ||
cargo init --bin --name hello . | ||
retry cargo fetch | ||
"${CROSS[@]}" build --target "${TARGET}" ${CROSS_FLAGS} | ||
cross_build --target "${TARGET}" | ||
popd | ||
|
||
rm -rf "${td}" | ||
|
@@ -166,18 +164,32 @@ main() { | |
|
||
fi | ||
|
||
# Test C++ support | ||
# Test C++ support in a no_std context | ||
if (( ${CPP:-0} )); then | ||
td="$(mkcargotemp -d)" | ||
|
||
git clone --depth 1 https://github.com/cross-rs/rust-cpp-accumulate "${td}" | ||
|
||
pushd "${td}" | ||
retry cargo fetch | ||
cross_build --target "${TARGET}" | ||
popd | ||
|
||
rm -rf "${td}" | ||
fi | ||
|
||
# Test C++ support | ||
if (( ${STD:-0} )) && (( ${CPP:-0} )); then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes we have C++ and std support, so we have to make that explicit. |
||
td="$(mkcargotemp -d)" | ||
|
||
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}" | ||
|
||
pushd "${td}" | ||
retry cargo fetch | ||
if (( ${RUN:-0} )); then | ||
cross_run --target "${TARGET}" | ||
else | ||
"${CROSS[@]}" build --target "${TARGET}" ${CROSS_FLAGS} | ||
cross_build --target "${TARGET}" | ||
fi | ||
popd | ||
|
||
|
@@ -193,11 +205,44 @@ main() { | |
cargo init --bin --name hello . | ||
retry cargo fetch | ||
RUSTFLAGS="-C target-feature=-crt-static" \ | ||
"${CROSS[@]}" build --target "${TARGET}" ${CROSS_FLAGS} | ||
cross_build --target "${TARGET}" | ||
popd | ||
|
||
rm -rf "${td}" | ||
fi | ||
|
||
# test cmake support | ||
td="$(mkcargotemp -d)" | ||
|
||
git clone \ | ||
--recursive \ | ||
--depth 1 \ | ||
https://github.com/cross-rs/rust-cmake-hello-world "${td}" | ||
|
||
pushd "${td}" | ||
retry cargo fetch | ||
if [[ "${TARGET}" == "arm-linux-androideabi" ]]; then | ||
# ARMv5te isn't supported anymore by Android, which produces missing | ||
Emilgardis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# symbol errors with re2 like `__libcpp_signed_lock_free`. | ||
cross_run --target "${TARGET}" --features=tryrun | ||
elif (( ${STD:-0} )) && (( ${RUN:-0} )) && (( ${CPP:-0} )); then | ||
cross_run --target "${TARGET}" --features=re2,tryrun | ||
elif (( ${STD:-0} )) && (( ${CPP:-0} )); then | ||
cross_build --target "${TARGET}" --features=re2 | ||
elif (( ${STD:-0} )) && (( ${RUN:-0} )); then | ||
cross_run --target "${TARGET}" --features=tryrun | ||
elif (( ${STD:-0} )); then | ||
cross_build --target "${TARGET}" --features=tryrun | ||
else | ||
cross_build --lib --target "${TARGET}" | ||
fi | ||
popd | ||
|
||
rm -rf "${td}" | ||
} | ||
|
||
cross_build() { | ||
"${CROSS[@]}" build "$@" ${CROSS_FLAGS} | ||
} | ||
|
||
cross_run() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,15 +34,18 @@ RUN /android-system.sh arm64 | |
|
||
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-linux-android- | ||
ENV CROSS_SYSROOT=/android-ndk/sysroot | ||
ENV CROSS_ANDROID_SDK=$ANDROID_SDK | ||
COPY android-symlink.sh / | ||
RUN /android-symlink.sh aarch64 aarch64-linux-android | ||
|
||
COPY android-runner / | ||
COPY android.cmake /opt/toolchain.cmake | ||
|
||
# Libz is distributed in the android ndk, but for some unknown reason it is not | ||
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT | ||
ENV CROSS_TARGET_RUNNER="/android-runner aarch64" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows us to use it both for the cargo runner and for |
||
ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \ | ||
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER="/android-runner aarch64" \ | ||
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER="$CROSS_TARGET_RUNNER" \ | ||
AR_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ar \ | ||
AS_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"as \ | ||
CC_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"gcc \ | ||
|
@@ -56,11 +59,16 @@ ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \ | |
SIZE_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"size \ | ||
STRINGS_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strings \ | ||
STRIP_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strip \ | ||
CMAKE_TOOLCHAIN_FILE_aarch64_linux_android=/opt/toolchain.cmake \ | ||
BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android="--sysroot=$CROSS_SYSROOT" \ | ||
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include"/ \ | ||
RUST_TEST_THREADS=1 \ | ||
HOME=/tmp/ \ | ||
TMPDIR=/tmp/ \ | ||
ANDROID_DATA=/ \ | ||
ANDROID_DNS_MODE=local \ | ||
ANDROID_ROOT=/system | ||
ANDROID_ROOT=/system \ | ||
CROSS_CMAKE_SYSTEM_NAME=Android \ | ||
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
CROSS_CMAKE_CRT=android \ | ||
CROSS_CMAKE_OBJECT_FLAGS="-DANDROID -ffunction-sections -fdata-sections -fPIC" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now want to run the CMake tests as well.