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

Don't use CXXFLAGS when compiling eh_trampoline.cc #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
libcxxrt_freebsd_task:
matrix:
- freebsd_instance:
image_family: freebsd-13-2
image_family: freebsd-13-3
- freebsd_instance:
image_family: freebsd-15-0-snap
- freebsd_instance:
Expand Down
63 changes: 63 additions & 0 deletions .github/scripts/android_test_driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

# This script is run on the emulator to run the tests

# Get list of all binaries in pwd for later iteration (only include binaries)
BINARIES=$(find . -maxdepth 1 -type f ! -name "*.so" ! -name "android_test_driver.sh")

TOTAL=0
PASS=0
SKIP=0
FAIL=0

# Run each binary, measure time and return value (PASS or FAIL). Print stdout and stderr only after a failure
for BINARY in $BINARIES; do
TOTAL=$((TOTAL + 1))

START_TIME=$(date +%s)
# Busybox date does not support %N, so we can't get milliseconds this way
#START_TIME_MS=$((START_TIME * 1000 + $(date +%N) / 1000000))

OUTPUT=$("$BINARY" 2>&1)
EXIT_CODE=$?

END_TIME=$(date +%s)
#END_TIME_MS=$((END_TIME * 1000 + $(date +%N) / 1000000))
#ELAPSED_TIME=$((END_TIME_MS - START_TIME_MS))
ELAPSED_TIME=$((END_TIME - START_TIME))

BINARY_NAME=$(basename "$BINARY")

if [ $EXIT_CODE -eq 0 ]; then
PASS=$((PASS + 1))
echo "PASSED ($EXIT_CODE): $BINARY_NAME (${ELAPSED_TIME}s)"
elif [ $EXIT_CODE -eq 77 ]; then
SKIP=$((SKIP + 1))
echo "SKIPPED: $BINARY_NAME"
else
FAIL=$((FAIL + 1))
echo "FAILED ($EXIT_CODE): $BINARY_NAME (${ELAPSED_TIME}s)"
if [ -z "$OUTPUT" ]; then
echo "No output written to stdout."
else
echo "Output:"
echo "$OUTPUT"
fi
fi
done

if [ $TOTAL -eq 0 ]; then
echo "No tests found. Exiting."
exit 1
fi

PERCENTAGE=$(((PASS + SKIP) * 100 / TOTAL))
echo "$PERCENTAGE% Passed. Total: $TOTAL, Passed: $PASS, Skipped: $SKIP, Failed: $FAIL"
echo "Finished running tests. Exiting."

# Exit with corresponding return value
if [ $FAIL -eq 0 ]; then
exit 0
else
exit 1
fi
63 changes: 63 additions & 0 deletions .github/scripts/android_test_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

