support --target-arch wasm32 (#1094)

Add wasm32 support to the build-obj, build-exe and build-lib commands
of the stage 1 compiler.  Wasm64 should work transparently once it's
supported in upstream LLVM.

To export a function:

    // lib.zig - for exposition, not necessary for this example
    pub use @import("add.zig");

    // add.zig
    export fn add(a: i32, b: i32) i32 {
        return a + b;
    }

To import a function:

    // cube.zig
    extern fn square(x: i32) i32;

    export fn cube(x: i32) i32 {
        return x * square(x);
    }
This commit is contained in:
Ben Noordhuis
2018-06-10 04:39:22 +02:00
committed by Andrew Kelley
parent 7a9635555b
commit d464b25322
4 changed files with 21 additions and 4 deletions

View File

@@ -838,7 +838,7 @@ bool ZigLLDLink(ZigLLVM_ObjectFormatType oformat, const char **args, size_t arg_
return lld::mach_o::link(array_ref_args, diag);
case ZigLLVM_Wasm:
assert(false); // TODO ZigLLDLink for Wasm
return lld::wasm::link(array_ref_args, false, diag);
}
assert(false); // unreachable
abort();