diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba1f5fa..1f267c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: - name: Install dependicies run: | sudo apt update - sudo apt install -yq cmake ninja-build + sudo apt install -yq cmake ninja-build libzstd-dev - name: Fetch archives uses: actions/download-artifact@v2 with: diff --git a/D142965.patch b/D142965.patch deleted file mode 100644 index ba858d9..0000000 --- a/D142965.patch +++ /dev/null @@ -1,29 +0,0 @@ -From f95bdff17b3ed73f7f50479aaab3dfedfe73c9d1 Mon Sep 17 00:00:00 2001 -From: Shao-Ce SUN -Date: Wed, 1 Feb 2023 00:24:43 +0800 -Subject: [PATCH] [flang] Suppress a warning in D118631 [-Wunused-result] - -Reviewed By: klausler - -Differential Revision: https://reviews.llvm.org/D142965 ---- - flang/lib/Semantics/mod-file.cpp | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp -index 5a4aeef806f0445..22633054f0ca7f4 100644 ---- a/flang/lib/Semantics/mod-file.cpp -+++ b/flang/lib/Semantics/mod-file.cpp -@@ -963,8 +963,10 @@ Scope *ModFileReader::Read(const SourceName &name, - // directory lists, the intrinsic module directory takes precedence. - options.searchDirectories = context_.searchDirectories(); - for (const auto &dir : context_.intrinsicModuleDirectories()) { -- std::remove(options.searchDirectories.begin(), -- options.searchDirectories.end(), dir); -+ options.searchDirectories.erase( -+ std::remove(options.searchDirectories.begin(), -+ options.searchDirectories.end(), dir), -+ options.searchDirectories.end()); - } - options.searchDirectories.insert(options.searchDirectories.begin(), "."s); - } diff --git a/additional-patch.json b/additional-patch.json deleted file mode 100644 index b090235..0000000 --- a/additional-patch.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "metadata": { - "info": [], - "title": "Undef Macros" - }, - "platforms": [ - "android" - ], - "rel_patch_path": "flang-undef-macros.patch", - "version_range": { - "from": 370808, - "until": null - } - }, - { - "metadata": { - "info": [], - "title": "Upstream D142965" - }, - "platforms": [ - "android" - ], - "rel_patch_path": "D142965.patch", - "version_range": { - "from": 413129, - "until": null - } - } -] \ No newline at end of file diff --git a/build-flang.sh b/build-flang.sh index c5c092b..23c7e66 100644 --- a/build-flang.sh +++ b/build-flang.sh @@ -7,8 +7,12 @@ set -e -o pipefail -u : ${ANDROID_NDK:=~/lib/android-ndk-r26b} : ${FLANG_MAKE_PROCESSES:=1} +patch -p1 -d $(pwd)/out/llvm-project < flang-undef-macros.patch + +ANDROID_TRIPLE="$BUILD_ARCH_OR_TYPE-linux-android" CC_HOST_PLATFORM=$BUILD_ARCH_OR_TYPE-linux-android$DEFAULT_ANDROID_API_LEVEL if [ $BUILD_ARCH_OR_TYPE = arm ]; then + ANDROID_TRIPLE="armv7a-linux-androideabi" CC_HOST_PLATFORM=armv7a-linux-androideabi$DEFAULT_ANDROID_API_LEVEL elif [ $BUILD_ARCH_OR_TYPE = host ]; then CC_HOST_PLATFORM=x86_64-linux-gnu @@ -46,14 +50,15 @@ _EXTRA_CONFIGURE_ARGS=" -DLLVM_HOST_TRIPLE=${CC_HOST_PLATFORM/-/-unknown-} " -_CONFIGURE_ARGS="\ --DCMAKE_C_COMPILER=$(pwd)/out/stage2-install/bin/clang --DCMAKE_CXX_COMPILER=$(pwd)/out/stage2-install/bin/clang++ --DCMAKE_LINKER=$(pwd)/out/stage2-install/bin/ld.lld --DCMAKE_CXX_FLAGS=-stdlib=libc++ --DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ --DCMAKE_INSTALL_RPATH=\\\${ORIGIN}/../lib/x86_64-unknown-linux-gnu:\\\${ORIGIN}/../lib -" +_HOST_RPATH='$ORIGIN:$ORIGIN/../lib/x86_64-unknown-linux-gnu:$ORIGIN/../lib' + +_CONFIGURE_ARGS=() +_CONFIGURE_ARGS+=("-DCMAKE_C_COMPILER=$(pwd)/out/stage2-install/bin/clang") +_CONFIGURE_ARGS+=("-DCMAKE_CXX_COMPILER=$(pwd)/out/stage2-install/bin/clang++") +_CONFIGURE_ARGS+=("-DCMAKE_LINKER=$(pwd)/out/stage2-install/bin/ld.lld") +_CONFIGURE_ARGS+=("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -Wl,-rpath=$_HOST_RPATH") +_CONFIGURE_ARGS+=("-DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -Wl,-rpath=$_HOST_RPATH") +_CONFIGURE_ARGS+=("-DCMAKE_INSTALL_RPATH=$_HOST_RPATH") _BUILD_TARGET="" if [ "$BUILD_ARCH_OR_TYPE" != "host" ]; then @@ -61,21 +66,21 @@ if [ "$BUILD_ARCH_OR_TYPE" != "host" ]; then export NDK_STANDALONE_TOOLCHAIN_DIR="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64" CMAKE_PROC=$BUILD_ARCH_OR_TYPE test $CMAKE_PROC == "arm" && CMAKE_PROC='armv7-a' - _CONFIGURE_ARGS="-DCMAKE_SYSTEM_NAME=Android" - _CONFIGURE_ARGS+=" -DCMAKE_SYSTEM_PROCESSOR=$CMAKE_PROC" - _CONFIGURE_ARGS+=" -DCMAKE_SYSTEM_VERSION=$DEFAULT_ANDROID_API_LEVEL" - _CONFIGURE_ARGS+=" -DCMAKE_ANDROID_NDK=$ANDROID_NDK" - _CONFIGURE_ARGS+=" -DCMAKE_SKIP_INSTALL_RPATH=ON" + _CONFIGURE_ARGS=("-DCMAKE_SYSTEM_NAME=Android") + _CONFIGURE_ARGS+=("-DCMAKE_SYSTEM_PROCESSOR=$CMAKE_PROC") + _CONFIGURE_ARGS+=("-DCMAKE_SYSTEM_VERSION=$DEFAULT_ANDROID_API_LEVEL") + _CONFIGURE_ARGS+=("-DCMAKE_ANDROID_NDK=$ANDROID_NDK") + _CONFIGURE_ARGS+=("-DCMAKE_SKIP_INSTALL_RPATH=ON") + echo "" > $NDK_STANDALONE_TOOLCHAIN_DIR/sysroot/usr/include/zstd.h + echo "!" > $NDK_STANDALONE_TOOLCHAIN_DIR/sysroot/usr/lib/$ANDROID_TRIPLE/libzstd.a _BUILD_TARGET="Fortran_main FortranRuntime FortranDecimal" -else - export LD_LIBRARY_PATH="$(pwd)/out/stage2-install/lib:${LD_LIBRARY_PATH:-}" fi mkdir -p build-$BUILD_ARCH_OR_TYPE-install mkdir -p build-$BUILD_ARCH_OR_TYPE pushd build-$BUILD_ARCH_OR_TYPE -cmake -G Ninja $_CONFIGURE_ARGS \ +cmake -G Ninja "${_CONFIGURE_ARGS[@]}" \ -DCMAKE_INSTALL_PREFIX=$(pwd)/../build-$BUILD_ARCH_OR_TYPE-install \ -DDOXYGEN_EXECUTABLE= \ -DBUILD_TESTING=OFF \ diff --git a/Build-flang.patch b/build-mlir.patch similarity index 100% rename from Build-flang.patch rename to build-mlir.patch diff --git a/build.sh b/build.sh index ab14c50..2ecf5d2 100644 --- a/build.sh +++ b/build.sh @@ -2,6 +2,7 @@ set -e -o pipefail -u +# Fetch source mkdir -p ~/bin export PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo @@ -11,24 +12,23 @@ git config --global user.email "you@example.com" git config --global color.ui false mkdir -p llvm-toolchain && cd llvm-toolchain repo init -u https://android.googlesource.com/platform/manifest -# Modified the manifest xml, to ensure not contain darwin prebuilt -# XXX: Windows prebuilt? -sed -E 's/(^.*?(darwin).*$)//g' ../manifest_10552028.xml > .repo/manifests/test.xml +# Modified the manifest xml, to ensure only contain linux component +sed -E 's/(^.*?(darwin|mingw|windows).*$)//g' ../manifest_12027248.xml > .repo/manifests/test.xml repo init -m test.xml repo sync -c -# Add patch for flang -jq --argjson a "$(cat toolchain/llvm_android/patches/PATCHES.json)" \ - --argjson b "$(cat ../additional-patch.json)" -n '$a + $b' \ - > toolchain/llvm_android/patches/PATCHES.json -cp ../flang-undef-macros.patch toolchain/llvm_android/patches/ -cp ../D142965.patch toolchain/llvm_android/patches/ +# Remove duplicated repo cache +# rm -rf .repo -patch -p1 < ../Build-flang.patch +# Remove older version prebuilts +rm -rf $(find prebuilts/clang/host/linux-x86/clang* -maxdepth 0 | grep -v "clang-r522817" | grep -v "clang-stable") -# Build again +# Patch to build mlir +patch -p1 < ../build-mlir.patch + +# Build pushd toolchain/llvm_android -python build.py --no-build lldb,windows --no-musl --single-stage --skip-tests +python build.py --no-build lldb,windows --no-musl --bootstrap-use-prebuilt --skip-tests --skip-runtimes popd tar -cjf package-install.tar.bz2 out/install diff --git a/manifest_10552028.xml b/manifest_12027248.xml similarity index 58% rename from manifest_10552028.xml rename to manifest_12027248.xml index 0114ce2..e7b1149 100644 --- a/manifest_10552028.xml +++ b/manifest_12027248.xml @@ -5,67 +5,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + +