Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    folkertdev
    @folkertdev:matrix.org
    [m]

    right. That's a shame because I don't need to actually do any linking. Anyway got that to mostly work, the final annoying thing is writing the output to a file or memory buffer outputs a bunch of stuff like this

    'pentium4' is not a recognized processor for this target (ignoring processor)
    '-16bit-mode' is not a recognized feature for this target (ignoring feature)
    '+32bit-mode' is not a recognized feature for this target (ignoring feature)

    is this something you get? or is there a way to silence it. I think I'm using the same settings as here https://github.com/seanyoung/solang/blob/main/src/emit/mod.rs#L5308

    Sean Young
    @seanyoung:matrix.org
    [m]
    Linking isn't just converting the object file into an executable; wasm-ld can do tricks like lto (link time optimization) several files. Having said that, it would be nice to be able to write an executable.
    'pentium4' is not a recognized processor for this target (ignoring processor)
    '-16bit-mode' is not a recognized feature for this target (ignoring feature)
    '+32bit-mode' is not a recognized feature for this target (ignoring feature)
    I've never this, where is this coming from?
    folkertdev
    @folkertdev:matrix.org
    [m]
    yes I'm more concerned at the moment with compile speed than runtime speed. invoking another process is not so great when I have 500 tests to run and every test has to do this
    Sean Young
    @seanyoung:matrix.org
    [m]
    folkertdev
    @folkertdev:matrix.org
    [m]

    This is my code

    Target::initialize_webassembly(&InitializationConfig::default());
    
    let triple = TargetTriple::create("wasm32-unknown-unknown-wasm");
    let target_machine = Target::from_name("wasm32")
        .unwrap()
        .create_target_machine(
            &triple,
            "",
            "", // TODO: this probably should be TargetMachine::get_host_cpu_features() to enable all features.
            inkwell::OptimizationLevel::None,
            inkwell::targets::RelocMode::Default,
            inkwell::targets::CodeModel::Default,
        )
        .unwrap();
    
    let file_type = inkwell::targets::FileType::Object;
    
    target_machine
        .write_to_file(llvm_module, file_type, &test_a_path)
        .unwrap();

    the final target_machine.write_to_file emits those lines

    Sean Young
    @seanyoung:matrix.org
    [m]
    I don't know how that is possible
    are you sure you are not passing the wrong arguments to wasm-ld?
    folkertdev
    @folkertdev:matrix.org
    [m]
    wasm-ld is not involved
    Sean Young
    @seanyoung:matrix.org
    [m]
    Does the llvm module you're compiling have the correct triple set? https://github.com/hyperledger-labs/solang/blob/main/src/emit/mod.rs#L5418-L5422
    folkertdev
    @folkertdev:matrix.org
    [m]

    I just added

        let triple = TargetTriple::create("wasm32-unknown-unknown-wasm");
    
        llvm_module.set_triple(&triple);

    but that makes no difference

    Sean Young
    @seanyoung:matrix.org
    [m]
    I don't know where those strings are coming from. Somewhere those pentium4 flags are being set for the target.
    folkertdev
    @folkertdev:matrix.org
    [m]
    ah, that might be the case actually
    those things are global right
    like Target::initialize_webassembly(&InitializationConfig::default());
    Sean Young
    @seanyoung:matrix.org
    [m]
    That is global, but that should be unrelated to this problem
    do you have any target cpu specifed?
    in your module or otherwise
    iow if you grep your code and other files for pentium4 is it somewhere there
    folkertdev
    @folkertdev:matrix.org
    [m]

    oh, I'm seeing this in the IR

    attributes #0 = { nobuiltin nounwind "target-cpu"="pentium4" "target-features"="-16bit-mode,+32bit-mode,-3dnow,-3dnowa,-64bit,-adx,-aes,-amx-bf16,-amx-int8,-amx-tile,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-bmi,-bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,-cx16,+cx8,-enqcmd,-ermsb,-f16c,-false-deps-lzcnt-tzcnt,-false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-7bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,-fast-scalar-fsqrt,-fast-scalar-shift-masks,-fast-shld-rotate,-fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,-fma,-fma4,-fsgsbase,-fsrm,+fxsr,-gfni,-hreset,-idivl-to-divb,-idivq-to-divl,-invpcid,-kl,-lea-sp,-lea-uses-ag,-lvi-cfi,-lvi-load-hardening,-lwp,-lzcnt,-macrofusion,+mmx,-movbe,-movdir64b,-movdiri,-mwaitx,+nopl,-pad-short-functions,-pclmul,-pconfig,-pku,-popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,-rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,-sahf,-serialize,-seses,-sgx,-sha,-shstk,-slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,+slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,+sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-sse-unaligned-mem,-ssse3,-tbm,-tsxldtrk,-uintr,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,-widekl,+x87,-xop,-xsave,-xsavec,-xsaveopt,-xsaves" }

    is that what this is?

    very much looks like it
    Sean Young
    @seanyoung:matrix.org
    [m]
    yes that looks like it
    where you getting your ir from?
    folkertdev
    @folkertdev:matrix.org
    [m]
    can I delete it (we have zig emitting a bunch of IR, so I think that's where it originates
    Sean Young
    @seanyoung:matrix.org
    [m]
    well if you have zig emitting IR, then make sure it's emitting ir for wasm. llvm ir not portable at all.
    (across cpus)
    I might just work because a pentium is a 32 bit little endian thing
    folkertdev
    @folkertdev:matrix.org
    [m]
    ok, thanks for all this. I know how to fix it in theory then, but sadly zig currently segfaults when trying to emit wasm code.
    muke 101
    @muke101_gitlab
    Hey, I've cloned the inkwell repo and if I just do a straight 'cargo build' I get an error for each and every LLVM C function call that it can't find it in the scope. I've tried to add the following rustflags: rustflags = ["-lLLVM-12", "-lm","-ldl","-lc","-lpthread","-lutil","-lgcc_s", "-C", "link-args=-L/usr/lib/llvm/12/lib64"] but it hasn't helped. Is there anything additional I need to do to build the library after cloning?
    The above rustflags is what I've had to use to get my own personal project that uses the inkwell crate to build
    Daniel Kolsoi
    @TheDan64
    See the readme; you need to specify the feature flag for the LLVM Version you're on
    muke 101
    @muke101_gitlab
    ah I got it, sorry pretty new to using rust projects
    I've build the library now and run the test cases for a PR for that phi node conversion feature I opened an issue about which pass just fine, how can I add the new methods to the documentation too though?
    r0nsha
    @r0nsha
    so is it just me, or does anybody else have bad link times when binding with llvm?
    my compiler compile times (the actual rust workspace) shot up from less than 1s to 11s when using inkwell or llvm-sys
    programmerjake
    @programmerjake:matrix.org
    [m]
    i find that's pretty normal, llvm is huge, so that's kinda expected
    λtlas
    @atlx
    quick question
    why is BasicMetadataTypeEnum not on the docs?
    8 replies
    λtlas
    @atlx
    ?
    Layle | Luca
    @ioncodes
    I'm running into a few issues emitting instructions:
    let ptr = self.module.get_global("ptr").unwrap();
    let loaded_ptr = self.builder.build_load(ptr, "");
    let i32_type = self.context.i32_type();
    let new_ptr = self.builder.build_int_add(loaded_ptr, i32_type.const_int(1, false), "++ptr");
    self.builder.build_store(new_ptr, ptr);
    1. How do I pass a GlobalVariable to build_load?
    2. How do I pass a constant value to build_int_add?
    3. How do I store the BasicValueEnum back to the GlobalVariable?
    note that ptr is just a simple i64
    With a change according to the compiler this is what I have now:
    let ptr = self.module.get_global("ptr").unwrap();
    let loaded_ptr = self.builder.build_load(ptr, "");
    let i32_type = self.context.i32_type();
    let i32_value = BasicValueEnum::IntValue(i32_type.const_int(1, false));
    let new_ptr = self.builder.build_int_add(loaded_ptr, i32_value, "++ptr");
    self.builder.build_store(ptr, new_ptr);
    And here's the error:
    image.png
    Layle | Luca
    @ioncodes
    I got it to work by calling .as_pointer_value() on the GlobalVariable (should have read the docs more carefully), however, I still can't figure out how to pass a constant to the add instruction
    Layle | Luca
    @ioncodes
    got it to work :))
    λtlas
    @atlx
    this is like the self help desk lmao
    Daniel Kolsoi
    @TheDan64
    Sorry, we don't get a lot of traffic here lol
    Daniel Kolsoi
    @TheDan64
    Maybe we should switch to discord and I'll see these messages more quickly lol