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

Couldn't compile #422

Closed
Larsouille25 opened this issue May 25, 2023 · 5 comments
Closed

Couldn't compile #422

Larsouille25 opened this issue May 25, 2023 · 5 comments

Comments

@Larsouille25
Copy link

Describe the Bug
I've just git clone the workspace checkout the last stable release, 0.2.0 and I wanted to run the kaleidoscope example, but I found cargo very unhappy,

To Reproduce

  1. git clone https://github.com/TheDan64/inkwell
  2. cargo run --example kaleidoscope

Expected Behavior
The kaleidoscope program should open.

LLVM Version (please complete the following information):

  • LLVM Version: 15.0.7
  • Inkwell Branch Used: on tag 0.2.0

Desktop (please complete the following information):

  • OS: Arch Linux, yes an error exist with LLVM 15.0.7 and Arch Linux but I fixed it so it's not that (i think)

Additional Context
An extract of the errors messages :

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMIsGlobalConstant` in this scope
   --> src/values/global_value.rs:191:18
    |
191 |         unsafe { LLVMIsGlobalConstant(self.as_value_ref()) == 1 }
    |                  ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMSetGlobalConstant` in this scope
   --> src/values/global_value.rs:195:18
    |
195 |         unsafe { LLVMSetGlobalConstant(self.as_value_ref(), is_constant as i32) }
    |                  ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMIsExternallyInitialized` in this scope
   --> src/values/global_value.rs:199:18
    |
199 |         unsafe { LLVMIsExternallyInitialized(self.as_value_ref()) == 1 }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMSetExternallyInitialized` in this scope
   --> src/values/global_value.rs:203:18
    |
203 |         unsafe { LLVMSetExternallyInitialized(self.as_value_ref(), externally_initialized as i32) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `externally_initialized`

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMSetVisibility` in this scope
   --> src/values/global_value.rs:207:18
    |
207 |         unsafe { LLVMSetVisibility(self.as_value_ref(), visibility.into()) }
    |                  ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMGetVisibility` in this scope
   --> src/values/global_value.rs:211:35
    |
211 |         let visibility = unsafe { LLVMGetVisibility(self.as_value_ref()) };
    |                                   ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDeleteGlobal` in this scope
   --> src/values/global_value.rs:227:9
    |
227 |         LLVMDeleteGlobal(self.as_value_ref())
    |         ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMGetAlignment` in this scope
   --> src/values/global_value.rs:235:18
    |
235 |         unsafe { LLVMGetAlignment(self.as_value_ref()) }
    |                  ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMSetAlignment` in this scope
   --> src/values/global_value.rs:239:18
    |
239 |         unsafe { LLVMSetAlignment(self.as_value_ref(), alignment) }
    |                  ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMGetLinkage` in this scope
   --> src/values/global_value.rs:287:18
    |
287 |         unsafe { LLVMGetLinkage(self.as_value_ref()).into() }
    |                  ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `LLVMSetLinkage` in this scope
   --> src/values/global_value.rs:291:18
    |
291 |         unsafe { LLVMSetLinkage(self.as_value_ref(), linkage.into()) }
    |                  ^^^^^^^^^^^^^^ not found in this scope

error[E0599]: no method named `get_type` found for struct `fn_value::FunctionValue` in the current scope
   --> src/values/callable_value.rs:100:40
    |
100 |             Left(function) => function.get_type().as_type_ref(),
    |                                        ^^^^^^^^ method not found in `FunctionValue<'_>`
    |
   ::: src/values/fn_value.rs:33:1
    |
33  | pub struct FunctionValue<'ctx> {
    | ------------------------------ method `get_type` not found for this struct

error[E0599]: no method named `get_element_type` found for struct `ptr_type::PointerType` in the current scope
   --> src/values/callable_value.rs:101:50
    |
101 |             Right(pointer) => pointer.get_type().get_element_type().as_type_ref(),
    |                                                  ^^^^^^^^^^^^^^^^ method not found in `PointerType<'_>`
    |
   ::: src/types/ptr_type.rs:18:1
    |
18  | pub struct PointerType<'ctx> {
    | ---------------------------- method `get_element_type` not found for this struct

Some errors have detailed explanations: E0046, E0412, E0425, E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0046`.
warning: `inkwell` (lib) generated 11 warnings
error: could not compile `inkwell` due to 220 previous errors; 11 warnings emitted
@Daniel-Boll
Copy link

Hello, @Larsouille25. The issue you encountered is primarily related to the inability of llvm_sys to dynamically link with LLVM 15. It appears that Arch Linux only provides dynamically linked LLVM packages.

To address this problem and make your project work, you can make use of the following configuration:

inkwell = { version = "0.2", features = ["llvm15-0"] }
llvm-sys-150 = { package = "llvm-sys", version = "150.1.0", features = ["prefer-dynamic"] }

These configurations should help you resolve the issue and enable a new project to work smoothly with LLVM 15 on Arch Linux. As of the example execution I don't know how one would change the feature to be added automatically in the main cargo.toml from inkwell.

Best Regards,
Daniel Boll. 🎴

@Larsouille25
Copy link
Author

Larsouille25 commented May 25, 2023

Hello, @Daniel-Boll, thanks for the solution but, when in my crate I have inkwell = { version = "0.2.0", features = ["llvm15-0"] } in the Cargo.toml file, that's just working fine. But when I try to compile inkwell (on the same PC), that's not working

@TheDan64
Copy link
Owner

@Larsouille25 Did you specify --features llvm15-0 via the cli?

@Larsouille25
Copy link
Author

The error is solved (forgot to close), it's specific to arch linux and LLVM 15.0.7, to solve the issue you need to download headers of llvm and create an env var that points to the llvm headers

@Larsouille25
Copy link
Author

See issue #405

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

3 participants