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

Linux - Illegal instruction error #144

Closed
leifliddy opened this issue Sep 2, 2022 · 15 comments · Fixed by #152
Closed

Linux - Illegal instruction error #144

leifliddy opened this issue Sep 2, 2022 · 15 comments · Fixed by #152

Comments

@leifliddy
Copy link
Contributor

leifliddy commented Sep 2, 2022

I've compiled Cemu on Fedora 36 (and 37) according to the (gcc) instructions in the BUILD.md guide.
When I execute the binary I receive the following error:

[leif.liddy@black cemu]$ ./Cemu 
Illegal instruction (core dumped)

I'm still rockin a i7-3770K which is pretty dated at this point. Going to upgrade when the Zen4 chips are released at the end of the month --but I figured this could help someone out who might be running into the same issue.

I believe this error is related age of this chip and the instruction sets it supports as the same Cemu binary runs fine on my laptop with a more modern processor. I figured there must be a flag I can pass to cmake that enables all instruction subsets supported by my CPU. But I'm not sure how to do that....

Here are pertinent details:

GDB

(gdb) run
Starting program: /home/leif.liddy/programs/cemu/Cemu 
....
[Thread debugging using libthread_db enabled]                                                                                                                                                                                                
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x00000000004e3451 in _GLOBAL__sub_I_rangeStore_ppcRanges ()

(gdb) bt
#0  0x00000000004e3451 in _GLOBAL__sub_I_rangeStore_ppcRanges ()
#1  0x00007ffff5df667e in call_init (env=<optimized out>, argv=0x7fffffffde68, argc=1) at ../csu/libc-start.c:145
#2  __libc_start_main_impl (main=0x4de400 <main>, argc=1, argv=0x7fffffffde68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde58) at ../csu/libc-start.c:368
#3  0x0000000000546a25 in _start ()

(gdb) display/i $pc
1: x/i $pc
=> 0x4e3451 <_GLOBAL__sub_I_rangeStore_ppcRanges+689>:	vinserti128 $0x1,%xmm1,%ymm0,%ymm0

coredump

       Storage: /var/lib/systemd/coredump/core.Cemu.1000.9d2fb048c3fe43919b2d12c9f3665568.510047.1662087909000000.zst (present)
     Disk Size: 1012.6K
       Message: Process 510047 (Cemu) of user 1000 dumped core.
                
                Module /home/leif.liddy/programs/cemu/Cemu with build-id fe1ce8460a2cfd71d3239abab780d504b252fbe9
                Stack trace of thread 510047:
                #0  0x00000000004e3451 n/a (/home/leif.liddy/programs/cemu/Cemu + 0xe3451)
                #1  0x00007f26292a167e __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2367e)
                #2  0x0000000000546a25 n/a (/home/leif.liddy/programs/cemu/Cemu + 0x146a25)
                ELF object binary architecture: AMD x86-64I be

cpu info

model name	: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz

flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
@Squall-Leonhart
Copy link
Contributor

cemu can function on Nahalem+ i7 processors, the ivy bridge 3770k should have no issues instruction wise.

@Squall-Leonhart
Copy link
Contributor

Require the verbose (-v) output of the compile stage

@bitscher
Copy link
Contributor

bitscher commented Sep 2, 2022

PR #80 seems to have introduced an -mavx2 flag in file src/Cafe/CMakeLists.txt which means the target CPU must have AVX2 extensions.
Try removing it and recompile from a clean directory.

@bitscher bitscher mentioned this issue Sep 2, 2022
Merged
@ghost
Copy link

ghost commented Sep 2, 2022

GCC won't compile without -mavx2. I recommend using clang in this case.

@leifliddy
Copy link
Contributor Author

@bitscher @tomlally Thanks for looking into this. Like @tomlally said, it won't compile without -maxv2. And with clang I get that linking error that many people have reported. It's all good, I've been looking for an excuse to upgrade my system anyway ; )

@leifliddy
Copy link
Contributor Author

leifliddy commented Sep 2, 2022

Perhaps I closed this issue prematurely. Can't believe this PR was created. Nice! @tomlally I'll test out your PR when I get home.

@leifliddy leifliddy reopened this Sep 2, 2022
@Exzap Exzap closed this as completed in #152 Sep 2, 2022
@Exzap Exzap reopened this Sep 2, 2022
@Squall-Leonhart
Copy link
Contributor

Squall-Leonhart commented Sep 2, 2022

GCC won't compile without -mavx2. I recommend using clang in this case.

Thats false, please use proper tests in the cmake to pass the machines supported instuction set to the compiler, it should resolve to -march=avx (-mavx) in the case of a Core i 2xxx/3xxx, SSE4 for a Nahalem Core i 800 or 900, etc.,

for personal builds -march=native is also feasible.

@ghost
Copy link

ghost commented Sep 2, 2022

GCC won't compile without -mavx2. I recommend using clang in this case.

Thats false.

See #152. Also, I meant that only in the context of this issue.

@Squall-Leonhart
Copy link
Contributor

Squall-Leonhart commented Sep 2, 2022

That is missing the AVX case, which Windows builds do take advantage of, an AVX capable processor such as the Fx series or Core i Sandy/Ivy will be restricted to SSE on Unix builds with that change.

@ghost
Copy link

ghost commented Sep 2, 2022

Where?

@Squall-Leonhart
Copy link
Contributor

Ah, its my mistake, the LatteIndices use SSE4.x on avx1 processors but AVX is used in other parts, such as the recompiler.

@leifliddy
Copy link
Contributor Author

leifliddy commented Sep 2, 2022

Holy crap it works!!! @tomlally can't thank you enough!

Update:
I can now get Cemu to run and to launch games, but they all seem to crash fairly quickly.
Not sure if it's related to this issue or not. Need to do a bit more troubleshooting...

@ghost
Copy link

ghost commented Sep 2, 2022

Holy crap it works!!! @tomlally can't thank you enough!

Don't because I broke it in the first place. But, hopefully I'm off the hook now that this is closed. 🙂

@abouvier
Copy link
Contributor

abouvier commented Sep 3, 2022

-mssse3 and -mavx2 are still defined in ih264d:

if((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
add_compile_options(-mssse3 -mavx2)
endif()

@ghost
Copy link

ghost commented Sep 4, 2022

This looks as if it could be easily fixed in the CMakeLists by only enabling -mssse3 for all the files ending in _ssse3.c, and -msse4.2 for all the files ending in _sse42.c.

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 a pull request may close this issue.

5 participants