Skip to content

Take advantage of mem.spanZ accepting null #4880

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

Merged
merged 2 commits into from
Mar 31, 2020

Conversation

daurnimator
Copy link
Contributor

Small tidy up I had around that can be upstreamed since #4858 was merged.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are quite nice

@daurnimator
Copy link
Contributor Author

Doh; looks like #4858 was broken! I'll add a fix to this PR.

const zig_triple = if (zig_triple_oz) |zig_triple_z| mem.spanZ(zig_triple_z) else "native";
const mcpu = if (mcpu_oz) |mcpu_z| mem.spanZ(mcpu_z) else null;
const dynamic_linker = if (dynamic_linker_oz) |dl_z| mem.spanZ(dl_z) else null;
const mcpu = mem.spanZ(mcpu_oz);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun bug: if I inlined this into the following expression I got:

broken LLVM module found: Call parameter type does not match function signature!
  %67 = getelementptr inbounds %std.zig.cross_target.ParseOptions, %std.zig.cross_target.ParseOptions* %10, i32 0, i32 1, !dbg !20878
 %"?[:0]const u8"*  call fastcc void @std.mem.spanZ.176(%"?[]const u8"* sret %67, i8* %68), !dbg !20880

This is a bug in the Zig compiler.

@andrewrk
Copy link
Member

the freebsd tests should be a good enough test here. other ones failed because of bad timing with a broken master branch commit

@andrewrk andrewrk merged commit 28b7306 into ziglang:master Mar 31, 2020
@daurnimator daurnimator deleted the use-spanZ branch March 31, 2020 22:10
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.

2 participants