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
mainly tested on 1.4.0, but I also tested nightly.
this may be a compiler bug, but I'm not sure. So here is what I know is going on. I have the following code which was generated by crabtw/bindgen and is intended to work over a union in a c library (part of the relevant code to not make it too noisy):
I'm showing only the impl for the cache part, but the other union variants work exactly the same way. The struct fields are public in the cache one for testing purposes, of course ideally I only have the getters. Now I have some code which does its unsafe job to dereference the pointers and ultimately get to the members of the struct.
Now here comes the important stuff. When I call it like this, the compiler fails on linking:
note: ld: warning: directory not found for option '-L/Users/michael/rust/hwloc-rs/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/michael/rust/hwloc-rs/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
"topology_object::TopologyObjectCacheAttributes::size::h5726f74039bc15c7uMa", referenced from:
main::hf733474fad67530eiaa in processor_cache.0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
But when I change it to direct struct member access (not going through the getter) it works! So this compiles fine and runs as expected in my test code:
Are struct TopologyObjectCacheAttributes and fn size public enough in the original not reduced code?
By "public enough" here I mean "can be named from other crates".
If they are defined in some private inner module and can't be named from other crates, then it may be a duplicate of #16734
Ah, I see, the full code is available in https://github.com/daschl/hwloc-rs
It is indeed the same problem as in #16734
Try to insert pub use topology_object::TopologyObjectCacheAttributes; into src/lib.rs, the problem should go away.
Hi folks,
mainly tested on 1.4.0, but I also tested nightly.
this may be a compiler bug, but I'm not sure. So here is what I know is going on. I have the following code which was generated by crabtw/bindgen and is intended to work over a union in a c library (part of the relevant code to not make it too noisy):
I'm showing only the impl for the cache part, but the other union variants work exactly the same way. The struct fields are public in the cache one for testing purposes, of course ideally I only have the getters. Now I have some code which does its
unsafe
job to dereference the pointers and ultimately get to the members of the struct.This is called like:
Now here comes the important stuff. When I call it like this, the compiler fails on linking:
But when I change it to direct struct member access (not going through the getter) it works! So this compiles fine and runs as expected in my test code:
I'm not an expert in rust so I have a hard time providing a smaller test case. If someone wants to run the code you can clone the repo and run the example (https://github.com/daschl/hwloc-rs/blob/master/examples/processor_cache.rs#L20) -
$ cargo run --example processor_cache
.Just make sure to have the hwloc library installed (1.11.1, from here https://www.open-mpi.org/software/hwloc/v1.11/), just plain configure, make, sudo make install.
The text was updated successfully, but these errors were encountered: