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

[LLVM] Use the LLVMInitializeAllTargets* functions #34962

Closed
3 tasks
nagisa opened this issue Jul 21, 2016 · 4 comments
Closed
3 tasks

[LLVM] Use the LLVMInitializeAllTargets* functions #34962

nagisa opened this issue Jul 21, 2016 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@nagisa
Copy link
Member

nagisa commented Jul 21, 2016

LLVM has the functions to initialize all supported targets already. We should get rid of this monstrosity and use the functions instead.

The problem is that these functions are currently static inline and thus have no symbol of their own. In order to be able to use them in rustc, we need to create a binding for it.

For now the migration would look something like this:

  • Implement RustLLVMInitializeAll{Targets,TargetInfos,TargetMCs,AsmPrinters,AsmParsers} in rust_llvm. These would call the static inline counterparts directly.
  • initialize_available_targets gets changed to call newly created wrappers;
  • Make sure our distribution LLVM is only compiled with the targets that we want to support (x86, ARM, Aarch64, MIPS, PNaCl);

cc @rust-lang/compiler

I also would consider this as an E-easy issue. The general direction for fixing this issue are listed above and this issue would help to understand how LLVM initialisation works and how rustc ties into the LLVM.


Once something like this patch lands and gets into all LLVM versions we support we could then remove the wrapper altogether.

@eddyb
Copy link
Member

eddyb commented Jul 21, 2016

Do we get any benefits from this, if we still support older LLVM versions? cc @alexcrichton @badboy

@nagisa
Copy link
Member Author

nagisa commented Jul 21, 2016

Primary benefit is an ability to target rustc at stuff other than the list of targets we currently hardcode if LLVM is not distributed by us (linked dynamically by distro or something).

@nagisa
Copy link
Member Author

nagisa commented Jul 21, 2016

Secondary benefit is that it would not force the dynamically linked LLVM to actually provide all those targets (i.e. if some distro distributes LLVM which can only do some of the targets we currently hardcode).

Of course that would introduce an error-case for this call which would need to be checked for and reported appropriately.

@sanxiyn sanxiyn added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jul 22, 2016
@nagisa
Copy link
Member Author

nagisa commented Jul 23, 2016

Apparently the LLVMInitializeAllTarget* stuff is all static inline, which is why I never noticed them before.

I adjusted the PR text to account for the new knowledge.

nagisa added a commit to nagisa/rust that referenced this issue Jul 28, 2016
Primary benefit of this change is that Rust now can support all LLVM targets which the LLVM that
has been linked to supports. Namely, this if the system LLVM, which supports extra targets, is
used, then rustc could also build code for them.

Fixes rust-lang#34962
@nagisa nagisa closed this as completed Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Projects
None yet
Development

No branches or pull requests

3 participants