Skip to content

Instantly share code, notes, and snippets.

@ianks
Created February 23, 2024 22:08
Show Gist options
  • Save ianks/d3e9697c5a1646af7748288f938a64a4 to your computer and use it in GitHub Desktop.
Save ianks/d3e9697c5a1646af7748288f938a64a4 to your computer and use it in GitHub Desktop.
Build bindgen with libclang
#!/bin/bash
git clone --depth 1 --branch release/14.x https://github.com/llvm/llvm-project
cd llvm-project
mkdir build
cd build
echo "Configuring clang"
cmake -G "Ninja" -DENABLE_SHARED=OFF -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE=Release ../llvm
echo "Building clang"
ninja -j 8 \
libclang.a \
llvm-config \
libLLVMFuzzMutate.a \
libLLVMFileCheck.a \
libLLVMInterfaceStub.a \
libLLVMDWARFLinker.a \
libLLVMExtensions.a \
libLLVMFrontendOpenACC.a \
libLLVMLTO.a \
libLLVMMCA.a \
libLLVMObjectYAML.a \
libLLVMDebugInfoGSYM.a \
libLLVMDebugInfoPDB.a \
libLLVMSymbolize.a \
libLLVMDWP.a \
libLLVMOrcShared.a \
libLLVMOrcTargetProcess.a \
libLLVMRuntimeDyld.a \
libLLVMExecutionEngine.a \
libLLVMInterpreter.a \
libLLVMJITLink.a \
libLLVMMCJIT.a \
libLLVMOrcJIT.a \
libLLVMAMDGPUTargetMCA.a \
libLLVMX86TargetMCA.a \
libLLVMLineEditor.a \
libLLVMCoverage.a \
libLLVMDlltoolDriver.a \
libLLVMLibDriver.a \
libLLVMXRay.a \
libLLVMWindowsManifest.a
export LLVM_CONFIG_PATH="$(pwd)/bin/llvm-config"
export LIBCLANG_STATIC_PATH="$(pwd)/lib/libclang.a"
git clone https://github.com/rust-lang/rust-bindgen
git checkout v0.69.4
cd rust-bindgen
cargo build --release -p bindgen-cli --no-default-features --features=static,logging,which-rustfmt
echo "Built: $PWD/target/release/bindgen"
ls -lh target/release/bindgen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment