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

feat: add linux/arm64 #98

Merged
merged 35 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
747a98d
feat: compatible with amd64 and arm64
wangyoucao577 Sep 30, 2024
a43af5f
feat: build multiple platforms
wangyoucao577 Sep 30, 2024
2791558
feat: seperate amd64 and arm64 to speed up building
wangyoucao577 Oct 1, 2024
de61458
test: ci
wangyoucao577 Oct 1, 2024
30f9a68
fix: image
wangyoucao577 Oct 1, 2024
9ece95c
fix: explicity set linux/amd64
wangyoucao577 Oct 1, 2024
959d76e
feat: build linux/arm64
wangyoucao577 Oct 2, 2024
6984d5e
fix: image
wangyoucao577 Oct 2, 2024
71f39e5
fix: warning
wangyoucao577 Oct 2, 2024
a7df3b8
fix: image
wangyoucao577 Oct 2, 2024
04b644d
fix: build multi platforms together
wangyoucao577 Oct 2, 2024
7be2794
test: with same image tag
wangyoucao577 Oct 2, 2024
53d8b63
chore: remove comments
wangyoucao577 Oct 3, 2024
1352d47
fix: linux/arm64
wangyoucao577 Oct 3, 2024
ac0cf05
fix: comment
wangyoucao577 Oct 3, 2024
c77a7bc
fix: enable both clang/gcc for linux/arm64 building
wangyoucao577 Oct 3, 2024
a0194c3
fix: path
wangyoucao577 Oct 3, 2024
4c2c7fb
feat: disable rust tests to speech up building
wangyoucao577 Oct 4, 2024
7a92b6f
feat: disable libwebsockets to speed up building
wangyoucao577 Oct 4, 2024
de24c40
feat: seperate linux/arm64 building
wangyoucao577 Oct 4, 2024
909c903
feat: add package and upload assets
wangyoucao577 Oct 4, 2024
d269d4a
fix: compatible
wangyoucao577 Oct 11, 2024
ba6aff5
feat: install testing tools
wangyoucao577 Oct 11, 2024
fc7e31d
chore: cancel in progress
wangyoucao577 Oct 11, 2024
459d2c9
feat: install jq
wangyoucao577 Oct 11, 2024
7113918
chore: update version
wangyoucao577 Oct 11, 2024
579a3fe
chore: remove testing changes
wangyoucao577 Oct 11, 2024
2c55940
fix: typo
wangyoucao577 Oct 11, 2024
04480dd
feat: enable websocket
wangyoucao577 Oct 11, 2024
c764c4b
fix: syntax
wangyoucao577 Oct 11, 2024
b65ddd3
feat: disable libwebsockets to speed up building
wangyoucao577 Oct 12, 2024
047cab6
feat: disable rust tests to speech up
wangyoucao577 Oct 12, 2024
a87a94b
feat: remove testing configs
wangyoucao577 Oct 12, 2024
6933fa5
Merge branch 'main' into feature/arm64
halajohn Oct 12, 2024
0c6f417
fix: refine codes
halajohn Oct 14, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ jobs:
include:
- image_name: "ubuntu2204"
workdir: "tools/docker_for_building/ubuntu/22.04"
platforms: linux/amd64,linux/arm64
- image_name: "ubuntu1804"
workdir: "tools/docker_for_building/ubuntu/18.04"
platforms: linux/amd64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build & Publish to Github Container Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
Expand All @@ -33,5 +38,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: ${{ matrix.workdir }}
platforms: ${{ matrix.platforms }}
snapshot: true
tags: "${{ github.ref == 'refs/heads/main' && 'latest,' || '' }}"
99 changes: 99 additions & 0 deletions .github/workflows/build_linux_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build - linux arm64

on:
release:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- "docs/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/build_linux_arm64.yml"
- "**.md"

jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: build-linux-arm64-${{ github.head_ref }}-${{ matrix.compiler }}-${{ matrix.build_type }}
cancel-in-progress: true
strategy:
matrix:
compiler: [gcc]
build_type: [release]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
submodules: "true"

