Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/libmoq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
os: macos-15-intel
- target: aarch64-apple-darwin
os: macos-latest
- target: universal-apple-darwin
os: macos-latest
Comment on lines +28 to +29
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Rust target installation will fail for universal-apple-darwin.

universal-apple-darwin is not a valid Rust target triple. The dtolnay/rust-toolchain action at line 39 will either fail or have no effect. The build script actually needs both x86_64-apple-darwin and aarch64-apple-darwin targets installed to compile the universal binary.

🐛 Proposed fix: Install both actual targets for universal builds
       - name: Install Rust
         uses: dtolnay/rust-toolchain@stable
         with:
-          targets: ${{ matrix.target }}
+          targets: ${{ matrix.target == 'universal-apple-darwin' && 'x86_64-apple-darwin,aarch64-apple-darwin' || matrix.target }}

Also applies to: 36-39

🤖 Prompt for AI Agents
In @.github/workflows/libmoq.yml around lines 28 - 29, Replace the invalid Rust
target "universal-apple-darwin" with the two concrete targets
"x86_64-apple-darwin" and "aarch64-apple-darwin" wherever the workflow lists
targets (search for the string "target: universal-apple-darwin"); update any
matrix or list used by the dtolnay/rust-toolchain action so it installs both
x86_64-apple-darwin and aarch64-apple-darwin instead of the universal name,
ensuring the build produces a universal binary by building both architectures.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the proposed fix looks good.

@claude I don't know if you have permission, but can you commit this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

- target: x86_64-pc-windows-msvc
os: windows-latest

