You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is important that we can build on 32-bit targets, I've tried to follow the instructions in the README.md,
but substituting with the 32-bit variants.
This doesn't work for some reason. And here's the latest error-message/hurdle:
[redacted] MINGW32 /c/Users/tpb398/Documents/GitHub/libR-sys
$ cargo build --target=i686-pc-windows-gnu
Compiling libR-sys v0.1.9 (C:\Users\tpb398\Documents\GitHub\libR-sys)
error: failed to run custom build command for `libR-sys v0.1.9 (C:\Users\tpb398\Documents\GitHub\libR-sys)`
Caused by:
process didn't exit successfully: `C:/cargo_target_dir\debug\build\libR-sys-46304186790a078b\build-script-build` (exit code: 101)
--- stdout
cargo:rustc-env=R_HOME=C:/R/R-4.0.2
cargo:rustc-env=R_HOME=C:/R/R-4.0.2/bin/i386
cargo:r_home=C:/R/R-4.0.2
cargo:rustc-link-search=C:/R/R-4.0.2/bin/i386
cargo:rustc-link-lib=dylib=R
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=wrapper.h
--- stderr
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: [(C:\\Users\\tpb398\\scoop\\apps\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit)), (C:\\Users\\tpb398\\scoop\\apps\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit))])"', C:\Users\tpb398\.cargo\registry\src\github.com-1ecc6299db9ec823\bindgen-0.53.3\src/lib.rs:1956:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I've searched for clang.dll in the mingw folders, and there is nothing named that.
It is the libclang.dll that is problem.
Here's a few more diagnostic things that I see mentioned when trying to troubleshoot this:
Hi @CGMossa,
Did you have any success building against i686?
There is one issue with the building process - the library relies heavily on the R executable (present in PATH) to determine R-specific indlude directories. On 64-bit system PATH usually contains x64 folder of R, meaning libR-sys is linking against 64-bit version of R.dll, and ultimately fails.
Another thing I have no explanation for - my path contains both mingw32 and mingw64, and by default a 64-bit clang is invoked. If I leave only mingw32, I get the exactly same error as you have posted.
However, with mingw64 and i386R on the path, the library can be built and tests can be run, but two of them fail (looks like some native integer/pointer size mismatch). I have no experience in bindgen and cannot comment on that, but I attach a detailed stacktrace.
I do not understand why the pipeline is able to build a 32-bit app and link agains 32-bit version of R.dll while using 64-bit clang and libraries, this is beyond me.
Below is the result of $(echo $env:RUST_BACKTRACE ; cargo test --release --target=i686-pc-windows-gnu ; clang -v ; Rscript.exe -e '.Platform$r_arch') *>&1 > dump.txt
dump.txt
full
Compiling winapi v0.3.9
Compiling memchr v2.3.4
Compiling version_check v0.9.2
Compiling glob v0.3.0
Compiling cc v1.0.65
Compiling libc v0.2.80
Compiling lazy_static v1.4.0
Compiling proc-macro2 v1.0.24
Compiling bitflags v1.2.1
Compiling log v0.4.11
Compiling cfg-if v0.1.10
Compiling unicode-xid v0.2.1
Compiling regex-syntax v0.6.21
Compiling quick-error v1.2.3
Compiling unicode-width v0.1.8
Compiling bindgen v0.53.3
Compiling vec_map v0.8.2
Compiling strsim v0.8.0
Compiling lazycell v1.3.0
Compiling shlex v0.1.1
Compiling peeking_take_while v0.1.2
Compiling rustc-hash v1.1.0
Compiling nom v5.1.2
Compiling clang-sys v0.29.3
Compiling thread_local v1.0.1
Compiling humantime v1.3.0
Compiling textwrap v0.11.0
Compiling libloading v0.5.2
Compiling aho-corasick v0.7.15
Compiling which v3.1.1
Compiling quote v1.0.7
Compiling regex v1.4.2
Compiling winapi-util v0.1.5
Compiling atty v0.2.14
Compiling termcolor v1.1.2
Compiling clap v2.33.3
Compiling cexpr v0.4.0
Compiling env_logger v0.7.1
Compiling libR-sys v0.1.10 (C:\Users\[redacted]\OneDrive\Development\Playground\libR-sys)
Finished release [optimized] target(s) in 1m 35s
Running target\i686-pc-windows-gnu\release\deps\libR_sys-6c682b6e624d8212.exe
running 19 tests
test bindgen_test_layout_R_CMethodDef ... ok
test bindgen_test_layout_R_CallMethodDef ... ok
test bindgen_test_layout_R_inpstream_st ... ok
test bindgen_test_layout_R_outpstream_st ... ok
test bindgen_test_layout_Rcomplex ... ok
test bindgen_test_layout___mingw_dbl_type_t ... ok
test bindgen_test_layout___mingw_dbl_type_t__bindgen_ty_1 ... ok
test bindgen_test_layout___mingw_flt_type_t ... ok
test bindgen_test_layout___mingw_ldbl_type_t__bindgen_ty_1 ... ok
test bindgen_test_layout__complex ... ok
test bindgen_test_layout__exception ... ok
test bindgen_test_layout__iobuf ... ok
test bindgen_test_layout_localeinfo_struct ... ok
test bindgen_test_layout_tagLC_ID ... ok
test bindgen_test_layout_threadlocaleinfostruct ... ok
test bindgen_test_layout_threadlocaleinfostruct__bindgen_ty_1 ... ok
test bindgen_test_layout___mingw_ldbl_type_t ... FAILED
test bindgen_test_layout_max_align_t ... FAILED
test tests::test_eval ... ok
failures:
---- bindgen_test_layout___mingw_ldbl_type_t stdout ----
thread 'bindgen_test_layout___mingw_ldbl_type_t' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `4`: Alignment of __mingw_ldbl_type_t', C:\Users\[redacted]\OneDrive\Development\Playground\libR-sys\target\i686-pc-windows-gnu\release\build\libR-sys-3b2a1ee2f7fff495\out/bindings.rs:2941:5
stack backtrace:
0: 0x4d1d1b - core::fmt::write::h3a9c091b8ca4c7a7
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\core\src\fmt/mod.rs:1080
1: 0x402bb4 - std::io::Write::write_fmt::h55320c7185531d90
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\io/mod.rs:1516
2: 0x4603fb - std::io::impls::<impl std::io::Write for alloc::boxed::Box<W>>::write_fmt::h6f6daa32b1c2a916
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\io/impls.rs:179
3: 0x474e7a - std::sys_common::backtrace::_print::hc2f2ae8a2de1951b
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:61
4: 0x474e7a - std::sys_common::backtrace::print::h3766cc9baca05bc8
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:48
5: 0x474e7a - std::panicking::default_hook::{{closure}}::h46a919c0bf907afe
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:208
6: 0x474b0e - std::panicking::default_hook::hc08848c5073d9694
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:224
7: 0x47553b - std::panicking::rust_panic_with_hook::h0cea3fe379539d48
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:577
8: 0x4751b2 - std::panicking::begin_panic_handler::{{closure}}::h4309871eae5bd138
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:484
9: 0x471bed - std::sys_common::backtrace::__rust_end_short_backtrace::h81ee9a5814303916
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:153
10: 0x475173 - rust_begin_unwind
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:483
11: 0x475122 - std::panicking::begin_panic_fmt::h09febdf1830100f4
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:437
12: 0x40193e - libR_sys::bindgen_test_layout___mingw_ldbl_type_t::h29799f4b51cd0da4
13: 0x4018a8 - libR_sys::bindgen_test_layout___mingw_ldbl_type_t::{{closure}}::hbfb7aff559cfe3e0
14: 0x4017d8 - core::ops::function::FnOnce::call_once::h614c99b5966abcde
15: 0x4290d6 - core::ops::function::FnOnce::call_once::h83e7561c518a8a48
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\core\src\ops/function.rs:227
16: 0x4290d6 - test::__rust_begin_short_backtrace::h90b11f61009b2e83
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:516
17: 0x427948 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8c86ac279728e24
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
18: 0x427948 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h2c82c02427f67527
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:308
19: 0x427948 - std::panicking::try::do_call::h6c28e5eff59b27d8
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:381
20: 0x427948 - std::panicking::try::ha356e80f88bfb021
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:345
21: 0x427948 - std::panic::catch_unwind::h6382aaa1f9c058d4
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:382
22: 0x427948 - test::run_test_in_process::h4409fa3820453ce1
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:543
23: 0x427948 - test::run_test::run_test_inner::{{closure}}::hab3d81435f5f1c26
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:449
24: 0x402085 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbf6e7f2154633f10
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\sys_common/backtrace.rs:137
25: 0x407f8a - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::h8ce8ddd14af0ac44
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\thread/mod.rs:464
26: 0x407f8a - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hc91973fe6d3d7749
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:308
27: 0x407f8a - std::panicking::try::do_call::hc9a2a154e6245402
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:381
28: 0x407f8a - std::panicking::try::hccfa1cfc786c6746
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:345
29: 0x407f8a - std::panic::catch_unwind::h15f4b4dfb90d6aa7
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:382
30: 0x407f8a - std::thread::Builder::spawn_unchecked::{{closure}}::hd39261c1641a1b8a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\thread/mod.rs:463
31: 0x407f8a - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0d2c8144d1ade409
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\core\src\ops/function.rs:227
32: 0x481e5b - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h47540c09aa657433
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
33: 0x481e5b - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h23f63b1f1783f38a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
34: 0x481e5b - std::sys::windows::thread::Thread::new::thread_start::h86e8623cdc9f64d6
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys\windows/thread.rs:56
35: 0x7736fa29 - <unknown>
36: 0x775d75f4 - <unknown>
37: 0x775d75c4 - <unknown>
---- bindgen_test_layout_max_align_t stdout ----
thread 'bindgen_test_layout_max_align_t' panicked at 'assertion failed: `(left == right)`
left: `16`,
right: `24`: Size of: max_align_t', C:\Users\[redacted]\OneDrive\Development\Playground\libR-sys\target\i686-pc-windows-gnu\release\build\libR-sys-3b2a1ee2f7fff495\out/bindings.rs:2651:5
stack backtrace:
0: 0x4d1d1b - core::fmt::write::h3a9c091b8ca4c7a7
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\core\src\fmt/mod.rs:1080
1: 0x402bb4 - std::io::Write::write_fmt::h55320c7185531d90
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\io/mod.rs:1516
2: 0x4603fb - std::io::impls::<impl std::io::Write for alloc::boxed::Box<W>>::write_fmt::h6f6daa32b1c2a916
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\io/impls.rs:179
3: 0x474e7a - std::sys_common::backtrace::_print::hc2f2ae8a2de1951b
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:61
4: 0x474e7a - std::sys_common::backtrace::print::h3766cc9baca05bc8
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:48
5: 0x474e7a - std::panicking::default_hook::{{closure}}::h46a919c0bf907afe
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:208
6: 0x474b0e - std::panicking::default_hook::hc08848c5073d9694
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:224
7: 0x47553b - std::panicking::rust_panic_with_hook::h0cea3fe379539d48
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:577
8: 0x4751b2 - std::panicking::begin_panic_handler::{{closure}}::h4309871eae5bd138
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:484
9: 0x471bed - std::sys_common::backtrace::__rust_end_short_backtrace::h81ee9a5814303916
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys_common/backtrace.rs:153
10: 0x475173 - rust_begin_unwind
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:483
11: 0x475122 - std::panicking::begin_panic_fmt::h09febdf1830100f4
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src/panicking.rs:437
12: 0x40188e - libR_sys::bindgen_test_layout_max_align_t::h374144ebd117569d
13: 0x4017f8 - libR_sys::bindgen_test_layout_max_align_t::{{closure}}::h8be0742b37d54879
14: 0x4017c8 - core::ops::function::FnOnce::call_once::h0a57d00c7b916612
15: 0x4290d6 - core::ops::function::FnOnce::call_once::h83e7561c518a8a48
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\core\src\ops/function.rs:227
16: 0x4290d6 - test::__rust_begin_short_backtrace::h90b11f61009b2e83
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:516
17: 0x427948 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8c86ac279728e24
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
18: 0x427948 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h2c82c02427f67527
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:308
19: 0x427948 - std::panicking::try::do_call::h6c28e5eff59b27d8
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:381
20: 0x427948 - std::panicking::try::ha356e80f88bfb021
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:345
21: 0x427948 - std::panic::catch_unwind::h6382aaa1f9c058d4
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:382
22: 0x427948 - test::run_test_in_process::h4409fa3820453ce1
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:543
23: 0x427948 - test::run_test::run_test_inner::{{closure}}::hab3d81435f5f1c26
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\test\src/lib.rs:449
24: 0x402085 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbf6e7f2154633f10
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\sys_common/backtrace.rs:137
25: 0x407f8a - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::h8ce8ddd14af0ac44
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\thread/mod.rs:464
26: 0x407f8a - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hc91973fe6d3d7749
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:308
27: 0x407f8a - std::panicking::try::do_call::hc9a2a154e6245402
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:381
28: 0x407f8a - std::panicking::try::hccfa1cfc786c6746
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panicking.rs:345
29: 0x407f8a - std::panic::catch_unwind::h15f4b4dfb90d6aa7
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src/panic.rs:382
30: 0x407f8a - std::thread::Builder::spawn_unchecked::{{closure}}::hd39261c1641a1b8a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\std\src\thread/mod.rs:463
31: 0x407f8a - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0d2c8144d1ade409
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\core\src\ops/function.rs:227
32: 0x481e5b - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h47540c09aa657433
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
33: 0x481e5b - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h23f63b1f1783f38a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\library\alloc\src/boxed.rs:1042
34: 0x481e5b - std::sys::windows::thread::Thread::new::thread_start::h86e8623cdc9f64d6
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\/library\std\src\sys\windows/thread.rs:56
35: 0x7736fa29 - <unknown>
36: 0x775d75f4 - <unknown>
37: 0x775d75c4 - <unknown>
failures:
bindgen_test_layout___mingw_ldbl_type_t
bindgen_test_layout_max_align_t
test result: FAILED. 17 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
[1] 1
error: test failed, to rerun pass '--lib'
clang version 11.0.0 (https://github.com/msys2/MINGW-packages c0083b9edc111315c868f9c53dd60aaa78d1669b)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\tools\msys64\mingw64\bin
[1] "i386"
Using the R executable to find R_HOME is almost certainly the wrong approach and I already have a PR pending to fix this: KyleMayes/clang-sys#12
It's possible that we need the build script to detect whether it's trying to build a 32bit or a 64bit target and modify the paths accordingly. Could you post the typical path layout on Windows when both 32bit and 64bit versions are installed? Do they use two different R_HOME values or are they nested under one single R_HOME? Where are the include files (e.g. Rinternals.h)? Where are the library files (something like libR.dll)?
@clauswilke,
So the layout is typically like this:
There is a default Program Files\R folder, to where all versions go (unless the user modified it during installation). In my case, it can look like this:
Here, R.exe is a 64-bit app and I guess this bin folder is added to the PATH.
Now, both x64 and i386 contain a full set of .exe apps and .dll, which are platform-specific, e.g.
So, to build a 32- or 64- bit project, a correct R.dll should be linked. The current approach invokes 64-bit R and gets an ....\bin\x64\R.dll as include, while the correct one for i686 is ....\bin\i386\R.dll.
There is yet another way. Default R installation can write values to Registry. Depending on whether the installer was executed as admin (elevated) or not, values can be written to different places, but they can (probably) be tested during the build process. Examples: ls HKLM:\SOFTWARE\R-core\ gives
Hive: HKEY_LOCAL_MACHINE\SOFTWARE\R-core Name Property
---- --------
R InstallPath : C:\Program Files\R\R-4.0.3 Current Version : 4.0.3
R64 InstallPath : C:\Program Files\R\R-4.0.3 Current Version : 4.0.3
Rtools InstallPath : C:\rtools40 Current Version : 4.0
and ls HKLM:\SOFTWARE\R-core\R produces all currently active installation of R (32-bit).
So, for instance (using powershell for the sake of example), a query of the form "$(Get-ItemProperty HKLM:\SOFTWARE\R-core\R64 | select -expand "InstallPath")\bin\x64"
results in C:\Program Files\R\R-4.0.3\bin\x64
and "$(Get-ItemProperty HKLM:\SOFTWARE\R-core\R | select -expand "InstallPath")\bin\i386"
results in C:\Program Files\R\R-4.0.3\bin\i386 ,
which should give correct 64- and 32-bit paths no matter how R is installed.
So we have the same Rinternals.h but different R.dll. I think when compiling on Windows we need to set the correct library path depending on the target we're compiling for. That should be possible.
I have amended my PR KyleMayes/clang-sys#12 to set different library paths depending on the target architecture. But I can't test it since I don't have windows. Could you guys test it? Note that you'll have to set the R_HOME environment variable for this code branch to be executed.
I still see the same error on my MSYS2. The error @Ilia-Kosenkov described in #9 (comment) is solved, but the original one stays the same.
This error
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: [(C:\\...\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit)),
(C:\\...\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit))])"',
Try to print out the target thats used in the clang call for creating the
bindings in the build.rs file. Also, unrelated, the current settings makes
all terminal calls msys calls, and none are cmd or Powe shell. See the
default part of the msys setup.
On Sat, Dec 12, 2020, 14:29 Hiroaki Yutani ***@***.***> wrote:
I have merged KyleMayes/clang-sys#12 <#12>. Does
this close this issue?
I still see the same error on my MSYS2. The error @Ilia-Kosenkov
<https://github.com/Ilia-Kosenkov> described in KyleMayes/clang-rs#77 (comment)
<#9 (comment)> is
not solved, but the original one stays the same.
This error
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: [(C:\\...\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit)),
(C:\\...\\msys2\\current\\mingw32\\bin\\libclang.dll: invalid DLL (32-bit))])"',
comes from clang-sys crate's validation:
if cfg!(target_pointer_width = "64") && magic != 523 {
return Err("invalid DLL (32-bit)".into());
}
I really don't understand why target_pointer_width is 64 when we specify
the target of 32bit...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIDVSHTNC3WAFK6KDOKS3TSUNV47ANCNFSM4T3IANRQ>
.
On Sat, Dec 12, 2020, 15:19 Hiroaki Yutani ***@***.***> wrote:
Try to print out the target
Here's printed-out bindgen_builder.command_line_flags(). Is this the same
on your environment?
["wrapper.h", "--rust-target", "1.40", "--blacklist-item", "FP_NAN",
"--blacklist-item", "FP_INFINITE", "--blacklist-item", "FP_ZERO",
"--blacklist-item", "FP_SUBNORMAL", "--blacklist-item", "FP_NORMAL",
"--no-derive-default", "--generate",
"functions,types,vars,methods,constructors,destructors", "--",
"-IC:\\Program Files\\R\\R-4.0.2\\include", "--target=i686-pc-windows-gnu"]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIDVSHWU3N4VIYMJYWFP43SUN3Y5ANCNFSM4T3IANRQ>
.
Yeah, I think we are stuck in front of the same problem...
This seems because cargo looks for the default toolchain even when we specify target. If I switch the default toolchain to 32-bit,
rustup default stable-i686-pc-windows-gnu
I can pass the validation, but I still get this error (the message says "The specified procedure could not be found." Sorry I don't know how to show English messages...):
thread 'main' panicked at 'Unable to find libclang: "the libclang shared library at C:\\msys64\\mingw32\\bin\\libclang.dll could not be opened: 指定されたプロシージャが見つかりません。 (os error 127)"', C:\Users\hiroaki-yutani\.cargo\registry\src\github.com-1285ae84e5963aae\bindgen-0.53.3\src/lib.rs:1956:31
it seems GitHub Actions runner already has it installed. I tried to install mingw32/mingw-w64-i686-clang on GitHub Actions CI runner, but it says it's up to date.
C:\windows\system32\cmd.exe /D /S /C D:\a\_temp\msys\msys2.cmd -c "'pacman' '--noconfirm' '-S' '--needed' '--overwrite' '*' 'mingw32/mingw-w64-i686-clang' 'mingw-w64-i686-toolchain'"
warning: mingw-w64-i686-clang-11.0.0-4 is up to date -- skipping
warning: mingw-w64-i686-binutils-2.35.1-3 is up to date -- skipping
warning: mingw-w64-i686-crt-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gcc-ada-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gcc-fortran-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gcc-libgfortran-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gcc-libs-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gcc-objc-10.2.0-5 is up to date -- skipping
warning: mingw-w64-i686-gdb-10.1-1 is up to date -- skipping
warning: mingw-w64-i686-gdb-multiarch-10.1-1 is up to date -- skipping
warning: mingw-w64-i686-headers-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-libmangle-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-libwinpthread-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-make-4.3-1 is up to date -- skipping
warning: mingw-w64-i686-pkgconf-1.7.3-5 is up to date -- skipping
warning: mingw-w64-i686-tools-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-winpthreads-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
warning: mingw-w64-i686-winstorecompat-git-9.0.0.6029.ecb4ff54-1 is up to date -- skipping
Side note: I find it so confusing to figure out what is and isn't already installed in the GitHub Actions runner. And if you once install something and then remove the install line it still remains in the cache. I wish there was an easy way to just clear the cache.
@clauswilke, --release has no effect - still fails both ways.
However, I put an example code using c++, in particular, msvc.
Strangely, it works fine for both x64 and x86, meaning I dynamically load dll, find two functions, invoke them, free resources.
The only difference so far is that I use simple LoadLibraryW, while rust fails with error at LoadLibraryExW, which has additional flags. I will try playing with LoadLibraryExW to see if it fails under certain conditions.
I can share a repo which can be reviewed and tested -- if needed.
Building from source is another step, I think there still maybe some rust-related issue there.
This is getting weirder and weirder with every step.
In short, cargo run fails on a sample project, however if cargo build and then just execute the *.exe -- everything works fine.
If anyone is testing my rust_clang_run, could you please invoke the output .exe manually?
I have removed this issue from the milestone for the next libR-sys release. It isn't immediately show-stopping, as I've now a set of manually fixed-up bindings that work for now. We should still try to get the i686 libclang issue resolved, though.
It feels like we have enough to go and ask 'rust' people about this issue. Clearly it is neither 'msys'/'mingw' nor 'clang' (I called the latter from x86 C++ app with no problem).
With the answers we got from other teams & the successful deployment of our own GitHub CI, should this issue be closed? README contains all the necessary information on how to build on windows, including i686.
Activity
Ilia-Kosenkov commentedon Nov 28, 2020
Hi @CGMossa,
Did you have any success building against
i686?There is one issue with the building process - the library relies heavily on the
Rexecutable (present inPATH) to determineR-specific indlude directories. On64-bit systemPATHusually containsx64folder ofR, meaninglibR-sysis linking against64-bit version ofR.dll, and ultimately fails.Another thing I have no explanation for - my path contains both
mingw32andmingw64, and by default a64-bitclangis invoked. If I leave onlymingw32, I get the exactly same error as you have posted.However, with
mingw64andi386Ron the path, the library can be built and tests can be run, but two of them fail (looks like some native integer/pointer size mismatch). I have no experience inbindgenand cannot comment on that, but I attach a detailed stacktrace.I do not understand why the pipeline is able to build a
32-bit app and link agains32-bit version ofR.dllwhile using64-bitclangand libraries, this is beyond me.Below is the result of
$(echo $env:RUST_BACKTRACE ; cargo test --release --target=i686-pc-windows-gnu ; clang -v ; Rscript.exe -e '.Platform$r_arch') *>&1 > dump.txtdump.txt
clauswilke commentedon Nov 28, 2020
Using the R executable to find
R_HOMEis almost certainly the wrong approach and I already have a PR pending to fix this: KyleMayes/clang-sys#12It's possible that we need the build script to detect whether it's trying to build a 32bit or a 64bit target and modify the paths accordingly. Could you post the typical path layout on Windows when both 32bit and 64bit versions are installed? Do they use two different
R_HOMEvalues or are they nested under one singleR_HOME? Where are the include files (e.g.Rinternals.h)? Where are the library files (something likelibR.dll)?Ilia-Kosenkov commentedon Nov 28, 2020
@clauswilke,
So the layout is typically like this:
There is a default
Program Files\Rfolder, to where all versions go (unless the user modified it during installation). In my case, it can look like this:Details
Within
R-4.0.3Details
\includeDetails
and platform-specific
\binDetails
Here,
R.exeis a64-bit app and I guess thisbinfolder is added to thePATH.Now, both
x64andi386contain a full set of.exeapps and.dll, which are platform-specific, e.g.Details
So, to build a
32- or64- bit project, a correctR.dllshould be linked. The current approach invokes64-bitRand gets an....\bin\x64\R.dllas include, while the correct one fori686is....\bin\i386\R.dll.There is yet another way. Default
Rinstallation can write values to Registry. Depending on whether the installer was executed as admin (elevated) or not, values can be written to different places, but they can (probably) be tested during the build process. Examples:ls HKLM:\SOFTWARE\R-core\givesand
ls HKLM:\SOFTWARE\R-core\Rproduces all currently active installation ofR(32-bit).So, for instance (using powershell for the sake of example), a query of the form
"$(Get-ItemProperty HKLM:\SOFTWARE\R-core\R64 | select -expand "InstallPath")\bin\x64"results in
C:\Program Files\R\R-4.0.3\bin\x64and
"$(Get-ItemProperty HKLM:\SOFTWARE\R-core\R | select -expand "InstallPath")\bin\i386"results in
C:\Program Files\R\R-4.0.3\bin\i386,which should give correct
64- and32-bit paths no matter howRis installed.clauswilke commentedon Nov 28, 2020
So we have the same
Rinternals.hbut differentR.dll. I think when compiling on Windows we need to set the correct library path depending on the target we're compiling for. That should be possible.clauswilke commentedon Nov 28, 2020
I have amended my PR KyleMayes/clang-sys#12 to set different library paths depending on the target architecture. But I can't test it since I don't have windows. Could you guys test it? Note that you'll have to set the
R_HOMEenvironment variable for this code branch to be executed.clauswilke commentedon Dec 8, 2020
I have merged KyleMayes/clang-sys#12. Does this close this issue?
Note also the problem described in KyleMayes/clang-rs#82. @CGMossa, do you have this problem?
yutannihilation commentedon Dec 12, 2020
I still see the same error on my MSYS2. The error @Ilia-Kosenkov described in #9 (comment) is solved, but the original one stays the same.
This error
comes from clang-sys crate's validation:
I really don't understand why
target_pointer_widthis64when we specify the target of 32bit...CGMossa commentedon Dec 12, 2020
yutannihilation commentedon Dec 12, 2020
Here's printed-out
bindgen_builder.command_line_flags(). Is this the same on your environment?CGMossa commentedon Dec 12, 2020
yutannihilation commentedon Dec 12, 2020
Yeah, I think we are stuck in front of the same problem...
This seems because
cargolooks for the default toolchain even when we specifytarget. If I switch the default toolchain to 32-bit,I can pass the validation, but I still get this error (the message says "The specified procedure could not be found." Sorry I don't know how to show English messages...):
clauswilke commentedon Dec 12, 2020
I think what is happening is that
cargouses the default toolchain to compilebuild.rs, and then runsbuild.rswith the specific compile target.If you switch the default toolchain, you also need a 32-bit clang. Did you install that? The github action does not.
yutannihilation commentedon Dec 12, 2020
Yes, I just followed https://github.com/extendr/libR-sys#windows-specific-instructions
Btw,
it seems GitHub Actions runner already has it installed. I tried to install
mingw32/mingw-w64-i686-clangon GitHub Actions CI runner, but it says it's up to date.(from my test branch: https://github.com/yutannihilation/libR-sys/runs/1542066028?check_suite_focus=true#step:3:33)
clauswilke commentedon Dec 12, 2020
Side note: I find it so confusing to figure out what is and isn't already installed in the GitHub Actions runner. And if you once install something and then remove the install line it still remains in the cache. I wish there was an easy way to just clear the cache.
24 remaining items
Ilia-Kosenkov commentedon Dec 16, 2020
@clauswilke,
--releasehas no effect - still fails both ways.However, I put an example code using
c++, in particular,msvc.Strangely, it works fine for both
x64andx86, meaning I dynamically loaddll, find two functions, invoke them, free resources.The only difference so far is that I use simple
LoadLibraryW, whilerustfails with error atLoadLibraryExW, which has additional flags. I will try playing withLoadLibraryExWto see if it fails under certain conditions.I can share a repo which can be reviewed and tested -- if needed.
Building from source is another step, I think there still maybe some
rust-related issue there.Ilia-Kosenkov commentedon Dec 16, 2020
This is getting weirder and weirder with every step.
In short,
cargo runfails on a sample project, however ifcargo buildand then just execute the*.exe-- everything works fine.If anyone is testing my
rust_clang_run, could you please invoke the output.exemanually?clauswilke commentedon Dec 16, 2020
Interesting! Can you reproduce this in the GH action? Run
cargo build, run the*.exe, and then run it again withcargo run?Ilia-Kosenkov commentedon Dec 16, 2020
Did not try running it with
cargo runafterwards, just created separate jobs.Here is the last report https://github.com/Ilia-Kosenkov/rust_clang_run/actions/runs/426337151.
Jobs that are called
Run i686do build and then run executable, other jobs docargo runonly.clauswilke commentedon Dec 16, 2020
I have removed this issue from the milestone for the next libR-sys release. It isn't immediately show-stopping, as I've now a set of manually fixed-up bindings that work for now. We should still try to get the i686 libclang issue resolved, though.
Ilia-Kosenkov commentedon Dec 16, 2020
It feels like we have enough to go and ask 'rust' people about this issue. Clearly it is neither 'msys'/'mingw' nor 'clang' (I called the latter from x86 C++ app with no problem).
clauswilke commentedon Dec 16, 2020
Agreed. We can file an issue with cargo: https://github.com/rust-lang/cargo
Do you want to do this or do you prefer if I do so?
Ilia-Kosenkov commentedon Dec 17, 2020
@clauswilke,
If you can do that, please do.
I will participate and provide clarifications of what I found if needed.
clauswilke commentedon Dec 17, 2020
Issue filed with cargo: rust-lang/cargo#8990
Ilia-Kosenkov commentedon Dec 18, 2020
Following suggestions from
rust/cargopeople, I was able to buildi686and test*libR-syswithout pre-built bindings.* because of
PATHresolution issue (see KyleMayes/clang-rs#91), ifPATHis updated to explicitly include onlyR_HOME\bin\i386, thenalso works.
mati865 commentedon Dec 19, 2020
I think cross-compiling from any Windows toolchain, even
x86_64-gnuwould work here.Ilia-Kosenkov commentedon Dec 22, 2020
With the answers we got from other teams & the successful deployment of our own GitHub CI, should this issue be closed?
README contains all the necessary information on how to build on windows, including
i686.clauswilke commentedon Dec 22, 2020
Yes, agreed. If new problems crop up we can open a new issue.