- name: Update version
run: |
git config --global --add safe.directory $(pwd)
python3 tools/version/update_version_in_ten_framework.py
python3 tools/version/check_version_in_ten_framework.py

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Build
run: |
docker run --rm --platform linux/arm64 \
-v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} \
ghcr.io/ten-framework/ten_building_ubuntu2204 \
bash -c "\
export PATH=$(pwd)/core/ten_gn:/usr/local/go/bin:/root/go/bin:/root/.cargo/bin:$PATH && \
echo $PATH && \
go env -w GOFLAGS="-buildvcs=false" && \
go1.20.12 download && \
rustup default nightly && \
tgn gen linux arm64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_tests=false ten_enable_libwebsockets=false && \
tgn build linux arm64 ${{ matrix.build_type }} && \
tree -I 'gen|obj' out \
"

- name: Upload tman
uses: actions/upload-artifact@v4
with:
name: tman-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}
path: out/linux/arm64/ten_manager/bin/tman

- name: Upload ten_packages
uses: actions/upload-artifact@v4
with:
name: ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}
path: |
out/linux/x64/ten_packages/system/ten_runtime
out/linux/x64/ten_packages/system/ten_runtime_go
out/linux/x64/ten_packages/system/ten_runtime_python
out/linux/arm64/ten_packages/extension/default_extension_cpp
out/linux/arm64/ten_packages/extension/default_extension_go
out/linux/arm64/ten_packages/extension/default_extension_python
out/linux/arm64/ten_packages/extension/py_init_extension_cpp

- name: Package assets
if: startsWith(github.ref, 'refs/tags/')
run: |
cd out/linux/arm64
zip -vr tman-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip ten_manager/bin/tman
zip -vr ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip \
ten_packages/system/ten_runtime \
ten_packages/system/ten_runtime_go \
ten_packages/system/ten_runtime_python \
ten_packages/extension/default_extension_cpp \
ten_packages/extension/default_extension_go \
ten_packages/extension/default_extension_python \
ten_packages/extension/py_init_extension_cpp

- name: Publish to release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
out/linux/arm64/tman-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip
out/linux/arm64/ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip
24 changes: 16 additions & 8 deletions build/common/scripts/package_asan_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def detect_mac_asan_lib(arch: str) -> str:


