Illegal instruction hit in build executable

That worked.

Behavior is now the same between x86 and x86_64 (VMOVD crash):

I’ll get back to figuring out this AVX/2 thing and report back if anything works for me (or I bail on Virtualbox).

This was fun! I’m sure someone is more adept than me at filing this bug, but let me know if I should be doing it. I’ll figure it out!

4 Likes

Sure, just go for it and make a Pull Request! Would be nice being able to say you found and fixed a bug in the standard library on day 1 learning Zig :wink: And if there are any difficulties, there are enough people able to help you.

5 Likes

Understood. Will do.

EDIT: issue opened
EDIT2: done? was it really this easy?
EDIT3: maybe it’s really done now. Thank you @mlugg

4 Likes

But wait, that means it also happens outside of the compiler, and in the process of executing the compiled binary of the build system.
This means there must be something wrong with Zig’s CPU feature detection.

1 Like

I agree.
I don’t have the knowledge yet to attack this problem in a timely manner and/or ask the right questions.

I still have the issue of needing to ‘turn on’ AVX/2 in my VM. I’m going to chip at that first and then circle back.

Unless anyone has some things they want me to try in my setup? I have two VM’s going and even if I fix one, the other can stay broken to investigate further.

Minutiae like this really gets my brain moving. I think we’ll get it eventually, but probably not today :wink:

At this point it might be best to just make an issue for it on github, so that someone who knows more about the compiler internals in regards to architecture detection can work on this.

I’m not sure this is a Zig issue. Certainly, his CPU has AVX, and Zig correctly detected that. It seems that the VM is just not enabling it. This stackoverflow question discusses this issue.

There are many applications that switch to a vectorized version of a function if the hardware supports it (I think operations like memcpy usually do this). So the VM must have some way of telling applications that AVX is disabled (I think this can be done with the cpuid instruction), otherwise most applications would fail. Now Zig does not seem to detect this correctly.

1 Like

Yes, the host CPU has AVX/2.

The VM has not exposed access to AVX/2 to the guest, as far as I can tell, and Zig has incorrectly detected (assumed?) that. Zig is running guest side here.

EDIT: host reports:

/proc/cpuinfo (guest) reports no AVX/2:

… and Zig generated a VMOVD instruction for use in the build executable.
This is my overall understanding so far.

I also cannot turn off Hyper-V because $CORP just backs it out on the next policy update :person_shrugging: I’m pretty much stuck on falling back to the host (windows) and can continue from there. I hesitantly mark the solution as ‘untested’ because I can’t confirm it myself.

I’ll open an issue and let it run its course: #23385

1 Like

Amazing. @andrewrk has created something special here.

@alexrp and I have worked out the issue and I’ve successfully tested that it works.

You all have been very helpful and patient with me. Thank you for that!
This has been an awesome first Zig experience for me.

3 Likes