diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml index d13b0ae4f4..d3b929c431 100644 --- a/.github/workflows/linux_arm64.yml +++ b/.github/workflows/linux_arm64.yml @@ -126,8 +126,6 @@ jobs: bash nodesource_setup.sh sudo apt-get install -y nodejs - rustup default stable - pip3 install --use-pep517 python-dotenv jinja2 df -h . diff --git a/.github/workflows/linux_ubuntu2204.yml b/.github/workflows/linux_ubuntu2204.yml index e4a9b35d6b..779ea3e115 100644 --- a/.github/workflows/linux_ubuntu2204.yml +++ b/.github/workflows/linux_ubuntu2204.yml @@ -179,12 +179,7 @@ jobs: # library is instrumented with AddressSanitizer. rustup update stable if [ "${{ matrix.build_type }}" = "debug" ]; then - echo "Setting Rust toolchain to stable with the GNU ASAN target" - rustup default stable rustup target add --toolchain stable x86_64-unknown-linux-gnuasan - else - echo "Setting Rust toolchain to stable for Linux release build" - rustup default stable fi rustc --version diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.yml index f84b25bd78..c5a8fecd63 100644 --- a/.github/workflows/mac_arm64.yml +++ b/.github/workflows/mac_arm64.yml @@ -123,8 +123,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest @@ -431,8 +429,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest @@ -604,8 +600,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest @@ -703,8 +697,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest @@ -810,8 +802,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest @@ -917,8 +907,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest diff --git a/.github/workflows/mac_x64.yml b/.github/workflows/mac_x64.yml index 0a6ae21a71..e5bd52ccc6 100644 --- a/.github/workflows/mac_x64.yml +++ b/.github/workflows/mac_x64.yml @@ -123,8 +123,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree brew install gettext @@ -482,8 +480,6 @@ jobs: # Due to https://github.com/llvm/llvm-project/issues/155531, we need # to use llvm@20 currently, and will switch to llvm when it is solved. brew install llvm@20 - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 requests go install golang.org/dl/go1.24.3@latest diff --git a/.github/workflows/tman_full_linux_arm64.yml b/.github/workflows/tman_full_linux_arm64.yml index d07e73e878..c559536981 100644 --- a/.github/workflows/tman_full_linux_arm64.yml +++ b/.github/workflows/tman_full_linux_arm64.yml @@ -138,8 +138,6 @@ jobs: cd ${{ github.workspace }} - rustup default stable - df -h . EXTRA_ARGS="is_clang=true log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_go_lint=false ten_enable_rust_incremental_build=false ten_manager_enable_frontend=true ten_enable_ffmpeg_extensions=false ten_enable_nodejs_binding=false ten_enable_python_binding=false ten_enable_go_binding=false ten_enable_ten_rust=true ten_enable_ten_manager=true" diff --git a/.github/workflows/tman_full_linux_x64.yml b/.github/workflows/tman_full_linux_x64.yml index 7d3bc0b0bd..4c7ae76b00 100644 --- a/.github/workflows/tman_full_linux_x64.yml +++ b/.github/workflows/tman_full_linux_x64.yml @@ -139,16 +139,9 @@ jobs: export PATH=$(pwd)/core/ten_gn:$PATH echo $PATH - # Linux x64 debug builds use the stable ASAN target, whose standard - # library is instrumented with AddressSanitizer. rustup update stable if [ "${{ matrix.build_type }}" = "debug" ]; then - echo "Setting Rust toolchain to stable with the GNU ASAN target" - rustup default stable rustup target add --toolchain stable x86_64-unknown-linux-gnuasan - else - echo "Setting Rust toolchain to stable for Linux release build" - rustup default stable fi df -h . diff --git a/.github/workflows/tman_full_mac_arm64.yml b/.github/workflows/tman_full_mac_arm64.yml index b97c120dcd..79ff954af7 100644 --- a/.github/workflows/tman_full_mac_arm64.yml +++ b/.github/workflows/tman_full_mac_arm64.yml @@ -118,8 +118,6 @@ jobs: - name: Install tools and dependencies run: | - rustup default stable - brew install tree pip3 install --use-pep517 python-dotenv jinja2 go install golang.org/dl/go1.24.3@latest diff --git a/.github/workflows/tman_full_mac_x64.yml b/.github/workflows/tman_full_mac_x64.yml index d6c4be2ead..3a49a04bad 100644 --- a/.github/workflows/tman_full_mac_x64.yml +++ b/.github/workflows/tman_full_mac_x64.yml @@ -118,8 +118,6 @@ jobs: - name: Install tools and dependencies run: | - rustup default stable - brew install tree brew install gettext diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 18e2785688..392bde0616 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -34,6 +34,15 @@ jobs: runs-on: windows-latest env: PYTHONIOENCODING: utf-8 + # Must use nightly for MinGW, otherwise error[E0554] will be triggered + # when rustc is building tman.exe, because sysinfo 0.32 uses + # "#![cfg_attr(target_os = "windows", feature(windows_by_handle))]" + # to use windows file handle API, which "may not be used on the stable + # release channel" + # For msvc, we also need to use nightly when ten_enable_go_binding=true + # because Go always uses MinGW toolchain on Windows (CGO requires + # GCC-compatible compiler) and the above issues will also happen. + RUSTUP_TOOLCHAIN: ${{ matrix.compiler == 'mingw' && 'nightly-x86_64-pc-windows-gnu' || 'nightly-x86_64-pc-windows-msvc' }} strategy: fail-fast: false matrix: @@ -216,19 +225,7 @@ jobs: go1.24.3 version go env -w GOFLAGS="-buildvcs=false" - if ("${{ matrix.compiler }}" -eq "mingw") { - # Must use nightly for MinGW, otherwise error[E0554] will be triggered - # when rustc is building tman.exe, because sysinfo 0.32 uses - # "#![cfg_attr(target_os = "windows", feature(windows_by_handle))]" - # to use windows file handle API, which "may not be used on the stable - # release channel" - rustup default nightly-x86_64-pc-windows-gnu - } else { - # For msvc, we also need to use nightly when ten_enable_go_binding=true - # because Go always uses MinGW toolchain on Windows (CGO requires - # GCC-compatible compiler) and the above issues will also happen. - rustup default nightly-x86_64-pc-windows-msvc - } + rustup update $env:RUSTUP_TOOLCHAIN cargo install --force cbindgen Write-Output "Verifying Rust toolchain..." @@ -283,15 +280,6 @@ jobs: $argsString = $buildArgs -join " " Write-Host "Build arguments: $argsString" - # Set toolchain or else toolchain may be switched during build - if ("${{ matrix.compiler }}" -eq "mingw") { - $env:RUSTUP_TOOLCHAIN = "nightly-x86_64-pc-windows-gnu" - } - else { - $env:RUSTUP_TOOLCHAIN = "nightly-x86_64-pc-windows-msvc" - } - echo $env:RUSTUP_TOOLCHAIN - tgn gen win x64 ${{ matrix.build_type }} -- $argsString tgn build win x64 ${{ matrix.build_type }} @@ -1108,13 +1096,6 @@ jobs: run: | $ENV:PATH += ";$PWD/core/ten_gn" - if ("${{ matrix.compiler }}" -eq "mingw") { - # Set toolchain to force use of the nightly-x86_64-pc-windows-gnu - # Or else toolchain may be switched to msvc during build - $env:RUSTUP_TOOLCHAIN = "nightly-x86_64-pc-windows-gnu" - echo $env:RUSTUP_TOOLCHAIN - } - cd out/win/x64/ pytest -s tests/ten_runtime/integration/python/ @@ -1287,13 +1268,6 @@ jobs: run: | $ENV:PATH += ";$PWD/core/ten_gn" - if ("${{ matrix.compiler }}" -eq "mingw") { - # Set toolchain to force use of the nightly-x86_64-pc-windows-gnu - # Or else toolchain may be switched to msvc during build - $env:RUSTUP_TOOLCHAIN = "nightly-x86_64-pc-windows-gnu" - echo $env:RUSTUP_TOOLCHAIN - } - cd out/win/x64/ pytest -s tests/ten_runtime/integration/cpp/ # continue-on-error: true diff --git a/build/ten_common/rust/rust.gni b/build/ten_common/rust/rust.gni index c19c268e58..58c27c9b58 100644 --- a/build/ten_common/rust/rust.gni +++ b/build/ten_common/rust/rust.gni @@ -125,13 +125,6 @@ template("rust_target") { } } - if (target == "x86_64-unknown-linux-gnuasan") { - args += [ - "--env", - "RUSTUP_TOOLCHAIN=stable", - ] - } - args += [ "--target", target, @@ -327,13 +320,6 @@ template("rust_test") { } } - if (target == "x86_64-unknown-linux-gnuasan") { - args += [ - "--env", - "RUSTUP_TOOLCHAIN=stable", - ] - } - args += [ "--target", target, @@ -451,13 +437,6 @@ template("rust_gen_cargo_config") { rebase_path(_output), ] - args += [ "--compiler" ] - if (is_clang) { - args += [ "clang" ] - } else { - args += [ "gcc" ] - } - if (is_win) { if (is_mingw) { # MinGW target for Windows @@ -505,10 +484,6 @@ template("rust_gen_cargo_config") { args += [ "--target", target, - "--target-os", - target_os, - "--target-arch", - target_cpu, ] if (enable_sanitizer && ten_rust_enable_gen_cargo_config) { diff --git a/build/ten_common/rust/rust_gen_cargo_config.py b/build/ten_common/rust/rust_gen_cargo_config.py index 2450ceaff4..b641576e4c 100644 --- a/build/ten_common/rust/rust_gen_cargo_config.py +++ b/build/ten_common/rust/rust_gen_cargo_config.py @@ -5,20 +5,13 @@ # Refer to the "LICENSE" file in the root directory for more information. # import argparse -import json import shutil import sys import os from build.scripts import timestamp_proxy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from scripts import package_asan_lib - - # The content of the auto generated .cargo/config.toml file is as follows. # -# - For the stable Linux x64 GNU ASAN target: -# # ```toml # [target.x86_64-unknown-linux-gnuasan] # rustflags = [] @@ -26,46 +19,9 @@ # [build] # target = "x86_64-unknown-linux-gnuasan" # ``` -# -# - For targets without an ASAN-instrumented standard library, such as macOS: -# -# ```toml -# [target.x86_64-apple-darwin] -# rustflags = ["-C", "linker=clang", "-Z", "external-clangrt", "-Z", -# "sanitizer=address", "-C", "link-args=-fsanitize=address"] -# -# [build] -# target = "x86_64-apple-darwin" -# ``` - -GCC_ASAN_FLAGS = [ - "-C", - "linker=gcc", - "-Z", - "external-clangrt", - "-Z", - "sanitizer=address", - "-l", - "asan", -] - - -# It is better to use lld as the linker in clang. In Rust, you can specify it -# using ["-C", "link-arg=-fuse-ld=lld"]. However, lld needs to be in the PATH. -# On some CI machines, lld is not in the PATH, so we won't use lld here. -CLANG_ASAN_FLAGS = [ - "-C", - "linker=clang", - "-Z", - "external-clangrt", - "-Z", - "sanitizer=address", - "-C", - "link-args=-fsanitize=address", -] CONFIG_TEMPLATE = """[target.{build_target}] -rustflags = {asan_flags} +rustflags = [] [build] target = "{build_target}" @@ -77,28 +33,12 @@ class ArgumentInfo(argparse.Namespace): def __init__(self): super().__init__() self.project_root: str - self.build_type: str - self.compiler: str self.target: str - self.target_os: str - self.target_arch: str self.tg_timestamp_proxy_file: str | None = None - self.enable_asan: bool self.action: str self.disable_incremental: bool = False -# On macOS, only the Clang compiler is available, and Clang's ASan runtime -# is provided only as a dynamic library. However, the linker flag -# '-shared-libasan' is not supported in Cargo with Clang on macOS. Cargo will -# issue a warning and ignore the flag, e.g., 'clang: warning: argument unused -# during compilation: '-shared-libasan''. This could be a bug in Cargo. To -# resolve this, use the following flag instead. -def special_link_args_on_mac(arch: str) -> str: - asan_lib = package_asan_lib.detect_mac_asan_lib(arch) - return f"link-arg=-Wl,{asan_lib}" - - def gen_cargo_config(args: ArgumentInfo): if not os.path.exists(args.project_root): raise FileNotFoundError( @@ -115,23 +55,12 @@ def gen_cargo_config(args: ArgumentInfo): if os.path.exists(cargo_config): os.remove(cargo_config) - if args.target == "x86_64-unknown-linux-gnuasan": - flags = [] - elif args.compiler == "gcc": - flags = GCC_ASAN_FLAGS.copy() - else: - flags = CLANG_ASAN_FLAGS.copy() - - if args.target_os == "mac": - flags.extend(["-C", special_link_args_on_mac(args.target_arch)]) - incremental_setting = ( "incremental = false" if args.disable_incremental else "" ) config_content = CONFIG_TEMPLATE.format( build_target=args.target, - asan_flags=json.dumps(flags), incremental_setting=incremental_setting, ) @@ -148,20 +77,12 @@ def delete_cargo_config(root: str): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument( - "--action", type=str, required=True, help="gen|delete|print" - ) - parser.add_argument("--project-root", type=str, required=False) - parser.add_argument("--compiler", type=str, required=True) - parser.add_argument("--target", type=str, required=False) - parser.add_argument("--target-os", type=str, required=True) - parser.add_argument("--target-arch", type=str, required=True) + parser.add_argument("--action", choices=("gen", "delete"), required=True) + parser.add_argument("--project-root", type=str, required=True) + parser.add_argument("--target", type=str, required=True) parser.add_argument( "--tg-timestamp-proxy-file", type=str, default="", required=False ) - parser.add_argument( - "--enable-asan", action=argparse.BooleanOptionalAction, default=True - ) parser.add_argument( "--disable-incremental", action=argparse.BooleanOptionalAction, @@ -190,7 +111,6 @@ def delete_cargo_config(root: str): finally: sys.exit(-1 if returncode != 0 else 0) - elif args.action == "delete": try: delete_cargo_config(args.project_root) @@ -210,19 +130,3 @@ def delete_cargo_config(root: str): finally: sys.exit(-1 if returncode != 0 else 0) - else: - # action = print - # - # Constructs and prints a space-separated string of the necessary ASan - # flags for Clang, taking into account any macOS-specific handling. - flags = [ - CLANG_ASAN_FLAGS[i] + CLANG_ASAN_FLAGS[i + 1] - for i in range(0, len(CLANG_ASAN_FLAGS) - 1, 2) - ] - - if args.target_os == "mac": - asan_flag = special_link_args_on_mac(args.target_arch) - flags.append(f"-C{asan_flag}") - - print(" ".join(flags)) - sys.exit(0) diff --git a/core/ten_gn b/core/ten_gn index 53ea4828b0..cf7036e5f1 160000 --- a/core/ten_gn +++ b/core/ten_gn @@ -1 +1 @@ -Subproject commit 53ea4828b0bbb68a3bad6c631d768a83ddbe1229 +Subproject commit cf7036e5f1a4795ead48d4ca8804db33a9a00b75 diff --git a/tools/docker_for_building/ubuntu/22.04/Dockerfile b/tools/docker_for_building/ubuntu/22.04/Dockerfile index a4368e2108..3ae2808763 100644 --- a/tools/docker_for_building/ubuntu/22.04/Dockerfile +++ b/tools/docker_for_building/ubuntu/22.04/Dockerfile @@ -110,9 +110,7 @@ RUN export ARCH=$(dpkg --print-architecture) && curl -OL https://go.dev/dl/go1.2 # Install cargo for rust. RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ - /root/.cargo/bin/rustup install stable && \ /root/.cargo/bin/rustup target add --toolchain stable x86_64-unknown-linux-gnuasan && \ - /root/.cargo/bin/rustup default stable && \ /root/.cargo/bin/cargo install --force cbindgen ENV PATH="/root/.cargo/bin:$PATH"