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

Add LLVM.init_native_target and LLVM.init_all_targets #15466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Feb 13, 2025

LLVM's targets need to be initialized before they can be used. The Crystal compiler does this in Crystal::Codegen::Target#to_target_machine, but for external code that uses the LLVM wrappers directly, there is no simple way to do this. This PR adds two convenience methods which are more or less equivalent to LLVM's LLVMInitializeNativeTarget and LLVMInitializeAllTargets, both static line functions in llvm-c/Target.h, except the latter only initializes targets already supported by Crystal itself (e.g. no RISC-V or PowerPC at the moment even if llvm-config indicates their availability).

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants