by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    mloc
    @mloc
    is there any way to build a (const) GEP on an ArrayValue right now?
    or will that need an inkwell change
    urg. nevermind, again, got my head in a loop
    Sameer Rahmani
    @lxsameer
    hey folks, quick and silly question, is inkwell an active project ? how much of the LLVM api does it cover ?
    mloc
    @mloc
    is there a way to build an arbitrary intrinsic?
    specifically @llvm.pow.f32
    mloc
    @mloc
    is it acceptable to just add an fn with the correct name + types?
    there is LookupIntrinsicID + GetIntrinsicDeclaration but they don't seem necessary if you can do the overloading yourself
    (and it's not exposed by inkwell)
    Daniel Kolsoi
    @TheDan64
    @lxsameer it is indeed active. It covers most of the C API but there are still some gaps.
    @mloc I think you can add a fn with the right name and types so long as it's linked correctly. Newer versions of LLVM have a specific intrinsic getter method which we don't currently support (thanks for reminding me!)
    Sameer Rahmani
    @lxsameer
    @TheDan64 sorry to ask this silly question, but what's you plan for the future of this library ? basically i'm in doubt to use it or not because i'm afraid that this library might not get updates and fall behind llvm halfway through the project
    Daniel Kolsoi
    @TheDan64
    I definitely plan to continue maintaining inkwell and never just abandon it. I see the worst-case scenario (assuming I'm still alive lol) is that I don't have time to add new changes myself, but would still make time to review and accept changes from the community. There are a couple of companies using inkwell in production so they do occasionally submit PRs.
    The biggest blocker to inkwell 0.1.0 is rust-lang/cargo#2980 and there doesn't seem to be any resolution in sight but we do have / will have stopgap crates for specific llvm versions as they release. Adding support for a new LLVM version usually takes a bit of time and effort though
    Sameer Rahmani
    @lxsameer
    cool, thanks a mil
    DGriffin91
    @DGriffin91
    I'm considering using inkwell to implement a DSL compiler. Is there a way to bundle LLVM so the end user only needs to install the rust application I build, and not have to install LLVM separately? Is there an existing project that is already doing this that I could look at to see how they are doing it?
    Sameer Rahmani
    @lxsameer
    but as far as i know, you should be able to use llvm api to compile to the target code as well
    i might be wrong though
    DGriffin91
    @DGriffin91
    @lxsameer Thanks! I'll check it out.
    Daniel Kolsoi
    @TheDan64
    The problem with llvmenv is that it's no longer maintained and hard to use
    I managed to get it to install LLVM 7&8 but not 10...
    Huh, looks like the author released a new version in May. In any case, it was unmaintained and the author was unresponsive to issues for a long while. Hopefully that changes
    DGriffin91
    @DGriffin91
    @TheDan64 Good to know. Are there any other practical ways to accomplish this?
    Daniel Kolsoi
    @TheDan64
    Llvmenv might still be your best bet... LLVM is just a pain in general
    Daniel Kolsoi
    @TheDan64
    Aleksander Litynski
    @AleksLitynski
    Hello. I'm running into the simplest problem imaginable, and I can't get around it. I've spent several days reading about lifetimes and references counting, and it's still not clicking. How am I supposed to write code that does this - https://pastebin.com/yNJYQ2W8
    This breaks because line 10 borrows context, then line 13 returns the context, leaving create_builder with a broken reference. Most examples pass a 'context' into the new/create function so its address won't change when builder is allocated, but I'd really rather the user be able to call a single function to do all the setup for them.
    Ben Konz
    @benkonz

    Hi, I'm trying to create a simple executable with LLVM and Inkwell, but when I run my program, I get cannot execute binary file: Exec format error

    code:

        let context = Context::create();
        let module = context.create_module("brainfrick-rust");
        let builder = context.create_builder();
    
        let i32_type = context.i32_type();
        let i32_one = i32_type.const_int(10, false);
        let main_fn_type = i32_type.fn_type(&[], false);
    
        let main_fn_val = module.add_function("main", main_fn_type, None);
        let basic_block = context.append_basic_block(main_fn_val, "entry");
    
        builder.position_at_end(basic_block);
    
        builder.build_return(Some(&i32_one));
        Target::initialize_all(&InitializationConfig::default());
    
        let target_triple = TargetMachine::get_default_triple();
    
        let target = Target::from_triple(&target_triple).map_err(|e| format!("{:?}", e))?;
        let target_machine = target
            .create_target_machine(
                &target_triple,
                "generic",
                "",
                OptimizationLevel::Default,
                RelocMode::Default,
                CodeModel::Default,
            )
            .ok_or_else(|| "Unable to create target machine!".to_string())?;
    
        let output_filename = matches.value_of("output").unwrap();
        target_machine
            .write_to_file(&module, FileType::Object, output_filename.as_ref())
            .map_err(|e| format!("{:?}", e))?;
    anything I am leaving out?
    Ben Konz
    @benkonz
    found out what I'm leaving out. The object files need to be linked with clang, https://stackoverflow.com/questions/11657529/how-to-generate-an-executable-from-an-llvmmodule
    Daniel Kolsoi
    @TheDan64
    @AleksLitynski Sorry for the late response but your example won't work because you're essentially trying to make a self-referential struct and Rust doesn't support those very well today because they're super tricky to do
    You might be able to get away with it using the rental crate, maybe. But it's recommended to just pass the context reference in. (rental is also no longer maintained IIRC so it's hard to recommend)