Skip to content
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

tooling: define cross-compilation toolchain for ARM64 #75

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 1 addition & 45 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,48 +1,4 @@
startup --output_user_root=/tmp/bazel_output
common --enable_bzlmod
build --verbose_failures
build --repo_env=CC=clang
build --cxxopt=-std=c++17

# Non-critical (Default)

build --cxxopt=-Wall
build --cxxopt=-Wextra
build --cxxopt=-Wpedantic
build --cxxopt=-Wshadow
build --cxxopt=-Wnon-virtual-dtor
build --cxxopt=-Wold-style-cast
build --cxxopt=-Wcast-align
build --cxxopt=-Wunused
build --cxxopt=-Woverloaded-virtual
build --cxxopt=-Wconversion
build --cxxopt=-Wsign-conversion
build --cxxopt=-Wmisleading-indentation
build --cxxopt=-Wnull-dereference
build --cxxopt=-Wformat=2
build --cxxopt=-Wimplicit-fallthrough
build --cxxopt=-Werror

# Disable warning option for external libs

build --per_file_copt=third_party/.*,external/.*@-Wno-all
build --per_file_copt=third_party/.*,external/.*@-Wno-extra
build --per_file_copt=third_party/.*,external/.*@-Wno-pedantic
build --per_file_copt=third_party/.*,external/.*@-Wno-shadow
build --per_file_copt=third_party/.*,external/.*@-Wno-non-virtual-dtor
build --per_file_copt=third_party/.*,external/.*@-Wno-old-style-cast
build --per_file_copt=third_party/.*,external/.*@-Wno-cast-align
build --per_file_copt=third_party/.*,external/.*@-Wno-unused
build --per_file_copt=third_party/.*,external/.*@-Wno-overloaded-virtual
build --per_file_copt=third_party/.*,external/.*@-Wno-conversion
build --per_file_copt=third_party/.*,external/.*@-Wno-sign-conversion
build --per_file_copt=third_party/.*,external/.*@-Wno-misleading-indentation
build --per_file_copt=third_party/.*,external/.*@-Wno-null-dereference
build --per_file_copt=third_party/.*,external/.*@-Wno-format=2
build --per_file_copt=third_party/.*,external/.*@-Wno-implicit-fallthrough
build --per_file_copt=third_party/.*,external/.*@-Wno-everything
build --per_file_copt=third_party/.*,external/.*@-Wno-error

# Disable warnings incompatible with newer C++ versions

build --cxxopt=-Wno-c++98-compat
build --cxxopt=-Wno-c++98-compat-pedantic
6 changes: 5 additions & 1 deletion .github/workflows/check_pr_description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ name: PR description
on: # yamllint disable-line rule:truthy
pull_request:
types: [opened, edited, synchronize]

jobs:
check-description:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Check PR description for issue link
id: contains_issue
run: |
Expand All @@ -25,6 +28,7 @@ jobs:
else
echo "PR description contains a valid issue link."
fi

- name: Fail PR if no issue link found
if: failure()
run: |-
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: Clang-Format
on: # yamllint disable-line rule:truthy
pull_request:
branches: ['*']

jobs:
clang-format:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: GitLint
on: # yamllint disable-line rule:truthy
pull_request:
branches: ['*']

jobs:
gitlint:
runs-on: ubuntu-latest
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/llvm_cov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yamllint disable rule:line-length
---
name: Run llvm-cov
on: # yamllint disable-line rule:truthy
Expand All @@ -7,14 +8,12 @@ on: # yamllint disable-line rule:truthy
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
container:
image: dtors/base-cpp:latest

- name: Install LLVM
run: |
sudo apt update
sudo apt install -y llvm
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Coverage Script
run: bazel run //tools/coverage:llvm_cov -- -t //examples/cpp:test -s
run: bazelisk run //tools/coverage:llvm_cov --platforms=//bazel/platforms:x86_64_linux -- -t //examples/cpp:test -s
18 changes: 9 additions & 9 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ on: # yamllint disable-line rule:truthy
jobs:
yamllint:
runs-on: ubuntu-latest
container:
image: dtors/base-cpp:latest

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure Git Safe Directory
run: |
git config --global --add safe.directory $(pwd)

- name: Find affected files
run: |
Expand All @@ -20,7 +27,6 @@ jobs:
cat affected_files.txt

- name: Find affected yaml files
id: bazel_targets
run: |
> affected_yaml_files.txt

Expand All @@ -33,14 +39,8 @@ jobs:
sort -u affected_yaml_files.txt -o affected_yaml_files.txt
echo "Affected yaml files:"
cat affected_yaml_files.txt

echo "yaml_files=$(cat affected_yaml_files.txt | tr '\n' ' ')" >> $GITHUB_ENV

- name: Install yamllint
if: env.yaml_files != ''
run: |
python -m pip install --upgrade pip
pip install yamllint
shell: bash

- name: Lint YAML files
if: env.yaml_files != ''
Expand Down
7 changes: 0 additions & 7 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
filegroup(
name = "clang_tidy_config",
srcs = [
".clang-tidy",
],
visibility = ["//visibility:public"],
)
33 changes: 28 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,47 @@ RUN apt-get update && apt-get install -y \
libxcb-xkb1 \
libxcb-cursor0 \
locales \
clang \
clang-format \
clang-tidy \
&& apt-get update \
qtbase5-dev \
&& apt-get clean

RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | tee -a /etc/apt/sources.list.d/llvm.list

RUN apt-get update && apt-get install -y \
llvm-18 \
llvm-18-dev \
clang-18 \
clang-tools-18 \
clang-format-18 \
clang-tidy-18 \
lld-18 \
lldb-18

# Cross-compilation
RUN apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu

RUN pip install yamllint

RUN pip install gitlint

RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh | sh

RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.23.0/bazelisk-linux-amd64 && \
RUN wget https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 && \
chmod 755 bazelisk-linux-amd64 && \
mv bazelisk-linux-amd64 /usr/bin/bazelisk

ENV HOME=/root

RUN update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100

RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100

RUN update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-18 100

RUN update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-18 100

RUN echo "alias bazel='bazelisk'" >> $HOME/.bashrc

RUN echo 'if [ -d "$HOME/bin" ] ; then\n PATH="$HOME/bin:$PATH"\nfi' >> $HOME/.bashrc && \
Expand Down
21 changes: 18 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
bazel_dep(name = "rules_python", version = "1.0.0")

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = False,
ignore_root_user_error = True,
python_version = "3.12",
)

# Compile commands
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "4f28899228fb3ad0126897876f147ca15026151e",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)

bazel_dep(name = "platforms", version = "0.0.10")

register_toolchains(
"//toolchain/x86_64_linux",
"//toolchain/aarch64_linux",
)
Loading
Loading