def detect_linux_asan_lib(arch: str) -> str:
if arch == "x64":
if arch in ["x64", "arm64"]:
out, _ = subprocess.Popen(
"gcc -print-file-name=libasan.so",
shell=True,
Expand All @@ -79,13 +79,21 @@ def detect_linux_asan_lib(arch: str) -> str:

# Generally speaking, this function should not need to be called because Clang's
# default ASan mechanism is static linking.
def detect_linux_clang_asan_lib(_arch: str) -> str:
out, _ = subprocess.Popen(
"clang -print-file-name=libclang_rt.asan-x86_64.so",
shell=True,
stdout=subprocess.PIPE,
encoding="utf-8",
).communicate()
def detect_linux_clang_asan_lib(arch: str) -> str:
if arch == "x64":
out, _ = subprocess.Popen(
"clang -print-file-name=libclang_rt.asan-x86_64.so",
shell=True,
stdout=subprocess.PIPE,
encoding="utf-8",
).communicate()
elif arch == "arm64":
out, _ = subprocess.Popen(
"clang -print-file-name=libclang_rt.asan-aarch64.so",
shell=True,
stdout=subprocess.PIPE,
encoding="utf-8",
).communicate()

libasan_path = out.strip()

Expand Down
4 changes: 2 additions & 2 deletions build/ten_manager/options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ declare_args() {
}

declare_args() {
ten_package_manager_enable_tests =
is_linux || is_win || (is_mac && target_cpu == "x64")
ten_package_manager_enable_tests = (is_linux && target_cpu == "x64") ||
is_win || (is_mac && target_cpu == "x64")
}
10 changes: 8 additions & 2 deletions build/ten_runtime/feature/autotool.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ def copy_system_deps(self):

if sys.platform == "linux":
libs.extend(
glob.glob(f"/usr/lib/x86_64-linux-gnu/lib{dep}.so.*")
glob.glob(
f"/usr/lib/{os.uname().machine}-linux-gnu/lib{dep}.so.*"
)
)
libs.extend(
glob.glob(
f"/usr/lib/{os.uname().machine}-linux-gnu/lib{dep}.so"
)
)
libs.extend(glob.glob(f"/usr/lib/x86_64-linux-gnu/lib{dep}.so"))
else:
print("TODO: Add support for other platforms.")
sys.exit(1)
Expand Down
17 changes: 10 additions & 7 deletions build/ten_runtime/feature/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,16 @@ def _fill_attributes(self):
self.sharedlinkerflags.append("--target=arm-linux-gnueabihf")
self.exelinkerflags.append("--target=arm-linux-gnueabihf")
elif self.args.target_cpu == "arm64":
self.cflags.append("--target=aarch64-linux-gnu")
self.sharedlinkerflags.append("--target=aarch64-linux-gnu")
self.exelinkerflags.append("--target=aarch64-linux-gnu")
if self.args.use_clang:
self.cflags.append("-fuse-ld=lld")
self.sharedlinkerflags.append("-fuse-ld=lld")
self.exelinkerflags.append("-fuse-ld=lld")
if os.uname().machine in ["arm64", "aarch64"]:
pass
else:
self.cflags.append("--target=aarch64-linux-gnu")
self.sharedlinkerflags.append("--target=aarch64-linux-gnu")
self.exelinkerflags.append("--target=aarch64-linux-gnu")
if self.args.use_clang:
self.cflags.append("-fuse-ld=lld")
self.sharedlinkerflags.append("-fuse-ld=lld")
self.exelinkerflags.append("-fuse-ld=lld")
else:
raise Exception(
"Currently can not build Linux target with CPU arch"
Expand Down
3 changes: 2 additions & 1 deletion build/ten_runtime/options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ declare_args() {
ten_enable_go_binding = is_mac || is_linux

# TODO: enable it on mac and win
ten_enable_python_binding = is_linux && target_cpu == "x64"
ten_enable_python_binding =
is_linux && (target_cpu == "x64" || target_cpu == "arm64")
}

# ten_runtime extensions
Expand Down
3 changes: 2 additions & 1 deletion build/ten_rust/options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ declare_args() {
}

declare_args() {
ten_rust_enable_tests = is_linux || is_win || (is_mac && target_cpu == "x64")
ten_rust_enable_tests = (is_linux && target_cpu == "x64") || is_win ||
(is_mac && target_cpu == "x64")
}
18 changes: 11 additions & 7 deletions tools/docker_for_building/ubuntu/22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ RUN apt-get clean && apt-get update && apt-get install -y --no-install-recommend
tree \
zip \
unzip \
jq \
cpulimit \
util-linux \
libasan5 \
autoconf \
libtool \
uuid-dev \
g++-multilib \
libmsgpack-dev \
libmysqlclient-dev \
libmysqlcppconn-dev \
Expand Down Expand Up @@ -54,6 +56,11 @@ RUN apt-get clean && apt-get update && apt-get install -y --no-install-recommend
python3-pip \
python3-venv

RUN export ARCH=$(dpkg --print-architecture) && \
if [ ${ARCH} = "amd64" ]; then \
apt-get install -y --no-install-recommends g++-multilib; \
fi

# =======================================
# Installing Python deps

Expand Down Expand Up @@ -84,10 +91,7 @@ RUN wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 && \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 && \
update-alternatives --install /usr/bin/clang-check clang-check /usr/bin/clang-check-18 100 && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-18 100 && \
mkdir -p /usr/lib/llvm-18/lib/x86_64-pc-linux-gnu && \
ln -sf $(clang -print-file-name=libc++.a) /usr/lib/llvm-18/lib/x86_64-pc-linux-gnu && \
ln -sf $(clang -print-file-name=libclang_rt.asan.so) $(dirname $(clang -print-file-name=libclang_rt.asan.so))/libclang_rt.asan-x86_64.so
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-18 100

# =======================================
# Install golang
Expand All @@ -97,8 +101,8 @@ ENV PATH="$PATH:/usr/local/go/bin:/root/go/bin"

# TEN go binding needs to be compatible with GO 1.20, so we need to install GO
# 1.20 to check the compatibility.
RUN curl -OL https://go.dev/dl/go1.22.3.linux-amd64.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xvf go1.22.3.linux-amd64.tar.gz && rm go1.22.3.linux-amd64.tar.gz && \
RUN export ARCH=$(dpkg --print-architecture) && curl -OL https://go.dev/dl/go1.22.3.linux-${ARCH}.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xvf go1.22.3.linux-${ARCH}.tar.gz && rm go1.22.3.linux-${ARCH}.tar.gz && \
go install golang.org/dl/go1.20.12@latest && go1.20.12 download

# =======================================
Expand Down
Loading