main () {
# first argument is the build directory
local BUILD_DIR=$1
# second argument is the android ndk sysroot
local ANDROID_NDK_SYSROOT=$2
# third argument is the target triple
# e.g. arm-linux-androideabi, aarch64-linux-android, x86_64-linux-android
local TARGET_TRIPLE=$3

if [ ! -d "$BUILD_DIR" ]
then
echo "Build directory argument not found"
exit 1
fi
if [ ! -d "$ANDROID_NDK_SYSROOT" ]
then
echo "Android NDK sysroot argument not found"
exit 1
fi
if [ -z "$TARGET_TRIPLE" ]
then
echo "Target triple argument not found"
exit 1
fi

# We need to run the emulator with root permissions
# This is needed to run the tests
adb root

local TEMP_DIR=$(mktemp -d)

# Copy libobjc.so and test binaries to temporary directory
cp $BUILD_DIR/libobjc.so* $TEMP_DIR
cp $BUILD_DIR/Test/* $TEMP_DIR

for file in $TEMP_DIR/*; do
# Check if file is a binary
if ! file $file | grep -q "ELF"
then
rm $file
continue
fi

# Set runtime path to ORIGIN
patchelf --set-rpath '$ORIGIN' $file
done

# Copy libc++_shared.so (required by libobjc2)
cp $ANDROID_NDK_SYSROOT/usr/lib/$TARGET_TRIPLE/libc++_shared.so $TEMP_DIR

adb shell rm -rf /data/local/tmp/libobjc2_tests
adb push $TEMP_DIR /data/local/tmp/libobjc2_tests

# Copy android_test_driver.sh to device
adb push $BUILD_DIR/../.github/scripts/android_test_driver.sh /data/local/tmp/libobjc2_tests

# Run the tests
adb shell "cd /data/local/tmp/libobjc2_tests && sh android_test_driver.sh"
}

main "$@"
122 changes: 120 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
# Build each combination of OS and release/debug variants
os: [ "ubuntu-22.04", "ubuntu-20.04" ]
build-type: [ Release, Debug ]
blocks-runtime: [ "EMBEDDED", "swift-5.10-RELEASE" ]
cxxlib: [ "libc++", "libstdc++" ]
llvm-version: [10, 11, 12, 13, 14, 15]
# Don't bother testing the LLVM versions that aren't in the default image for the different platforms
Expand All @@ -41,7 +42,7 @@ jobs:
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} ${{ matrix.build-type }} LLVM-${{ matrix.llvm-version }} ${{ matrix.cxxlib }}
name: ${{ matrix.os }} ${{ matrix.build-type }} LLVM-${{ matrix.llvm-version }} ${{ matrix.cxxlib }} BlocksRuntime-${{ matrix.blocks-runtime }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand All @@ -53,11 +54,24 @@ jobs:
sudo apt install libc++-${{matrix.llvm-version}}-dev libc++abi-${{matrix.llvm-version}}-dev
sudo apt install libunwind-${{matrix.llvm-version}}-dev || true
fi
if [ "${{ matrix.blocks-runtime }}" != "EMBEDDED" ]; then
git clone --depth 1 --branch "${{ matrix.blocks-runtime }}" https://github.com/apple/swift-corelibs-libdispatch.git ${{github.workspace}}/swift-corelibs-libdispatch
cmake -B ${{github.workspace}}/swift-corelibs-libdispatch/build -G Ninja -DINSTALL_PRIVATE_HEADERS=ON -DCMAKE_C_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm-version}} -S ${{github.workspace}}/swift-corelibs-libdispatch
pushd ${{github.workspace}}/swift-corelibs-libdispatch/build
ninja
sudo ninja install
popd
fi
- name: Configure CMake
run: |
export LDFLAGS=-L/usr/lib/llvm-${{ matrix.llvm-version }}/lib/
if [ "${{ matrix.blocks-runtime }}" != "EMBEDDED" ]; then
export EMBEDDED_BLOCKS_RUNTIME=OFF
else
export EMBEDDED_BLOCKS_RUNTIME=ON
fi
ls -lahR /usr/lib/llvm-${{ matrix.llvm-version }}/lib/
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -G Ninja -DTESTS=ON -DCMAKE_C_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_OBJC_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_ASM_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_OBJCXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_CXX_FLAGS="-stdlib=${{matrix.cxxlib}}"
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -G Ninja -DTESTS=ON -DEMBEDDED_BLOCKS_RUNTIME=$EMBEDDED_BLOCKS_RUNTIME -DCMAKE_C_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_OBJC_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_ASM_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_OBJCXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_CXX_FLAGS="-stdlib=${{matrix.cxxlib}}"
# Build with a nice ninja status line
- name: Build
working-directory: ${{github.workspace}}/build
Expand Down Expand Up @@ -245,6 +259,110 @@ jobs:
name: ${{ matrix.msystem }}-${{ matrix.build-type }}
path: dist/

android:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ ubuntu-20.04 ]
build-type: [ Release, Debug ]
arch:
- name: x86_64
triple: x86_64-linux-android
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
- name: arm64-v8a
triple: aarch64-linux-android
# Google broke ARM64 emulation on x86_64 hosts. A workaround is to overwrite the qemu machine type.
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -accel off -qemu -machine virt
api-level: [ 27, 33 ]
# Please note that:
# - arm64-v8a emulation on a x86_64 host currently is only possible up to API level 27 Oreo
# - armeabi-v7a is only supported up to API level 24
exclude:
- api-level: 33
arch:
name: arm64-v8a
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: Android ${{ matrix.build-type }} ${{ matrix.arch.name }} API-${{ matrix.api-level }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update -y
sudo apt-get install patchelf ninja-build -y
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.arch.name }}
- name: Create AVD and Snapshot for Caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: hmelder/[email protected]
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch.name }}
force-avd-creation: false
emulator-options: ${{ matrix.arch.emu-options }}
disable-animations: true
script: echo "Generated AVD snapshot for caching."
# We are using the default NDK from the GitHub Actions runner.
- name: Configure CMake
run: |
export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
export CCPREFIX=$TOOLCHAIN/bin/${{ matrix.arch.triple }}${{ matrix.api-level }}
export CC="$CCPREFIX-clang"
export CXX="$CCPREFIX-clang++"
export OBJC="$CCPREFIX-clang"
export OBJCXX="$CCPREFIX-clang++"
export AS="$CCPREFIX-clang"
export LD="$TOOLCHAIN/bin/ld.lld"
export AR="$TOOLCHAIN/bin/llvm-ar"
export RANLIB="$TOOLCHAIN/bin/llvm-ranlib"
export STRIP="$TOOLCHAIN/bin/llvm-strip"
export NM="$TOOLCHAIN/bin/llvm-nm"
export OBJDUMP="$TOOLCHAIN/bin/llvm-objdump"
export LDFLAGS="-fuse-ld=lld"
export LIBS="-lc++_shared"

cmake -B ${{github.workspace}}/build \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=${{ matrix.arch.name }} \
-DANDROID_NDK=$ANDROID_NDK_HOME \
-DANDROID_STL=c++_shared \
-DCMAKE_FIND_USE_CMAKE_PATH=false \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_ASM_COMPILER=$AS \
-DCMAKE_BUILD_TYPE=${{matrix.build-type}} \
-DTESTS=ON \
-DANDROID_PLATFORM=android-${{ matrix.api-level }} \
-G Ninja
- name: Build
working-directory: ${{github.workspace}}/build
run: |
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja -v
- name: Test
uses: hmelder/[email protected]
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch.name }}
force-avd-creation: false
emulator-options: ${{ matrix.arch.emu-options }}
disable-animations: true
target: default
script: |
${{github.workspace}}/.github/scripts/android_test_main.sh ${{github.workspace}}/build ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot ${{ matrix.arch.triple }}


# Fake check that can be used as a branch-protection rule.
all-checks:
needs: [ubuntu, windows, qemu-crossbuild]
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*~
.*.sw?
Build
[b|B]uild
Debug
Release
16 changes: 0 additions & 16 deletions CMake/detect_arch.c

This file was deleted.

Loading