diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f712c0401f..2b20c3fc68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: types: [opened, synchronize, reopened, labeled] paths-ignore: - '.github/workflows/sanitize.yml' + - '.github/workflows/sanitize-threads.yml' - '.github/workflows/reviter.yml' - '.github/workflows/docs.yaml' - '.github/workflows/docs-multiversion.yaml' diff --git a/.github/workflows/sanitize-threads.yml b/.github/workflows/sanitize-threads.yml new file mode 100644 index 0000000000..df45462b49 --- /dev/null +++ b/.github/workflows/sanitize-threads.yml @@ -0,0 +1,152 @@ +name: Nightly thread sanitizer check + +on: + pull_request: {} # Uncomment only to test this WF file update. + schedule: + - cron: '0 7 * * *' # Runs daily at 1:00 AM CST + workflow_dispatch: # Allows manual triggering + + +permissions: + contents: write +jobs: + build-and-runtest-with-asan-ubsan: + runs-on: ubuntu-latest + if: github.repository == 'qualcomm/eld' + + steps: + - name: Set up Clang 22 + uses: egor-tensin/setup-clang@23bc15cd4207e45f1566447deb48f4ff3ef932cb #v2.3 + with: + version: "22" + platform: x64 + + - name: Install libc++ and libc++abi + run: | + sudo apt update + sudo apt install -y clang-22 lld-22 ninja-build libc++-22-dev libc++abi-22-dev ccache libclang-rt-22-dev libunwind-22-dev + echo "PATH=/usr/lib/llvm-22/bin:$PATH" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/usr/lib/llvm-22/lib:$PATH" >> $GITHUB_ENV + + - name: Build and Test with Clang and show versions + run: | + echo "clang version" + clang --version + echo "clang++ version" + clang++ -stdlib=libc++ --version + echo "ld.lld version" + ld.lld --version + echo '#include ' > test.cpp + echo 'int main() { std::cout << "Hello, Clang on Ubuntu 24.04!" << std::endl; return 0; }' >> test.cpp + clang++ -std=c++17 -stdlib=libc++ test.cpp -o test_clang + ./test_clang + + - name: Checkout llvm-project + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: llvm/llvm-project + path: ./llvm-project/ + ref: main + + - name: Checkout eld + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: ./llvm-project/llvm/tools/eld + ref: main + + - name: Configure workflow environment variables + uses: ./llvm-project//llvm/tools/eld/.github/workflows/ConfigureBuildWorkflowENV + + - name: Restore ccache + id: cache-ccache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 + with: + path: ${{ github.workspace }}/obj/ccache + key: thread-sanitizer-ccache-${{ runner.os }}-${{ github.run_id }} + restore-keys: | + thread-sanitizer-ccache-${{ runner.os }}- + + - name: Record pre-build entry + if: github.event_name == 'schedule' + uses: ./llvm-project//llvm/tools/eld/.github/workflows/BuildStatusDataRecorder + with: + enabled: true + project: "./llvm-project//llvm/tools/eld" + stage: "pre-" + workflow-name: "thread-sanitizer" + record-mode: "record" + status: "fail" + run-id: ${{github.run_id}} + arch-name: "all" + branch-name: "${{env.BUILD_BRANCH}}" + + - name: Run CMake + run: | + mkdir -p obj + cd obj + cmake -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \ + -DLLVM_USE_SANITIZER="Thread" \ + -DCMAKE_CXX_FLAGS:STRING="-stdlib=libc++" \ + -DCMAKE_C_COMPILER:STRING=`which clang` \ + -DCMAKE_CXX_COMPILER:STRING=`which clang++` \ + -DLLVM_TARGETS_TO_BUILD:STRING="ARM;AArch64;RISCV;Hexagon;X86" \ + -DLLVM_CCACHE_BUILD:BOOL=ON \ + -DLLVM_CCACHE_DIR:STRING=$PWD/ccache/ \ + -DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON \ + -DLLVM_ENABLE_SPHINX=OFF \ + -DUSE_LLVM_UTILS_FROM_INSTALL:BOOL=ON \ + -DLLVM_USE_LINKER=lld \ + ../llvm-project/llvm + + - name: Build Project + run: | + cd obj + ninja ld.eld + + - name: Prune ccache before save + if: always() + env: + CCACHE_DIR: ${{ github.workspace }}/obj/ccache + run: ccache --evict-older-than 7200s + + - name: Save ccache + if: always() + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 + with: + path: ${{ github.workspace }}/obj/ccache + key: thread-sanitizer-ccache-${{ runner.os }}-${{ github.run_id }} + + - name: Fetch nightly toolset + uses: ./llvm-project//llvm/tools/eld/.github/workflows/FetchNightlyToolset + + - name: Run tests + run: | + cd obj + ninja check-eld + + - name: Update build entry + if: github.event_name == 'schedule' + uses: ./llvm-project//llvm/tools/eld/.github/workflows/BuildStatusDataRecorder + with: + enabled: true + project: "./llvm-project//llvm/tools/eld" + stage: "post-" + workflow-name: "thread-sanitizer" + record-mode: "update" + status: "pass" + run-id: ${{github.run_id}} + arch-name: "all" + branch-name: "${{env.BUILD_BRANCH}}" + + - name: Clean up nightly toolset + if: always() + run: | + rm -rf ${{ github.workspace }}/inst + rm -f ${{ github.workspace }}/install-nightly-toolchain.tar.xz + if [ -d "${{ github.workspace }}/inst" ] || [ -f "${{ github.workspace }}/install-nightly-toolchain.tar.xz" ]; then + echo "Warning: Failed to clean up nightly toolset" + else + echo "Successfully cleaned up nightly toolset" + fi