From 334794b40df3dead99c48a3ef8c4b0709b407f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 22 Apr 2024 15:28:30 +0300 Subject: [PATCH] test: Do a minimal test to try to build the libcxx std c++ module --- .github/workflows/build.yml | 5 +++++ test-libcxx-module.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 test-libcxx-module.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58e41ed..fb01788 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,6 +85,7 @@ jobs: # llvm-mingw). LLVM_CMAKEFLAGS="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra .github/workflows/store-version.sh install/llvm-mingw/versions.txt + ./test-libcxx-module.sh $(pwd)/install/llvm-mingw RUN_I686=false RUN_X86_64=false ./run-tests.sh $(pwd)/install/llvm-mingw cd install DISTRO=ubuntu-$(grep DISTRIB_RELEASE /etc/lsb-release | cut -f 2 -d =)-$(uname -m) @@ -129,6 +130,7 @@ jobs: - name: Test using the cross-built assembled toolchain run: | sudo apt-get update && sudo apt-get install qemu-user-static libc6-arm64-cross libstdc++6-arm64-cross + QEMU_LD_PREFIX=/usr/aarch64-linux-gnu ./test-libcxx-module.sh $(pwd)/install/llvm-mingw QEMU_LD_PREFIX=/usr/aarch64-linux-gnu RUN_I686=false RUN_X86_64=false ./run-tests.sh $(pwd)/install/llvm-mingw - name: Package the toolchain env: @@ -206,6 +208,7 @@ jobs: # other (arm64) architecture form. MACOS_REDIST=1 LLVM_CMAKEFLAGS="-DLLVM_ENABLE_ZSTD=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra .github/workflows/store-version.sh install/llvm-mingw/versions.txt + ./test-libcxx-module.sh $(pwd)/install/llvm-mingw RUN_I686=false RUN_X86_64=false ./run-tests.sh $(pwd)/install/llvm-mingw cd install NAME=llvm-mingw-$TAG-ucrt-macos-universal @@ -263,6 +266,7 @@ jobs: ./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb $ARGS .github/workflows/store-version.sh install/llvm-mingw/versions.txt ./copy-msys-dependencies.sh $(pwd)/install/llvm-mingw ${{matrix.sys}} + ./test-libcxx-module.sh $(pwd)/install/llvm-mingw ./run-tests.sh $(pwd)/install/llvm-mingw cd install NAME=llvm-mingw-$TAG-ucrt-msys2-${{matrix.sys}} @@ -358,6 +362,7 @@ jobs: - uses: actions/checkout@v4 - name: Run tests run: | + ./test-libcxx-module.sh /llvm-mingw ./run-tests.sh /llvm-mingw ./run-lldb-tests.sh /llvm-mingw diff --git a/test-libcxx-module.sh b/test-libcxx-module.sh new file mode 100755 index 0000000..edd9c5a --- /dev/null +++ b/test-libcxx-module.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (c) 2024 Martin Storsjo +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -ex + +if [ $# -lt 1 ]; then + echo $0 prefix + exit 1 +fi +PREFIX="$1" +PREFIX="$(cd "$PREFIX" && pwd)" +export PATH=$PREFIX/bin:$PATH + +: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}} + +for arch in $ARCHS; do + # TODO: This should ideally use "$CXX -print-file-name=libc++.modules.json", then parse the json to find the relevant cppm file and include directory. + $arch-w64-mingw32-clang++ -I$PREFIX/share/libc++/v1 -std=gnu++23 -Wno-reserved-module-identifier -x c++-module -fmodule-output=std.pcm -o std.cppm.obj -c $PREFIX/share/libc++/v1/std.cppm + $arch-w64-mingw32-clang++ -I$PREFIX/share/libc++/v1 -std=gnu++23 -Wno-reserved-module-identifier -x c++-module -fmodule-output=std.compat.pcm -fmodule-file=std=std.pcm -o std.compat.cppm.obj -c $PREFIX/share/libc++/v1/std.compat.cppm +done