GitHub操作未创建Rust二进制文件



我正在使用GitHub Actions交叉编译我的Rust程序。操作成功完成,并且在目标目录中创建了文件,但没有二进制文件。这是我的工作流程文件:

name: Compile and save program
on:
push:
branches: [main]
paths-ignore: ["samples/**", "**.md"]
workflow_dispatch:

jobs:    
build:
strategy:
fail-fast: false
matrix:
target: 
- aarch64-unknown-linux-gnu
- i686-pc-windows-gnu
- i686-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-gnu

name: Build executable
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install dependencies
run: |
rustup target add ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release --all-features --target-dir=/tmp
- name: Debug missing files
run: |
echo "target dir:"
ls -a /tmp/release
echo "deps:"
ls -a /tmp/release/deps
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: |
/tmp/release

这是针对Windows x86_64时创建的目录的布局(针对其他平台时唯一的区别是.fingerprintbuild内目录的名称(:

.
├── .cargo-lock
├── .fingerprint/
│   ├── libc-d2565b572b77baea/
│   ├── winapi-619d3257e8f28792/
│   └── winapi-x86_64-pc-windows-gnu-7e7040207fbb5417/
├── build/
│   ├── libc-d2565b572b77baea/
│   ├── winapi-619d3257e8f28792/
│   └── winapi-x86_64-pc-windows-gnu-7e7040207fbb5417/
├── deps/
│   └── <empty>
├── examples/
│   └── <empty>
└── incremental/
└── <empty>

正如您所看到的,没有二进制文件,这反映在上传的工件中。

是什么原因造成的?

编辑1

该程序在我的本地设备上构建良好。我的.cargo/config.toml在下面。

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

这是我的Cargo.toml:

[package]
name = "brainfuck"
version = "0.4.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
console = "0.15.2"
either = "1.8.0"

编辑2

在测试回购时,我发现这个问题只有在指定目标时才会出现。如果我不指定目标,只使用默认的系统目标,我会得到一个预期的二进制文件。

原来我没有正确阅读货物文档。构建缓存文档提到,具有指定目标的构建的结果存储在target/<triple>/debug/中,而这确实是它们所在的位置。

最新更新