Giter Club home page Giter Club logo

clang-sys's People

Contributors

alexanderkjall avatar aliu avatar anderslanglands avatar atouchet avatar bsteinb avatar contrun avatar elrendio avatar emilio avatar gifnksm avatar hackattack avatar ignatenkobrain avatar jeandudey avatar jelmansouri avatar jessicah avatar jmpesp avatar jupp0r avatar kiron1 avatar kornelski avatar kylemayes avatar m3rcuriel avatar martijnberger avatar nickdesaulniers avatar poliorcetics avatar ptrstr avatar reyk avatar tov avatar upsuper avatar wrenger avatar yamakaky avatar yutannihilation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

clang-sys's Issues

Unknown enum variants returned by libclang cause crash in clang-sys builds targeting earlier versions of libclang

If clang-sys is compiled to target clang_3_5 but is linked against libclang 3.9 a crash (SIGSEGV or stack overflow) occurs when libclang returns an enum variant unknown to clang-sys that is then used in a match expression.

I filed a "bug" with rust-lang although it seems this is intended behavior for rust. Possible solutions are to cast the enums to an int or use int constants instead to avoid this problem, perhaps re-wrapping them as an enum. rust-lang/rust#36927

Some other discussions of this issue:

https://internals.rust-lang.org/t/c-style-enums-in-ffi-and-a-proposal-to-lump-in-with-unions/2744
https://users.rust-lang.org/t/backward-compatibility-of-enums/5224
rust-lang/rfcs#757

How to compile libclang version 6_0_0 to statically link

A noob question here. I would like to use your library together with clang-rs. However, due to some limitations, I need it statically linked. As you mentioned in the README, I would need to manually compile the libclang for version 6_0_0 to statically link it. Are there any good references of how to do it? Thanks in advance!

parse_version fails on debian Jessie

running the rust-bindgen tests, which uses cargo-sys
---- builder_state stdout ----
thread 'builder_state' panicked at 'called Result::unwrap() on an Err value: ParseIntError { kind: InvalidDigit }', ../src/libcore/result.rs
...
17: 0x559314b80437 - clang_sys::support::parse_version::h797e147fe3900f18
at /clean/devenv/rust/cargo/registry/src/github.com-88ac128001ac3a9a/clang-sys-0.6.0/src/support.rs:89
18: 0x559314b7fea5 - clang_sys::support::Clang::new::hdc3ebf8b18e7e1ba
at /clean/devenv/rust/cargo/registry/src/github.com-88ac128001ac3a9a/clang-sys-0.6.0/src/support.rs:32
....

clang --version on this system outputs:
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)

Panic in clang_sys::support::Clang::find

In particular, when called with None. Minimal example:

extern crate clang_sys;

fn main() {
    clang_sys::support::Clang::find(None);
}

This is with clang-sys 0.7.1.

Versioned libclang.so on Ubuntu

On Ubuntu 16.04, the clang packages (at least libclang-3.9-dev) don't contain libclang.so, but only a versioned shared library. This versioned library is called libclang-3.9.so. It might be useful to, in addition to searching for versioned libs that have the version appended, also search for the Ubuntu-style versioned library.

dyld: Library not loaded: @rpath/libclang.dylib

Building bindgen on my OS X (Yosemite) all works fine but once I execute it:

> target/debug/bindgen
dyld: Library not loaded: @rpath/libclang.dylib
  Referenced from: /Users/philipp/local.ch/rust-bindgen/target/debug/bindgen
  Reason: image not found
Trace/BPT trap: 5

my libclang.dylib is here: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib

and xcode-select -p outputs /Applications/Xcode.app/Contents/Developer, so all seems fine. Any hints?

`support::parse_search_paths()` should not `.expect(include_start)`

(The title refers to https://github.com/KyleMayes/clang-sys/blob/master/src/support.rs#L185)

It's as the title says - To give more context, I ran into a panic caused by this when using bindgen and it took me a while to figure out that it was because my clang is the one provided by Emscripten 1.37 which, unlike the "regular" clang, only outputs the "#include "[...]" search starts here:" line but not the "#include <[...]> search starts here:" one.

Also, seeing only that line as the message I got from the resulting panic was confusing to me.

I suggest that, instead of panicking, an empty Vec be returned.

Expose location of C headers

For my project I need to compile a bit of extra C code that uses clang functions.

However, in my build script I'm unable to find the right directory that contains the headers.

Could you expose that information? It's usually done by setting links and emitting Cargo variable cargo:include=, so that other build scripts can find it via DEP_CLANG_INCLUDE env var.

I can make a PR if you're interested.

Why is xcode-select searched before llvm-config on MacOSX ?

Why is xcode-select searched first for the path, and llvm-config second on MacOS X?

If I have an LLVM compiled from source, and put it on my path, llvm-config will always return the correct result, but xcode-select will return the paths for some other LLVM (the one bundled with whatever SDK is active).

search LD_LIBRARY_PATH for libclang

I'm trying to use ffmpeg-sys (which depends on bindgen and thus clang-sys) in a Heroku-like environment. In that environment, apt packages (using heroku-buildpack-apt) are not installed in their default location, but in another user-writable directory. LD_LIBRARY_PATH is set so the folder where libclang-3.9.so (in my case) can be found is included.

I think it would be sensible to include all directories in LD_LIBRARY_PATH in the locations searched for the libclang shared library. This would happen automatically if clang-sys were linked with libclang in the normal way, so I think it would be sensible to match that behaviour when loading the library at runtime.

linking with `cc` failed: exit code: 1

Hi! I am trying to use statically link clang-sys on Mac in my pet hello world project. So I downloaded and compiled libclang version 6_0_0 and it has all the necessary files (libclang.a llvm-config etc). Here's my Cargo.toml

[package]
name = "hello_libclang"
version = "0.1.0"
authors = ["Oleksii Dykan <[email protected]>"]

[dependencies]

[dependencies.clang-sys]
version = "0.24.0"
features = ["static", "clang_6_0"]

and here's my main.rs:

extern crate clang_sys;

fn main() {
    println!("Hello, world!");
}

I try to compile it with the following command:

LLVM_CONFIG_PATH=~/Desktop/clang-test/build/bin/llvm-config LIBCLANG_STATIC_PATH=~/Desktop/clang-test/build/lib LIBCLANG_PATH=~/Desktop/clang-test/build/lib cargo build

however, on the compilation time I get the following error:

error: linking with `cc` failed: exit code: 1

Do you know what could be the reason for that? Thanks in advance!

Proposal: Load libclang on runtime

Some users like me can't get working clang-sys linking to libclang and the only way to get it working was loading it dynamically using dlopen and it's friends, we could mantain two versions of the library like x11-rs does, one linked (x11) and one loading the library at runtime (x11-dl).

Sorry if my english isn't good, i speak spanish :)

Improve llvm search path

Currently build.rs contains a hard-coded, os-specific list of directories to search. I think it could be improved by simply using the output of llvm-config --libdir, maybe with a fallback with the current search path.

bindgen fails to load libclang.dll

From rust-lang/rust-bindgen#1276

Why can't bindgen find libclang.dll?

D:\3rdparty\reaper_extension_sdk\jmde>bindgen reaper_plugin_functions.h -o reaper.rs
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared libra
ry at D:\\Program Files\\LLVM\\bin\\libclang.dll could not be opened: %1 is not
a valid Win32 application. (os error 193)"', libcore\result.rs:945:5
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: BaseThreadInitThunk
  15: RtlInitializeExceptionChain
  16: RtlInitializeExceptionChain

Btw, the file "D:\Program Files\LLVM\bin\libclang.dll" exists and has version 4.0.0.0.
An earlier version of bindgen cli was working without problems on this system.

custom static build fails, because build uses llvm-config --libs without using --libdir

I built static llvm and clang, and did make install to custom, non-standard directories.

Static build.rs of clang-sys get_llvm_libraries() only queries llvm-config --libs, but this output just lists lib names (-lLLVMLTO -lLLVMPasses) and lacks any -L flags required to find them.

This fixes the build for me:

print!("-L {} ", run_llvm_config(&["--libdir"]).expect("libdir"));

Next release?

Are you planning a new release soon? I can't wait to use the recent improvements.

llvm-config --shared-mode not supported

Build fails if static clang is used with dynamic llvm.

llvm-config --libs gives libs specific to its own type of build,

  • i.e. -lLLVM-4 for dynamic build (sytem-wide LLVM*.so) or
  • -lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMSymbolize etc. for lib*.a.

You can check llvm-config --shared-mode to know which one LLVM was built for.
If you'd rather force static linking, then use llvm-config --link-static --libs

Can't find clang on Ubuntu

On Ubuntu, LLVM binaries have the version number appended to their name, like so:

$clang[TAB][TAB]
clang-3.5                     clang-format-diff-3.5
clang++-3.5                   clang-modernize-3.5
clang-apply-replacements-3.5  clang-query-3.5
clang-check-3.5               clang-tblgen-3.5
clang-format-3.5              clang-tidy-3.5

support::Clang::find can't find clang this way.

Test MacOS

Could someone test llvm-config --libdir on MacOS?

Support minimum version

It would be useful for cases where we require a certain minimum version of clang to be used to provide an error if that version can't be found.

Non informative error message when libclang is 32 bits

On fedora the load_manually function looks for clang in /usr/lib instead of /usr/lib64 which makes the ELF not load. Instead of getting the error message:
wrong ELF class: ELFCLASS32
You get the unhelpful message:
the ``libclang`` shared library could not be opened.

rustc version:
rustc 1.17.0-nightly (0f34b532a 2017-02-21) binary: rustc commit-hash: 0f34b532af590d25e9178f87c620931dd671cc2e commit-date: 2017-02-21 host: x86_64-unknown-linux-gnu release: 1.17.0-nightly LLVM version: 3.9

libclang.so.1 not found on Debian

On Debian 8.5, it looks a lot like #28

The clang lib is /usr/lib/llvm-3.5/lib/libclang.so.1, but I had to create a link named libclang.so to get it to compile.

Error message follow:

Build failed, waiting for other jobs to finish...
error: failed to compile `bindgen v0.18.0`, intermediate artifacts can be found at `/tmp/cargo-install.7B4EzkrL0K9o`

Caused by:
  failed to run custom build command for `clang-sys v0.7.2`
process didn't exit successfully: `/tmp/cargo-install.7B4EzkrL0K9o/release/build/clang-sys-66118395f506ca26/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'could not find libclang.so, set the LIBCLANG_PATH environment variable to a path where libclang.so can be found', /home/tatref/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.7.2/build.rs:42
note: Run with `RUST_BACKTRACE=1` for a backtrace.

It seems that the version I'm using should be clear of this bug?

Feature detection

If I compile with clang_3_9, does the build script checks if clang 3.9 is available?

ld: library not found for -lclang.dy

I'm trying to use clang-sys on macOS as follows:

clang-sys = { version = "0.24.0", features = ["clang_6_0"] }

The build fails with:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.1y16o1qfye96o7m0.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.2339ye2qsut5jzf1.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.2xs38k3nu4oe9uo6.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.3fiyi1r0f9gw01la.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.3rngp6bm2u2q5z0y.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.4011gx3bwpzq03se.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.4oc10dk278mpk1vy.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.4xq48u46a1pwiqn7.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.4ypvbwho0bu5tnww.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.8xzrsc1ux72v29j.rcgu.o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.oa3rad818d8sgn4.rcgu.o" "-o" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135" "$PROJECT/target/debug/deps/test_main-f36430e3bd34d135.crate.allocator.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "$PROJECT/target/debug/deps" "-L" "/usr/local/opt/llvm/lib" "-L" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-8b11cd23e28267c4.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libterm-97c75d65953833c3.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-96e8d9c41fd5f863.rlib" "$PROJECT/target/debug/deps/$PROJECT-9d25e484d92983e9.rlib" "$PROJECT/target/debug/deps/libclang_sys-7109b6c4a521deab.rlib" "$PROJECT/target/debug/deps/liblibc-aecf7ee5e4c12d5c.rlib" "$PROJECT/target/debug/deps/libglob-186622082d7523d5.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-90d0baaa628316fc.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-2501f1a43ee00253.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-1ebc0af87eedc756.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-d5a51010c907c42d.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-776df9543761d8dc.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-56ad06cec3622785.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-54ae7b5ec4f1ba32.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-585d1da946bc8c2f.rlib" "$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-a06451ee7f3e01cf.rlib" "-l" "clang.dy" "-l" "System" "-l" "resolv" "-l" "pthread" "-l" "c" "-l" "m"
  = note: ld: library not found for -lclang.dy
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Somehow it tries to use libclang.dy, and not libclang.dylib.

Also, v0.23.0 compiles just fine.

Allow for non-standard clang install paths on macOS

I just ran into an issue with coreaudio-sys by way of rust-bindgen by way of clang-sys where it was not able to find the path to my libclang.dylib.

I managed to pin it down to this line, where the shared library search path points to a typical Xcode installation location. However, I'm a Cocoa dev who bounces around between Xcode versions a lot and have to maintain a folder structure for managing different Xcode versions in different locations. This path being hardcoded, alongside the fact that I can't get RLS to account for environment variables and I don't have my own version of LLVM installed, has left me with limited options here.

Instead of hardcoding this path, can we change this behavior to do a search based on the return from xcode-select -p? I see that we're already checking for some output from xcodebuild to find the clang executable, so it wouldn't be antithetical to the design of the rest of the crate.

Test Windows

Could someone test llvm-config --libdir on Windows?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.