Skip to content

using rustbuild breaks compiling against system llvm when linked against libffi #39880

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

Closed
ht990332 opened this issue Feb 16, 2017 · 8 comments
Closed
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@ht990332
Copy link

I get the following error:
rust undefined reference to `ffi_type_double'

There was a workaround that helped in the past but it doesn't anymore.

@nagisa
Copy link
Member

nagisa commented Feb 16, 2017

That’s most likely because your system llvm-config does not print -lffi in

$ llvm-config --system-libs
-lrt -ldl -lcurses -lpthread -lz -lm -lffi

That’s a bug in your system LLVM. Workaround is to put something like

#!/usr/bin/bash
/usr/bin/llvm-config "$@" | sed 's/-lm/-lm -lffi/'

in your path (so the script would execute instead of the actual llvm-config, when llvm-config is invoked)

@ht990332
Copy link
Author

ht990332 commented Feb 16, 2017

I will try that now. Than you.
Edit: It didn't help. Maybe I need to patch llvm instead?

@kyrias
Copy link
Contributor

kyrias commented Mar 3, 2017

Yeah, I'm currently trying to build rust 1.15.1 for Arch, and I've tried both the old setting RUSTFLAGS to -C link-args=-lffi approach, and making llvm-config a wrapper script that adds it, but neither works anymore. Not sure how it decides the CFLAGS it uses now.

@ht990332
Copy link
Author

ht990332 commented Mar 3, 2017

I noticed Fedora is using --disable-rustbuild http://pkgs.fedoraproject.org/cgit/rpms/rust.git/tree/rust.spec#n260 which retains the old behavior.

@kyrias
Copy link
Contributor

kyrias commented Mar 3, 2017

Just discovered that it's a regression in llvm(-config). On e.g. debian it is included in llvm-config, and if I download the Arch package for the same llvm version it also outputs -lffi there, so seems to have been a regression between LLVM 3.5 and 3.9. Would need help from some LLVM people to figure out what changed though.

@cuviper
Copy link
Member

cuviper commented Mar 3, 2017

I noticed Fedora is using --disable-rustbuild http://pkgs.fedoraproject.org/cgit/rpms/rust.git/tree/rust.spec#n260 which retains the old behavior.

For 1.15, yes, as I haven't transitioned yet. I hope to use rustbuild for 1.16.

Fedora doesn't normally use static linking, but it's an option, and you can see my ffi workaround here:
http://pkgs.fedoraproject.org/cgit/rpms/rust.git/tree/rust.spec#n233

I still think llvm-config --link-static --system-libs ought to output -lffi itself though. It was mentioned in #34486 (comment) that llvm-config has a FIXME about this, which is still there in the latest sources.

japaric pushed a commit to japaric/rust that referenced this issue Apr 7, 2017
committed by mistake
@Mark-Simulacrum Mark-Simulacrum added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label May 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@Mark-Simulacrum
Copy link
Member

I take it this isn't a problem on Rust's side, so closing. If I'm wrong please let us know!

dylanmckay added a commit to avr-rust/rust-legacy-fork that referenced this issue Sep 25, 2017
This shouldn't need to be in tree, but I'm committing it anyway because
it's a headache when compiling with a separate LLVM root.
shepmaster pushed a commit to avr-rust/rust-legacy-fork that referenced this issue Sep 28, 2017
This shouldn't need to be in tree, but I'm committing it anyway because
it's a headache when compiling with a separate LLVM root.
@tmccombs
Copy link
Contributor

is there an llvm issue open for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

6 participants