-
Notifications
You must be signed in to change notification settings - Fork 671
[bazel] Build with LLVM #8414
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
base: 2027
Are you sure you want to change the base?
[bazel] Build with LLVM #8414
Changes from all commits
9e3f07d
e4f6490
6da76b8
7adcc0d
6f94a1b
f488776
6db1309
cb955ba
3ab7b31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,14 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" } | ||
| - { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" } | ||
| - { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" } | ||
| - { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" } | ||
| - { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" } | ||
| - { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" } | ||
| - { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" } | ||
| - { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" } | ||
| - { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" } | ||
| - { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" } | ||
| - { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" } | ||
| - { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" } | ||
| - { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" } | ||
| - { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" } | ||
| - { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" } | ||
| - { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" } | ||
|
|
||
| - { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" } | ||
|
|
||
|
|
@@ -34,8 +34,19 @@ jobs: | |
|
|
||
| name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}" | ||
| runs-on: ${{ matrix.os }} | ||
| container: ${{ matrix.container }} | ||
| steps: | ||
| - name: Free disk space (Linux) | ||
| uses: jlumbroso/free-disk-space@main | ||
| with: | ||
| tool-cache: false | ||
| android: true | ||
| dotnet: true | ||
| haskell: true | ||
| large-packages: false | ||
| docker-images: false | ||
| swap-storage: false | ||
| if: startsWith(matrix.os, 'ubuntu') | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: { fetch-depth: 0 } | ||
|
|
||
|
|
@@ -45,6 +56,10 @@ jobs: | |
| username: ${{ secrets.BAZEL_CACHE_USERNAME }} | ||
| password: ${{ secrets.BAZEL_CACHE_PASSWORD }} | ||
|
|
||
| - name: Install apt dependencies | ||
| if: matrix.os == 'ubuntu-24.04' | ||
| run: sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev | ||
|
|
||
| - if: matrix.os == 'ubuntu-24.04' | ||
| uses: bazel-contrib/[email protected] | ||
| with: | ||
|
|
@@ -64,12 +79,7 @@ jobs: | |
| - name: Free Space | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | ||
| fsutil volume diskfree C: | ||
| else | ||
| df -h / | ||
| fi | ||
| run: df -h | ||
|
|
||
| buildifier: | ||
| name: "buildifier" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,14 @@ http_archive( | |
| url = "https://github.com/wpilibsuite/rules_bzlmodrio_toolchains/releases/download/2025-1.bcr6/rules_bzlmodrio_toolchains-2025-1.bcr6.tar.gz", | ||
| ) | ||
|
|
||
| # TODO(davo): update version after the next release of toolchains_llvm after 1.5.0 | ||
| http_archive( | ||
| name = "toolchains_llvm", | ||
| integrity = "sha256-Ht0UsdgsySFX+H7AU3TS992uZr8nV5TP60lADgKeP7s=", | ||
| strip_prefix = "toolchains_llvm-cebf1ed19db1521bcaae489a40dd736d50e9302f", | ||
| url = "https://github.com/bazel-contrib/toolchains_llvm/archive/cebf1ed19db1521bcaae489a40dd736d50e9302f.tar.gz", | ||
| ) | ||
|
|
||
| http_archive( | ||
| name = "pybind11_bazel", | ||
| integrity = "sha256-iwRj1wuX2pDS6t6DqiCfhIXisv4y+7CvxSJtZoSAzGw=", | ||
|
|
@@ -128,10 +136,95 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps") | |
|
|
||
| bazel_features_deps() | ||
|
|
||
| load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") | ||
|
|
||
| bazel_toolchain_dependencies() | ||
|
|
||
| load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") | ||
|
|
||
| apple_support_dependencies() | ||
|
|
||
| load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") | ||
|
|
||
| COMMON_EXTRA_COMPILE_FLAGS = [ | ||
| "-Wextra", | ||
| "-Werror", | ||
| "-pedantic", | ||
| "-Wno-unused-parameter", | ||
| "-fPIC", | ||
| ] | ||
|
|
||
| LINUX_EXTRA_COMPILE_FLAGS = COMMON_EXTRA_COMPILE_FLAGS + ["-gz=zlib"] | ||
|
|
||
| MACOS_EXTRA_COMPILE_FLAGS = COMMON_EXTRA_COMPILE_FLAGS + [ | ||
| "-Wno-shorten-64-to-32", | ||
| "-Wno-gcc-compat", | ||
| "-Wno-missing-field-initializers", | ||
| "-Wno-unused-private-field", | ||
| ] | ||
|
|
||
| CONLY_FLAGS = ["-Wno-c23-extensions"] | ||
|
|
||
| COMMON_EXTRA_CXX_FLAGS = [ | ||
| "-Wformat=2", | ||
| "-Wno-unused-parameter", | ||
| "-pthread", | ||
| "-Wno-deprecated-enum-enum-conversion", | ||
| "-Wno-nontrivial-memcall", # warning in imgui.h inline functions | ||
| ] | ||
|
|
||
| LINUX_EXTRA_CXX_FLAGS = COMMON_EXTRA_CXX_FLAGS + ["-Wno-psabi"] | ||
|
|
||
| MACOS_EXTRA_CXX_FLAGS = COMMON_EXTRA_CXX_FLAGS + [ | ||
| "-Wno-unused-const-variable", | ||
| "-Wno-error=c11-extensions", | ||
| "-Wno-deprecated-anon-enum-enum-conversion", | ||
| ] | ||
|
|
||
| LINUX_EXTRA_LINK_FLAGS = ["-Wl,-rpath,$ORIGIN"] | ||
|
|
||
| MACOS_EXTRA_LINK_FLAGS = ["-Wl,-rpath,@loader_path"] | ||
|
|
||
| llvm_toolchain( | ||
| name = "llvm_toolchain", | ||
| conly_flags = { | ||
| "darwin-aarch64": CONLY_FLAGS, | ||
| "darwin-x86_64": CONLY_FLAGS, | ||
| "linux-aarch64": CONLY_FLAGS, | ||
| "linux-x86_64": CONLY_FLAGS, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AustinSchuh was there a particular reason bazel-contrib/toolchains_llvm#435 doesn't allow specifying a global
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason other than it probably didn't exist when that code was originally written 6 years ago. |
||
| }, | ||
| cxx_standard = {"": "c++20"}, | ||
| extra_compile_flags = { | ||
| "darwin-aarch64": MACOS_EXTRA_COMPILE_FLAGS, | ||
| "darwin-x86_64": MACOS_EXTRA_COMPILE_FLAGS, | ||
| "linux-aarch64": LINUX_EXTRA_COMPILE_FLAGS, | ||
| "linux-x86_64": LINUX_EXTRA_COMPILE_FLAGS, | ||
| }, | ||
| extra_cxx_flags = { | ||
| "darwin-aarch64": MACOS_EXTRA_CXX_FLAGS, | ||
| "darwin-x86_64": MACOS_EXTRA_CXX_FLAGS, | ||
| "linux-aarch64": LINUX_EXTRA_CXX_FLAGS, | ||
| "linux-x86_64": LINUX_EXTRA_CXX_FLAGS, | ||
| }, | ||
| extra_link_flags = { | ||
| "darwin-aarch64": MACOS_EXTRA_LINK_FLAGS, | ||
| "darwin-x86_64": MACOS_EXTRA_LINK_FLAGS, | ||
| "linux-aarch64": LINUX_EXTRA_LINK_FLAGS, | ||
| "linux-x86_64": LINUX_EXTRA_LINK_FLAGS, | ||
| }, | ||
| llvm_version = "20.1.7", | ||
| stdlib = { | ||
| "darwin-aarch64": "builtin-libc++", | ||
| "darwin-x86_64": "builtin-libc++", | ||
| "linux-aarch64": "stdc++", | ||
| "linux-x86_64": "stdc++", | ||
| }, | ||
| ) | ||
|
|
||
| load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") | ||
|
|
||
| llvm_register_toolchains() | ||
|
|
||
| load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains") | ||
|
|
||
| rules_cc_toolchains() | ||
|
|
||
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.
There's no
toolchains_llvmrelease that supports theextra_*_flagsparameters yet.