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
add cross compilation regression test #1112
Conversation
Verify that it's possible to build for the host architecture and a different target architecture from a single build.zig. The test doubles as a basic WebAssembly smoke test.
looks like llvm 6 from homebrew gave this error: I'm not sure why the linux travis ci versions worked, unless the llvm apt repos have the experimental targets enabled. the windows one worked because it downloads my build of llvm which purposefully has web assembly enabled. |
One option we have is to add a flag to the build to disable this test, and then only set this flag on travis for macos. Then we can remove the flag once homebrew gets an llvm version which has webassembly target enabled. |
Sounds good. I'll look into that tomorrow. |
Related: https://reviews.llvm.org/D43211 |
Oh, by the way, the test suite already tests building these targets: Lines 30 to 46 in c529b81
for all the build modes, on every platform. That's why you see printed a few times, when running the main test suite:
|
var direct = std.heap.DirectAllocator.init(); | ||
defer direct.deinit(); | ||
|
||
const bytes = try std.io.readFileAlloc(&direct.allocator, "zig-cache/liblib.a"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of how to do this without depending on zig-cache
(which is supposed to be a black box):
zig/test/standalone/load_dynamic_library/main.zig
Lines 4 to 9 in c529b81
const args = try std.os.argsAlloc(std.debug.global_allocator); | |
defer std.os.argsFree(std.debug.global_allocator, args); | |
const dynlib_name = args[1]; | |
var lib = try std.DynLib.open(std.debug.global_allocator, dynlib_name); |
zig/test/standalone/load_dynamic_library/build.zig
Lines 12 to 15 in c529b81
const run = b.addCommand(".", b.env_map, [][]const u8{ | |
main.getOutputPath(), | |
lib.getOutputPath(), | |
}); |
Cross compilation is pretty heavily tested in the main test suite. What this PR brings to the table is testing web assembly. Given that LLVM still has web assembly in the experimental targets list, I think it's not time to add web assembly to the test matrix yet. Let's revisit this when LLVM 7 comes out in September. Feel free to push back on this, if you get CI reporting all green. |
poke LLVM 7 is out, though removing WASM from the experimental targets list didn't quite make the cut. Also the wasm build is broken for exported symbols - see issue #1570. |
Verify that it's possible to build for the host architecture
and a different target architecture from a single build.zig.
The test doubles as a basic WebAssembly smoke test.