Open vezult opened 4 years ago
There is not dependency on weechat-dev
, the weechat-sys
crate bundles weechat-plugin.h
and if you don't have weechat-plugin.h
on your system the bundled one will be used.
While the CI is currently non-functioning, it did manage to build the project without having any additional deps installed, I am not sure what is missing from your system. A working C compiler will obviously be needed and these header files as well.
If you figure out what's missing we can mention it in the README.
So, while I'm sure this isn't the correct fix, this is what allowed me to successfully build weechat-sys
on my machine:
diff --git a/weechat-sys/build.rs b/weechat-sys/build.rs
index 1957ec6..9044393 100644
--- a/weechat-sys/build.rs
+++ b/weechat-sys/build.rs
@@ -26,7 +26,9 @@ fn build(file: &str) -> Result<Bindings, ()> {
];
let mut builder = bindgen::Builder::default().rustfmt_bindings(true);
- builder = builder.header(file);
+ builder = builder.header(file)
+ .clang_arg("-I/usr/include/")
+ .clang_arg("-I/usr/lib/gcc/x86_64-linux-gnu/8/include/");
for t in INCLUDED_TYPES {
builder = builder.whitelist_type(t);
Both of those include paths should be in your search path for your GCC 8 install by default. You seem to have multiple GCC versions installed as well as LLVM, it's unclear what your default C compiler is and why it isn't searching in those directories.
For example on my system I have GCC 10, which is used by default
$ cpp -v /dev/null -o /dev/null 09:55:35
Using built-in specs.
COLLECT_GCC=cpp
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/cc1 -E -quiet -v /dev/null -o /dev/null -mtune=generic -march=x86-64
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include-fixed
/usr/include
End of search list.
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
stddef.h
can be found inside of /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include/stddef.h
which is as shown contained in the default search list. We can certainly add /usr/include
to the search path in build.rs
but I don't think that fixed your issue. Adding the GCC 8 specific search path to build.rs
doesn't really make sense.
Build with both:
rust-weechat/weechat-sys on master [⇡] is 📦 v0.4.0 via 🦀 v1.48.0 ❯ grep -A3 builder.header build.rs
builder = builder.header(file)
.clang_arg("-I/usr/include/")
.clang_arg("-I/usr/lib/gcc/x86_64-linux-gnu/8/include/");
rust-weechat/weechat-sys on master [⇡] is 📦 v0.4.0 via 🦀 v1.48.0
❯ cargo build
Compiling weechat-sys v0.4.0 (/home/david/Development/community/rust-weechat/weechat-sys)
Finished dev [unoptimized + debuginfo] target(s) in 4.04s
Build without /usr/include:
rust-weechat/weechat-sys on master [⇡] is 📦 v0.4.0 via 🦀 v1.48.0 took 4s
❯ sed -i -e 's/.clang_arg("-I\/usr\/include\/")//' build.rs
rust-weechat/weechat-sys on master [!⇡] is 📦 v0.4.0 via 🦀 v1.48.0
❯ cargo build
Compiling weechat-sys v0.4.0 (/home/david/Development/community/rust-weechat/weechat-sys)
Finished dev [unoptimized + debuginfo] target(s) in 4.01s
Build without either:
rust-weechat/weechat-sys on master [!⇡] is 📦 v0.4.0 via 🦀 v1.48.0
❯ sed -i -e 's/.clang_arg("-I\/usr\/lib\/gcc\/x86_64-linux-gnu\/8\/include\/")//' build.rs
rust-weechat/weechat-sys on master [!⇡] is 📦 v0.4.0 via 🦀 v1.48.0
❯ cargo build
Compiling weechat-sys v0.4.0 (/home/david/Development/community/rust-weechat/weechat-sys)
error: failed to run custom build command for `weechat-sys v0.4.0 (/home/david/Development/community/rust-weechat/weechat-sys)`
Caused by:
process didn't exit successfully: `/home/david/Development/community/rust-weechat/target/debug/build/weechat-sys-40fddab25177a659/build-script-build` (exit code: 101)
--- stderr
src/wrapper.h:1:10: fatal error: 'weechat/weechat-plugin.h' file not found
src/wrapper.h:1:10: fatal error: 'weechat/weechat-plugin.h' file not found, err: true
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', weechat-sys/build.rs:72:61
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
rust-weechat/weechat-sys on master [!⇡] is 📦 v0.4.0 via 🦀 v1.48.0 took 2s
❯ grep -A3 builder.header build.rs
builder = builder.header(file)
;
So it does seem like the first include path is unnecessary. The second does seem to be required, for whatever reason.
GCC 8 is my default compiler:
❯ cpp -v /dev/null -o /dev/null
Using built-in specs.
COLLECT_GCC=cpp
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/8/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu /dev/null -o /dev/null -mtune=generic -march=x86-64
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
The ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
looks like a likely culprit, perhaps.
I checked several other Debian 10 machines, and each of them include that message in cpp -v
output. Given that, it seems possible that this is an issue on Debian generally. That said, I've not previously encountered this issue when compiling other -sys crates.
I had the same problem.
error: failed to run custom build command for `weechat-sys v0.4.0 (https://github.com/poljar/rust-weechat#fafc7e7e)`
Caused by:
process didn't exit successfully: `/home/arouene/Projects/weechat-matrix-rs/target/release/build/weechat-sys-8f3a560455ba992d/build-script-build` (exit status: 101)
--- stderr
/usr/include/weechat/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/weechat/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found, err: true
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /home/arouene/.cargo/git/checkouts/rust-weechat-4239b35d876f5f87/fafc7e7/weechat-sys/build.rs:70:61
I am on Fedora 34, I needed to install clang
, clang-libs
was already installed but not clang
:man_shrugging: , gcc-c++
was also already installed without success.
On CentOS 7.9.2009, installed clang
, clang-libs
, llvm
, llvm-libs
, seems gcc-c++
is also installed: gcc-c++-4.8.5
.
Getting the same error:
error: failed to run custom build command for `weechat-sys v0.4.0 (https://github.com/poljar/rust-weechat#fafc7e7e)`
Caused by:
process didn't exit successfully: `/home/myuser/git/weechat-matrix-rs/target/debug/build/weechat-sys-1a657337347b7df7/build-script-build` (exit status: 101)
--- stderr
/usr/include/weechat/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/weechat/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found, err: true
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found
src/weechat-plugin.h:29:10: fatal error: 'stddef.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()',
My issue (on CentOS 7.9) was fixed by doing a ln -s /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/stddef.h
in /usr/include
. (Probably not the correct way, just seemed like a quick fix/way to test.)
I ran into the same problem on Fedora 35. This got the build working for me
sudo dnf install clang clang-libs weechat-devel gcc-c++ cargo
export WEECHAT_HOME=/path/to/weechat
cargo build
make install
for some reason my weechat installation wont load plugins located in ${WEECHAT_HOME}/plugins
I was too lazy to look into why so i just did this to get weechat to load the plugin
sudo ln -s ${WEECHAT_HOME}/plugins/matrix.so /usr/lib64/weechat/plugins/matrix.so
reloaed weechat and was then /matrix
was available, and I was able to connect.
│18:22:05 weechat │ Plugins loaded: alias, buflist, charset, exec, fset, irc, logger, matrix, perl, python, relay, script, spell, trigger
│18:22:27 matrix-org ℹ │ matrix: Connected to matrix-org
Thanks @poljar
There appears to be some implicit assumptions being made about the build environment.
Although it's somewhat obvious, the docs don't mention a hard dependency on
weechat-dev
or similar packages. However, with that installed,stddef.h
(required byweechat-plugin.h
) is not being found.I'm not exactly sure what it's referring to:
It might be worth making mention of non-rust build dependencies in the README.