Skip to content
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
52 changes: 41 additions & 11 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:

on:
push:
tags: ['v*']
tags: [ 'v*' ]
workflow_dispatch:
inputs:
version:
Expand All @@ -21,6 +21,7 @@ env:
CARGO_TERM_COLOR: always
LIBTORCH_VERSION: 2.7.1
LIBTORCH_CXX11_ABI: 1
LIBTORCH_BYPASS_VERSION_CHECK: 1

jobs:
build-and-release:
Expand Down Expand Up @@ -59,19 +60,49 @@ jobs:
C:\libtorch
key: ${{ runner.os }}-${{ matrix.target }}-cargo-libtorch-${{ hashFiles('**/Cargo.lock') }}-${{ env.LIBTORCH_VERSION }}

# Linux libtorch setup
- name: Setup libtorch (Linux)
# Linux libtorch setup with explicit linker configuration
- name: Setup libtorch (Linux) - Alternative
if: matrix.os == 'ubuntu-latest'
run: |
if [ ! -d "/tmp/libtorch" ]; then
sudo apt-get update && sudo apt-get install -y wget unzip build-essential cmake
cd /tmp
wget -q ${{ matrix.libtorch_url }} -O libtorch.zip
unzip -q libtorch.zip
fi
sudo cp -r /tmp/libtorch /usr/local/ || true
sudo apt-get update
sudo apt-get install -y wget unzip build-essential cmake pkg-config

# Download and extract libtorch
cd /tmp
wget -q ${{ matrix.libtorch_url }} -O libtorch.zip
unzip -q libtorch.zip

# Move to system location
sudo mv libtorch /usr/local/

# Create pkg-config file for libtorch
sudo mkdir -p /usr/local/lib/pkgconfig
sudo tee /usr/local/lib/pkgconfig/libtorch.pc > /dev/null <<EOF
prefix=/usr/local/libtorch
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: libtorch
Description: PyTorch C++ Library
Version: ${{ env.LIBTORCH_VERSION }}
Libs: -L\${libdir} -ltorch -ltorch_cpu -lc10
Cflags: -I\${includedir}
EOF

# Update ldconfig
echo "/usr/local/libtorch/lib" | sudo tee /etc/ld.so.conf.d/libtorch.conf
sudo ldconfig

# Set environment variables
echo "LIBTORCH=/usr/local/libtorch" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/libtorch/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "LIBRARY_PATH=/usr/local/libtorch/lib:$LIBRARY_PATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV

# Verify
pkg-config --exists libtorch && echo "pkg-config found libtorch" || echo "pkg-config missing libtorch"
ldconfig -p | grep torch

# Windows libtorch setup
- name: Setup libtorch (Windows)
Expand All @@ -90,7 +121,6 @@ jobs:
if: matrix.os == 'macos-latest'
run: |
if [ ! -d "/tmp/libtorch" ]; then
brew install wget cmake
cd /tmp
wget -q ${{ matrix.libtorch_url }} -O libtorch.zip
unzip -q libtorch.zip
Expand Down
79 changes: 56 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust CI
name: Rust CI (Debug)

on:
push:
Expand All @@ -10,56 +10,89 @@ on:
env:
CARGO_TERM_COLOR: always
LIBTORCH_VERSION: 2.7.1
LIBTORCH_CXX11_ABI: 1

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust
- name: Install Rust with specific version
uses: dtolnay/rust-toolchain@stable
with:
# Try a specific known-good version if stable is problematic
toolchain: 1.89.0
components: rustfmt, clippy, rust-src

- name: Debug Rust environment
run: |
rustc --version --verbose
cargo --version
rustup show
rustup component list --installed
echo "Proc macro support:"
rustc --print target-list | grep $(rustc -vV | sed -n 's/host: //p')

- name: Cache cargo registry
uses: actions/cache@v3
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-v2
restore-keys: |
${{ runner.os }}-cargo-

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget unzip build-essential cmake
brew install wget

- name: Download and install libtorch
- name: Setup libtorch
run: |
cd /tmp
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip
# Detect architecture and download appropriate libtorch
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
LIBTORCH_URL="https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-${LIBTORCH_VERSION}.zip"
else
LIBTORCH_URL="https://download.pytorch.org/libtorch/cpu/libtorch-macos-x86_64-${LIBTORCH_VERSION}.zip"
fi

echo "Downloading libtorch for $ARCH from $LIBTORCH_URL"
wget "$LIBTORCH_URL" -O libtorch.zip
unzip libtorch.zip
sudo mv libtorch /usr/local/

echo "LIBTORCH=/usr/local/libtorch" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/libtorch/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=/usr/local/libtorch/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Verify libtorch installation
- name: Force clean build
run: |
ls -la /usr/local/libtorch/
ls -la /usr/local/libtorch/lib/
cargo clean
rm -rf ~/.cargo/registry/cache/
cargo update

- name: Build
run: cargo build --verbose
- name: Try building specific problematic crate first
run: |
echo "Attempting to build darling_macro specifically..."
cargo build -p darling_macro --verbose || echo "darling_macro build failed, continuing..."

- name: Build with maximum debugging
run: |
export RUST_LOG=debug
export RUST_BACKTRACE=full
cargo build --verbose
env:
LIBTORCH: /usr/local/libtorch
LD_LIBRARY_PATH: /usr/local/libtorch/lib
DYLD_LIBRARY_PATH: /usr/local/libtorch/lib
LIBTORCH_BYPASS_VERSION_CHECK: 1

- name: Run tests
run: cargo test --verbose
env:
LIBTORCH: /usr/local/libtorch
LD_LIBRARY_PATH: /usr/local/libtorch/lib
DYLD_LIBRARY_PATH: /usr/local/libtorch/lib
LIBTORCH_BYPASS_VERSION_CHECK: 1
Loading