Skip to content
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

Closed
wants to merge 1 commit into from
Closed

add cross compilation regression test #1112

wants to merge 1 commit into from

Conversation

bnoordhuis
Copy link
Contributor

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.

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.
@andrewrk
Copy link
Member

looks like llvm 6 from homebrew gave this error:
unable to create target based on: wasm32-unknown-unknown-wasm

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.

@andrewrk
Copy link
Member

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.

@bnoordhuis
Copy link
Contributor Author

Sounds good. I'll look into that tomorrow.

@andrewrk
Copy link
Member

Related: https://reviews.llvm.org/D43211

@andrewrk
Copy link
Member

Oh, by the way, the test suite already tests building these targets:

zig/test/tests.zig

Lines 30 to 46 in c529b81

const test_targets = []TestTarget{
TestTarget{
.os = builtin.Os.linux,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.gnu,
},
TestTarget{
.os = builtin.Os.macosx,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.unknown,
},
TestTarget{
.os = builtin.Os.windows,
.arch = builtin.Arch.x86_64,
.environ = builtin.Environ.msvc,
},
};

for all the build modes, on every platform. That's why you see printed a few times, when running the main test suite:

Created ./zig-cache/test but skipping execution because it is non-native.
Created ./zig-cache/test but skipping execution because it is non-native.
Created ./zig-cache/test but skipping execution because it is non-native.
Created ./zig-cache/test but skipping execution because it is non-native.
Created ./zig-cache/test.exe but skipping execution because it is non-native.
Created ./zig-cache/test.exe but skipping execution because it is non-native.
Created ./zig-cache/test.exe but skipping execution because it is non-native.
Created ./zig-cache/test.exe but skipping execution because it is non-native.

var direct = std.heap.DirectAllocator.init();
defer direct.deinit();

const bytes = try std.io.readFileAlloc(&direct.allocator, "zig-cache/liblib.a");
Copy link
Member

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):

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);

const run = b.addCommand(".", b.env_map, [][]const u8{
main.getOutputPath(),
lib.getOutputPath(),
});

@andrewrk
Copy link
Member

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.

@andrewrk andrewrk closed this Jun 18, 2018
@josephg
Copy link

josephg commented Sep 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants