rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.4k stars 691 forks source link

update requirements for OpenBSD #2838

Closed niko-ng closed 4 months ago

niko-ng commented 4 months ago

Hello, Since OpenBSD 7.4 the libclang path has changed. users have to make sure they install the port of llvm by running pkg_add llvm. And then, depending on the version that was chosen for install, the path for the dynamic library varies. by example, for the 17 version, it should be

LIBCLANG_PATH=/usr/local/llvm17/lib

this is the solution for all users encountering the error :

Unable to find libclang: "the `libclang` shared library at /usr/local/lib/libclang.so.8.2 could not be opened: Cannot load specified object"
basicfeatures commented 4 months ago

Any updates on this?

niko-ng commented 4 months ago

Any updates on this?

What do yo mean "update" ? The team of rust-bindgen needs to update their docs. I have provided what should be updated. They havent done it yet. not sure they have seen this issue. If you need to make rust-bindgen work on your openbsd system with version 7.4 or 7.5, then you just have to follow the instructions i detailed above.

basicfeatures commented 4 months ago

I need to install langchainrb basically. I'll follow your setup, many thanks man!

niko-ng commented 4 months ago

langchainrb

I think this command will work (or something similar)

env LIBCLANG_PATH=/usr/local/llvm17/lib gmake gem install langchainrb

you can also try to run export LIBCLANG_PATH=/usr/local/llvm17/lib before running gem install langchainrb

Make sure you installed the version 17 of LLVM before, by running pkg_add llvm.

BTW, I am curious why all those AI projects are running on Ruby, and why you guys are choosing OpenBSD as an OS for your AI stuff ? I love OpenBSD, just didn't know it is used for LLM. Is there a specific reason?

basicfeatures commented 4 months ago

To me Ruby is mankind's greatest achievement so far in programming, and Rails is the best way of organizing it into a web framework. It's like Python's little brother. Same concepts basically, but with a modernized syntax and package system.

Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software like NGiNX & Apache (https://openbsd.org/papers/httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker and so on.

OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest configuration syntax.

The biggest obstacle to OpenBSD is its lack of NVidia drivers, but we're working on it!

niko-ng commented 4 months ago

Ah nice! Yes I love OpenBSd, the best OS for security and simplicity. I know Ruby a bit and Rails too, from 15 years ago. Nice to see it is still used. I'll give a try to those AI things you are using ;) there was also this guy that had the same issue : https://www.reddit.com/r/rust/comments/1cg82vz/rust_openbsd_and_ruby_gems/

niko-ng commented 4 months ago

BTW, if the fix works for you, you should talk to the maintainers of langchainrb and tiktoken_ruby because they need to upgrade their build scripts for openbsd (change the LIBCLANG_PATH env var)

emilio commented 4 months ago

We'd take a pr with the doc fix fwiw, but an even better approach might be to teach clang-sys about where libclang is in openbsd

niko-ng commented 4 months ago

You are right that it is not a rust-bindgen issue, but a clang-sys one. in fact, llvm-config --libdir should return the right path and clang-sys should be able to find the lib without the need for the env var LIBCLANG_PATH. But something is wrong in the setup, at least on my machine, as it looks like there are 2 competing llvm-config on the machine. the old one and the newer one. Seems like an OpenBSD issue too. In any case, you can update your docs indeed, and clang-sys would have to do the same. I don't have the time for that right now, nor to open more issues everywhere, nor to make you a PR for your docs. i just created an issue at clang-sys now. I did my part which was to locate the issue (that has been mostly affecting rust-bindgen so far, as it is used extensively in the AI ruby ecosystem, apparently). For me it was when compiling rust-rocksdb, which can be also pretty common in general, but not so much on OpenBSD. Anyway, you can take it in your hands @emilio, or not. Me i leave you here with that.

pvdrz commented 4 months ago

closed as https://github.com/KyleMayes/clang-sys/issues/180 was opened. The readme already mentions what to do to point to the right libclang path.