Skip to content

sccache with cc-rs: No input files given to clang in MacOS Github runner #2253

@rafaelbeckel

Description

@rafaelbeckel

This is a follow-up on an issue I originally reported on cc-rs: rust-lang/cc-rs#1196

I found out it only happens in MacOS Github runner with sccache enabled.
I tried to invalidate it with SCCACHE_RECACHE: "1", without success.

For your convenience, this is the same original issue description:


I have a Rust library that includes some C dependencies and builds them with cc crate.

The build works perfectly on my machine, but cc does pass the input files to clang in GitHub CI. The build does not fail, but the library is built without the C symbols.

The library is used by an iOS App. The App builds on my machine but not in Github CI because it can't find the C symbols in the library.

While building the library on Github, I noticed it emits some warnings from the detect_compiler_family.c file from this crate.

This same warning happens for all our C dependencies, using libpng as an example:

warning: [email protected]: /Users/runner/work/mylib/mylib/build/aarch64-apple-ios-sim/release/build/png-9e337979ddc13f8a/out/12269455920946110607detect_compiler_family.c:2:9: warning: clang [-W#pragma-messages]
warning: [email protected]: #pragma message "clang"
warning: [email protected]:         ^
warning: [email protected]: /Users/runner/work/mylib/mylib/build/aarch64-apple-ios-sim/release/build/png-9e337979ddc13f8a/out/12269455920946110607detect_compiler_family.c:6:9: warning: gcc [-W#pragma-messages]
warning: [email protected]: #pragma message "gcc"
warning: [email protected]:         ^
warning: [email protected]: 2 warnings generated.

# The error is here
warning: [email protected]: clang: error: unknown argument: '-?'
warning: [email protected]: clang: error: no input files

How to reproduce

Build a library with some C dependency on the MacOS Github runner (I'm using macos-14).

  test_rust_ios_build:
    runs-on: "macos-14"
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: "recursive"

      - name: Install llvm from Homebrew
        run: |
          brew update
          brew install llvm@18
          export LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lunwind ${LDFLAGS}"
          export CC="/opt/homebrew/opt/llvm/bin/clang"
          export CXX="/opt/homebrew/opt/llvm/bin/clang++"
          export LD="/opt/homebrew/opt/llvm/bin/clang"
          export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

      - name: Setup Rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          cache: false

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          cache-directories: ${{ github.workspace }}/build
          cache-all-crates: true

      - name: Run sccache-cache
        uses: mozilla-actions/[email protected]

      - name: Build iOS
        env:
          CC_ENABLE_DEBUG_OUTPUT: 1
          CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG: true
          RUST_BACKTRACE: "full"
        run: cargo build -v --target $TARGET --release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions