Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relocation R_X86_64_32 against `.rodata' can not be used when making a shared object #3

Closed
JeanMertz opened this issue Jun 21, 2019 · 7 comments
Assignees

Comments

@JeanMertz
Copy link

Thank you for this crate, and the json-query project.

I've been working with the crate recently, and things are working wonderfully. I'm using the bundled feature of json-query to support statically linking to the required libjq dependency.

This worked on macOS, and also in an "alpine" based container, but I've since pushed my code changes and it seems that Travis is having some issues.

Travis is running the Ubuntu Xenial release and it's throwing the following error:

  = note: /usr/bin/ld: /home/travis/build/blendle/automaat/target/debug/deps/libjq_sys-e398fc3ed0925020.rlib(execute.o):
relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; 
recompile with -fPIC
          /home/travis/build/blendle/automaat/target/debug/deps/libjq_sys-e398fc3ed0925020.rlib: error adding symbols: Bad value
          collect2: error: ld returned 1 exit status

The build is publicly available here.

I've cleared the Travis cache, but the problem did not go away. The compiler is pretty clear with the recompile with -fPIC message, but I'm not quite sure how or where to pass those flags (or if it would even solve the problem).

Do you have any pointers that I could follow to debug this problem? Thanks!

@onelson
Copy link
Owner

onelson commented Jun 22, 2019

The makefile generated by autotools et al does set -fPIC if I remember correctly. I'll use this as an invitation to finally setup travis for this repo and see if I can learn something about this. No idea off the top of my head.

As far as the crate is concerned, it treats the autotools build mostly as a black box. We link dynamic during development (since it's quicker to just depend on a distro .so) and build jq from source ourselves for production. I'm delighted to hear you were actually able to use this crate in alpine... I never thought to try it. At any rate, I'll try to reproduce and see if I can learn something.

Thanks for reporting!

@onelson onelson self-assigned this Jun 22, 2019
@JeanMertz
Copy link
Author

One more thing I noticed, that I can't quite explain, is that in the linked CI build above, the cargo build --all-features succeeds while the cargo test --all-features following thereafter fails to build.

I fail to see why one would succeed without compilation errors, and the other one wouldn't.

@onelson
Copy link
Owner

onelson commented Jun 22, 2019

Yeah, I can't explain it either, however, I've been able to reproduce this in the jq-sys crate (now that I have travis setup for it). Running cargo test --features bundled will fail over there, even while building my testcrate (in this repo) will succeed.

Still, I think I've got a resolution on the way. I've got the CI for this crate now pulling in jq-sys so I can run a sort of integration test against it, leveraging the autogenerated bindgen test suite, and it looks like it's passing on travis with a small mod to the make invocation.

While I don't think it should be needed, and I don't know why it would be required when running in travis but not elsewhere, passing CFLAGS=-fPIC to make seems to paper over the issue.

@JeanMertz
Copy link
Author

Still, I think I've got a resolution on the way.

Great to hear!

I'm relatively new to Rust, and only just picked up my first C book, so those flags are all magic to me, but I'm glad you knew where to look 😄.

@onelson
Copy link
Owner

onelson commented Jun 22, 2019

I'm planning to cut a release this weekend, but if possible please add a patch to your Cargo.toml and re-run your travis job to verify the fix works for you.

[patch.crates-io]
jq-src = { git = "https://github.com/onelson/jq-src", branch = "master" }

@JeanMertz
Copy link
Author

Thank you! And indeed, applying your patch solved the problem. 🎉

@onelson
Copy link
Owner

onelson commented Jun 23, 2019

Released as 0.4.1. Now, on to the next thing on the list!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants