rust-lang / rust-lang/rust-bindgen

libclang not found when building using azure pipelines for windows

Open
#2,091 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

build.log
Recently all my windows build failed with:

thread 'main' panicked at 'Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the LIBCLANG_PATH environment variable to a path where one of these files can be found (invalid: [])"', D:\a\1\s$(HOME)/.cargo/registry\src\github.com-1ecc6299db9ec823\bindgen-0.58.1\src/lib.rs:2057:31

I have this small sample:

[package]
name = "sync"
version = "0.2.0"
authors = ["Sample"]
edition = "2018"

[dependencies]
xlsxwriter = "0.3.5"

I tried to set the ENV but it not work:

trigger:
  branches:
    include:
      - 'master'

strategy:
  maxParallel: 2
  matrix:
    windows-stable:
      imageName: 'windows-latest'
      rustup_toolchain: stable

pool:
  vmImage: $(imageName)

steps:
  - script: |
      cargo version
      rustc --version
      rustup toolchain list
      setx PATH "C:\Program Files\LLVM\bin;%PATH%" /M
      setx LIBCLANG_PATH "C:\Program Files\LLVM\bin" /M
      echo %path:;=&echo.%
      refreshenv
    displayName: Versions

  - script: |
      cargo build --bin sync --release
    env:
      LIBCLANG_PATH: "C:\Program Files\LLVM\bin"
    displayName: Cargo build Windows
    condition:  eq( variables['Agent.OS'], 'Windows_NT' )

P.D. This could be similar to https://github.com/rust-lang/rust-bindgen/issues/1797.
P.D.2: I attached the full log.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached build.log and the failure at bindgen-0.58.1/src/lib.rs:2057:31. Reproduce the cargo build on the Windows Azure Pipelines configuration shown, focusing on how LIBCLANG_PATH is passed to the build. Done means the sample xlsxwriter project builds successfully on windows-latest without the libclang-not-found panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, rust
Domain
build-system, ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.