Expand Down
95 changes: 63 additions & 32 deletions rs/libmoq/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,70 @@ while [[ $# -gt 0 ]]; do
esac
done

# Detect target if not specified
if [[ -z "$TARGET" ]]; then
TARGET=$(rustc -vV | grep host | cut -d' ' -f2)
echo "Detected target: $TARGET"
fi

# Get version from Cargo.toml if not specified
if [[ -z "$VERSION" ]]; then
VERSION=$(grep '^version' "$SCRIPT_DIR/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
echo "Detected version: $VERSION"
fi

echo "Building libmoq for $TARGET..."
if [[ "$TARGET" == "universal-apple-darwin" ]]; then
if [[ "$(uname)" != "Darwin" ]]; then
echo "Error: Universal builds are only supported on macOS" >&2
exit 1
fi

echo "Building libmoq for $TARGET..."

# Build x86_64
echo "Building for x86_64-apple-darwin..."
cargo build --release --package libmoq --target x86_64-apple-darwin --manifest-path "$WORKSPACE_DIR/Cargo.toml"

# Build arm64
echo "Building for aarch64-apple-darwin..."
cargo build --release --package libmoq --target aarch64-apple-darwin --manifest-path "$WORKSPACE_DIR/Cargo.toml"

# Define sources for packaging
# Use arm64 as the reference for headers/pkgconfig (they should be identical)
REF_TARGET="aarch64-apple-darwin"
INCLUDE_SOURCE="$WORKSPACE_DIR/target/$REF_TARGET/include/moq.h"
PKGCONFIG_SOURCE="$WORKSPACE_DIR/target/$REF_TARGET/pkgconfig/moq.pc"

# Libraries to combine
LIB_X86="$WORKSPACE_DIR/target/x86_64-apple-darwin/release/libmoq.a"
LIB_ARM64="$WORKSPACE_DIR/target/aarch64-apple-darwin/release/libmoq.a"
LIB_FILE="libmoq.a"

# Set up cross-compilation for Linux ARM64
if [[ "$TARGET" == "aarch64-unknown-linux-gnu" ]]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
else
# Detect target if not specified
if [[ -z "$TARGET" ]]; then
TARGET=$(rustc -vV | grep host | cut -d' ' -f2)
echo "Detected target: $TARGET"
fi

echo "Building libmoq for $TARGET..."

# Set up cross-compilation for Linux ARM64
if [[ "$TARGET" == "aarch64-unknown-linux-gnu" ]]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi

cargo build --release --package libmoq --target "$TARGET" --manifest-path "$WORKSPACE_DIR/Cargo.toml"
cargo build --release --package libmoq --target "$TARGET" --manifest-path "$WORKSPACE_DIR/Cargo.toml"

# Define sources for packaging
INCLUDE_SOURCE="$WORKSPACE_DIR/target/$TARGET/include/moq.h"
PKGCONFIG_SOURCE="$WORKSPACE_DIR/target/$TARGET/pkgconfig/moq.pc"

TARGET_DIR="$WORKSPACE_DIR/target/$TARGET/release"
if [[ "$TARGET" == *"-windows-"* ]]; then
LIB_SOURCE="$TARGET_DIR/moq.lib"
LIB_FILE="moq.lib"
else
LIB_SOURCE="$TARGET_DIR/libmoq.a"
LIB_FILE="libmoq.a"
fi
fi

# Determine paths
TARGET_DIR="$WORKSPACE_DIR/target/$TARGET/release"
NAME="moq-${VERSION}-${TARGET}"
PACKAGE_DIR="$OUTPUT_DIR/$NAME"

Expand All @@ -75,36 +116,26 @@ echo "Packaging $NAME..."
rm -rf "$PACKAGE_DIR"
mkdir -p "$PACKAGE_DIR/include" "$PACKAGE_DIR/lib"

# Copy header (generated in target/$TARGET/include/ by build.rs)
cp "$WORKSPACE_DIR/target/$TARGET/include/moq.h" "$PACKAGE_DIR/include/"
# Copy header
cp "$INCLUDE_SOURCE" "$PACKAGE_DIR/include/"

# Copy static library
case "$TARGET" in
*-windows-*)
cp "$TARGET_DIR/moq.lib" "$PACKAGE_DIR/lib/"
;;
*)
# Unix-like (macOS, Linux, etc.)
cp "$TARGET_DIR/libmoq.a" "$PACKAGE_DIR/lib/"
;;
esac
if [[ "$TARGET" == "universal-apple-darwin" ]]; then
echo "Creating universal binary..."
lipo -create "$LIB_X86" "$LIB_ARM64" -output "$PACKAGE_DIR/lib/$LIB_FILE"
else
cp "$LIB_SOURCE" "$PACKAGE_DIR/lib/"
fi
Comment on lines +119 to +128
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's find and examine the build.sh file
find . -name "build.sh" -path "*/libmoq/*" | head -5

Repository: moq-dev/moq

Length of output: 75


🏁 Script executed:

# Search for the build.sh file
fd "build.sh" rs/libmoq

Repository: moq-dev/moq

Length of output: 73


🏁 Script executed:

# Look for workflow files that might reference libmoq
fd -e "yml" -e "yaml" | grep -i "workflow\|action" | head -20

Repository: moq-dev/moq

Length of output: 37


🏁 Script executed:

# Examine the build.sh file around lines 119-128
cat -n rs/libmoq/build.sh | sed -n '100,135p'

Repository: moq-dev/moq

Length of output: 1272


🏁 Script executed:

# Check entire build.sh to understand variable definitions
wc -l rs/libmoq/build.sh

Repository: moq-dev/moq

Length of output: 77


🏁 Script executed:

# Search for workflow/CI files
fd -e "yml" -e "yaml" .github

Repository: moq-dev/moq

Length of output: 37


🏁 Script executed:

# Read the beginning of build.sh to understand setup and variable definitions
cat -n rs/libmoq/build.sh | head -100

Repository: moq-dev/moq

Length of output: 3948


🏁 Script executed:

# Search for where LIB_X86 and LIB_ARM64 are defined
rg "LIB_X86|LIB_ARM64" rs/libmoq/

Repository: moq-dev/moq

Length of output: 338


🏁 Script executed:

# Look for GitHub workflow files
find .github -type f \( -name "*.yml" -o -name "*.yaml" \) 2>/dev/null

Repository: moq-dev/moq

Length of output: 257


🏁 Script executed:

# Examine the libmoq.yml workflow file
cat .github/workflows/libmoq.yml

Repository: moq-dev/moq

Length of output: 2621


Workflow target configuration needs fixing for universal binary builds.

The packaging logic using lipo is correct. However, the libmoq.yml workflow incorrectly tries to install universal-apple-darwin as a Rust target (line 34), which doesn't exist. For the universal build job to succeed on macos-latest (ARM runner), the workflow should instead install both x86_64-apple-darwin and aarch64-apple-darwin targets before running build.sh. The build script itself correctly handles the "universal-apple-darwin" target by explicitly building both architectures and combining them with lipo, but this requires both underlying targets to be available.

🤖 Prompt for AI Agents
In `@rs/libmoq/build.sh` around lines 119 - 128, The workflow currently attempts
to rustup-install "universal-apple-darwin" which is invalid; update the
libmoq.yml job that prepares the Rust targets so it installs both
x86_64-apple-darwin and aarch64-apple-darwin (the actual Rust targets) before
invoking build.sh, since build.sh (which checks TARGET and uses lipo to combine
LIB_X86 and LIB_ARM64 when TARGET=="universal-apple-darwin") expects both
architecture-specific targets to be present; ensure the job runs rustup target
add x86_64-apple-darwin aarch64-apple-darwin on macos-latest prior to building.


# Copy pkg-config file (generated in target/$TARGET/pkgconfig/ by build.rs, not for Windows)
if [[ "$TARGET" != *"-windows-"* ]]; then
mkdir -p "$PACKAGE_DIR/lib/pkgconfig"
cp "$WORKSPACE_DIR/target/$TARGET/pkgconfig/moq.pc" "$PACKAGE_DIR/lib/pkgconfig/"
cp "$PKGCONFIG_SOURCE" "$PACKAGE_DIR/lib/pkgconfig/"
fi

# Generate CMake config files from templates
mkdir -p "$PACKAGE_DIR/lib/cmake/moq"

# Determine library filename
if [[ "$TARGET" == *"-windows-"* ]]; then
LIB_FILE="moq.lib"
else
LIB_FILE="libmoq.a"
fi

# Extract major version
MAJOR_VERSION="${VERSION%%.*}"

Expand Down
Loading