4141#include < sys/resource.h>
4242#endif
4343
44+ #if defined(__x86_64) || defined(__x86_64__)
45+ void __cpuid (int *r_cpuinfo, int p_info) {
46+ // Note: Some compilers have a buggy `__cpuid` intrinsic, using inline assembly (based on LLVM-20 implementation) instead.
47+ __asm__ __volatile__ (
48+ " xchgq %%rbx, %q1;"
49+ " cpuid;"
50+ " xchgq %%rbx, %q1;"
51+ : " =a" (r_cpuinfo[0 ]), " =r" (r_cpuinfo[1 ]), " =c" (r_cpuinfo[2 ]), " =d" (r_cpuinfo[3 ])
52+ : " 0" (p_info));
53+ }
54+ #endif
55+
4456// For export templates, add a section; the exporter will patch it to enclose
4557// the data appended to the executable (bundled PCK).
4658#if !defined(TOOLS_ENABLED) && defined(__GNUC__)
@@ -54,6 +66,27 @@ extern "C" const char *pck_section_dummy_call() {
5466#endif
5567
5668int main (int argc, char *argv[]) {
69+ #if defined(__x86_64) || defined(__x86_64__)
70+ int cpuinfo[4 ];
71+ __cpuid (cpuinfo, 0x01 );
72+
73+ if (!(cpuinfo[2 ] & (1 << 20 ))) {
74+ printf (" A CPU with SSE4.2 instruction set support is required.\n " );
75+
76+ int ret = system (" zenity --warning --title \" Godot Engine\" --text \" A CPU with SSE4.2 instruction set support is required.\" 2> /dev/null" );
77+ if (ret != 0 ) {
78+ ret = system (" kdialog --title \" Godot Engine\" --sorry \" A CPU with SSE4.2 instruction set support is required.\" 2> /dev/null" );
79+ }
80+ if (ret != 0 ) {
81+ ret = system (" Xdialog --title \" Godot Engine\" --msgbox \" A CPU with SSE4.2 instruction set support is required.\" 0 0 2> /dev/null" );
82+ }
83+ if (ret != 0 ) {
84+ ret = system (" xmessage -center -title \" Godot Engine\" \" A CPU with SSE4.2 instruction set support is required.\" 2> /dev/null" );
85+ }
86+ abort ();
87+ }
88+ #endif
89+
5790#if defined(SANITIZERS_ENABLED)
5891 // Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times.
5992 struct rlimit stack_lim = { 0x1E00000 , 0x1E00000 };
0 commit comments