gwsystems / aWsm

WebAssembly ahead-of-time compiler and runtime. Focuses on generating fast code, simplicity, and portability.
BSD 3-Clause "New" or "Revised" License
310 stars 18 forks source link

Adding data layout meta #22

Open Jacarte opened 3 years ago

Jacarte commented 3 years ago

Hi @geky

In my use of case the data-layout metadata is needed. Taking a look at the llvm-alt crate, it seems that there is no way using the wrapper. However, calling directly to the llvm-sys underlying crate seems to work.

if let Some(ref layout) = opt.layout {
        unsafe {
            let c_target = std::ffi::CString::new(layout.to_string()).unwrap();
            llvm::ffi::core::LLVMSetDataLayout(llvm_module.into(), c_target.as_ptr());
        }
    }

WDYT? Thanks in advance

gparmer commented 3 years ago

Any context for what you're using the data layout for? Generally more debugging information would be quite useful.