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

[i386] miniaudio.h:83477:no such instruction: lzcntl %eax, %ecx'` #842

Open
barracuda156 opened this issue Apr 25, 2024 · 2 comments
Open

Comments

@barracuda156
Copy link

@mackron In addition to #841 on older i386 this may fail:

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %edx, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %edx, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_abaddon/abaddon/work/abaddon-0.2.1/subprojects/miniaudio/miniaudio.h:83477:no such instruction: `lzcntl %eax, %ecx'

Looks like there is no check there, it is assumed it is supported with all systems using gcc or clang, which is not the case: at least assembler has to support this insn, and it may not.

Build run on 10.6 i386 with gcc13, physical cpu CoreDuo.

@mackron
Copy link
Owner

mackron commented Apr 26, 2024

Thanks. This is an awkward one. So this is actually coming from dr_flac, which I amalgamate into miniaudio using a tool. It's used in a tight loop deep in the decoding logic and is important that it's used if available. dr_flac will do a runtime support check to ensure the instruction is not executed if unavailable, so I don't think it's causing any harm in practice at runtime, but I'm not sure how to disable this error. I want it to still be compiled into the executable even if the compiler is targeting i386. Do you have any suggestions?

Is compilation actually succeeding, or is this presenting as an error instead of a warning? If it's a warning, since I'm doing a runtime check, I suppose silencing the warning work?

@barracuda156
Copy link
Author

@mackron It causes the build to fail, but admittedly this is a minority case, and it should not be disabled for everyone because it fails here.
This seems to be a somewhat common problem, because many multimedia-related projects either simply assume that all x86 SIMD are available on all x86 cpus or rely on a compiler version check, which is of no help in fact, since a compiler may support a given flag, while assembler may not, and that will break everything.

I do not really have a neat solution here. In principle, it should be checked that an instruction from a specific SIMD type can be actually compiled (instead of using a macro to check GCC/Clang version or check support for passing -mavx etc. flags – that is useless) – that gonna ensure that both compiler and assembler can handle those. But this may be bothersome to implement, and very few users will perhaps benefit from that.
As a simple and safe solution maybe just add a configure option to turn off AXV stuff (or even SIMD altogether)? So that default behavior does not change, but if someone gets a problem, there will be a neat way to have this compiled correctly.

Given that miniaudio can be borrowed by other projects, so there will be no native configure, a macro will do: say, if someone needs to avoid AVX, just pass a cppflag -DNO_AVX, or smth to that effect.

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

No branches or pull requests

2 participants