-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[libc] add multi-platform pre-commit github actions #119104
Conversation
@llvm/pr-subscribers-github-workflow Author: Schrodinger ZHU Yifan (SchrodingerZhu) ChangesFull diff: https://github.com/llvm/llvm-project/pull/119104.diff 3 Files Affected:
diff --git a/.github/workflows/libc-fullbuild-tests.yml b/.github/workflows/libc-fullbuild-tests.yml
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/.github/workflows/libc-gpu-build.yml b/.github/workflows/libc-gpu-build.yml
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/.github/workflows/libc-overlay-tests.yml b/.github/workflows/libc-overlay-tests.yml
new file mode 100644
index 00000000000000..63732a37277886
--- /dev/null
+++ b/.github/workflows/libc-overlay-tests.yml
@@ -0,0 +1,66 @@
+# This workflow is for pre-commit testing of the LLVM-libc project.
+name: LLVM-libc Pre-commit Overlay Tests
+
+on:
+ pull_request:
+ branches: [ "main" ]
+ paths:
+ - 'libc/**'
+ - '.github/workflows/libc-overlay-tests.yml'
+
+jobs:
+ build:
+ env:
+ SCCACHE_GHA_ENABLED: "true"
+ runs-on: ${{ matrix.os }}
+ strategy:
+ # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, windows-latest, macos-latest]
+ build_type: [Release, Debug]
+ compiler: [
+ { c_compiler: gcc, cpp_compiler: g++ },
+ { c_compiler: clang, cpp_compiler: clang++ },
+ { c_compiler: clang-cl, cpp_compiler: clang-cl }
+ ]
+ exclude:
+ - os: windows-latest
+ compiler: { c_compiler: gcc, cpp_compiler: g++ }
+ - os: ubuntu-latest
+ compiler: { c_compiler: clang-cl, cpp_compiler: clang-cl }
+ - os: macos-latest
+ compiler: { c_compiler: clang-cl, cpp_compiler: clang-cl }
+ - os: macos-latest
+ compiler: { c_compiler: gcc, cpp_compiler: g++ }
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Run sccache-cache
+ uses: mozilla-actions/sccache-action@v0.0.6
+
+ - name: Set reusable strings
+ id: strings
+ shell: bash
+ run: |
+ echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
+
+ - name: Configure CMake
+ run: >
+ cmake -B ${{ steps.strings.outputs.build-output-dir }}
+ -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }}
+ -DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }}
+ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
+ -DCMAKE_C_COMPILER_LAUNCHER=sccache
+ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
+ -DLLVM_ENABLE_RUNTIMES=libc
+ -G Ninja
+ -S ${{ github.workspace }}/runtimes
+
+ - name: Build
+ run: cmake --build ${{ steps.strings.outputs.build-output-dir }}
+
+ - name: Test
+ working-directory: ${{ steps.strings.outputs.build-output-dir }}
+ run: ninja check-libc
|
Update branch to check caching. |
I can see that the cache writing run into errors but I don't know why. Perhaps github forbids some writes when update the cache too frequently. For the time being, I guess this is already the best caching effort I can do with sccache. |
I'm not sure what kind of errors you are seeing but for the other jobs we've been using a different action for managing the sccache and it's working pretty well: https://github.com/llvm/llvm-project/blob/main/.github/workflows/llvm-project-tests.yml#L93 |
There is a I will try the other action later on. |
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.
The windows testing should probably go into the traditional premerge pipeline where we have decently powerful machines available.
The windows/macos testing are all light weight, even without caching, it finishes within 10 mins. The Linux one is a bit more problematic, as there are 9000+ testing units. But all of these finishes in 20mins. |
GHAC does not like to handle too many requests. I think this makes the |
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.
Cool! Mostly just some simple questions about the PR.
# TODO: add back gcc build when it is fixed | ||
# - c_compiler: gcc | ||
# cpp_compiler: g++ |
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.
Do you have more context about what's going wrong with the gcc builds?
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.
Please see https://github.com/llvm/llvm-project/actions/runs/12217700280/job/34082285018?pr=119104 and https://github.com/llvm/llvm-project/actions/runs/12218362957/job/34083763790?pr=119104
First one is for overlay and latter one for fullbuild.
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-headers-generic linux-libc-dev | ||
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm |
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.
Why do we need the symlink?
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.
Debian and its variants has a multilib sysroot, so arch-dependent headers are not installed into /usr/include/
.
Ideally, libc
should also add /usr/include/$(uname -p)-linux-gnu/
in its include directories but we do not do that.
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DCMAKE_BUILD_TYPE=MinSizeRel |
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.
Why MinSizeRel
(vs. Release
)?
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.
GHA has limited cache capability (10G in total). And we need to share it with other projects such as libcxx
. Therefore, I decide to optimize for sizes.
- name: Prepare dependencies (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
choco install ninja |
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.
What is choco
?
https://github.com/chocolatey/choco
does that itself have to be installed, or does it ship on the github buildbots? I guess same question for brew
on OSX; usually those don't come pre-installed IIRC.
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.
It is shipped in image per github spec. Please see https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
-DCMAKE_C_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW | ||
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded |
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.
Is this necessary for MinSizeRel
or Release
?
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.
This is following the instructions from https://github.com/mozilla/sccache/tree/main?tab=readme-ov-file#usage
-DCMAKE_BUILD_TYPE=MinSizeRel | ||
-DCMAKE_C_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW |
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.
Do we need to set 141? Surely we can omit that?
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.
Same as above, following the instructions from https://github.com/mozilla/sccache/tree/main?tab=readme-ov-file#usage
@@ -0,0 +1,76 @@ | |||
# This workflow is for pre-commit testing of the LLVM-libc project. | |||
name: LLVM-libc Pre-commit Fullbuild Tests | |||
|
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.
Can you add:
permissions:
contents: read
To each new file you've added. This is standard best practices for GitHub actions definitions.
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.
In the same level of name? Sure. Adding now
We do not have CI coverage for Windows/MacOS and we regularly run into problem where changes break post-commit fullbuild which is not tested in pre-commit builds. This PR utilizes the github action to address such issues.
This is a proof-of-concept for now.We do not have CI coverage for Windows/MacOS and we regularly run into problem where changes break post-commit fullbuild which is not tested in pre-commit builds. This PR utilizes the github action to address such issues.