Compilation Errors for XenonRecomp Results with g++ and Clang
Summary
When utilizing XenonRecomp, I learned that a few instructions in the games I tested were not implemented. When I compile them in g++, it complains about calls for functions that weren't declared (further detailed below). Initially, I was under the belief these missing function declarations were due to these unimplemented instructions. However, reviewing the documentation notates that g++ is not recommended. Regardless, another game (that admittedly also utilizes missing instructions; these instructions are completely different from the one I'm primarily wanting to get running) also produced the same compilation errors. Compiling with Clang produces a different set of errors altogether. I wanted to highlight it below and ask for any insight if at all possible.
Unimplemented Instructions
The following instructions appear to not be implemented in recompiler.cpp at this time:
- dcbst
- frsqrte
Compilation Error with G++
The following function calls are generated, but the functions themselves aren't declared in scope:
- __builtin_rotateleft32
- __builtin_rotateleft64
- __builtin_assume
Compilation Errors with Clang
The following are needed target features:
- sse4.1
- avx
The following is another error that slightly varied:
always_inline function '__mm_shuffle_epi8' requires target feature 'ssse3', but would be inlined into function [this varies but generally follows the naming scheme of '__imp__sub__HEXHERE'] that is compiled without support for 'ssse3'
====================== Steps Performed:
Note: Any new users reading this may be tempted to follow below exactly. However, please know that you will not inherently produce good results (and these may have resulted in my issue). For instance, the XenonAnalyse will not produce a working .toml file for all games (as games may utilize patterns that the pattern check isn't familiar with as noted here)
- Ensured WSL was installed; I utilize Win 10
- Download repository (
git clone https://github.com/hedge-dev/XenonRecomp.gitin CMD) - Installed Clang 18.1.8
- Ensured CMake was installed using
cmake --versionin CMD; I had to install it on their website - Downloaded all submodules in CMD in root repository (utilized
git submodules --init; I haven't utilized submodules before admittedly so I may need to use update in the future too) - Compiled entirety of project in VS utilizing Clang v. 18.1.8.
- Ran
XenonAnalyse.exe [Game's default.XEX Path] [Where You Want the Jump Table .TOML File]in CMD. Jump Table .TOML file successfully created. - Created new config.toml file for my game specifically. I did remove the
patch_file_pathassignment as I have no patch for my game. - Ran
XenonRecomp.exe [the config .toml file] [path to ppc_context.h in XenonUtil]in CMD - Navigated to C:/XboxRecompileProject/GAME/Output
- Attempted to compile once with g++. This compilation complained that functions were not declared.
- Attempted to compile again with Clang. Received errors about what was shared above.
GAME_Config.toml
[main] file_path = "C:/XboxRecompileProject/GAME/default.xex" patched_file_path = "C:/XboxRecompileProject/GAME/default_patched.xex" out_directory_path = "C:/XboxRecompileProject/GAME/Output" switch_table_file_path = "GAME_JT.toml"
Unimplemented Instructions
The following instructions appear to not be implemented in recompiler.cpp at this time:
- dcbst
- frsqrte
dcbst and frsqrte are PowerPC instructions. Microsoft seems to just use the polyfill 1.0 / sqrt(x) for frsqrte on platforms that don't support the instruction. I don't think there is an easy answer for dcbst.
Compilation Error with G++
The following function calls are generated, but the functions themselves aren't declared in scope:
- __builtin_rotateleft32
- __builtin_rotateleft64
- __builtin_assume
__builtin_rotateleft32, __builtin_rotateleft64 and __builtin_assume seem to be Clang extensions, so you would have to find GCC equivalents. C++20 has std::rotl and std::rotr. C++23 has [[assume]]
Compilation Errors with Clang
The following are needed target features:
- sse4.1
- avx
The following is another error that slightly varied:
always_inline function '__mm_shuffle_epi8' requires target feature 'ssse3', but would be inlined into function [this varies but generally follows the naming scheme of '__imp__sub__HEXHERE'] that is compiled without support for 'ssse3'
Try compiling with -march=native
What did you do for step 9? Because I did what was in step 8 and 9, but no new files came out from doing step 9, and I had everything as it should be in terms of files and me using CMD.
- Created new config.toml file for my game specifically. I did remove the
patch_file_pathassignment as I have no patch for my game.- Ran
XenonRecomp.exe [the config .toml file] [path to ppc_context.h in XenonUtil]in CMD
What did you do for step 9? Because I did what was in step 8 and 9, but no new files came out from doing step 9, and I had everything as it should be in terms of files and me using CMD.
- Created new config.toml file for my game specifically. I did remove the
patch_file_pathassignment as I have no patch for my game.- Ran
XenonRecomp.exe [the config .toml file] [path to ppc_context.h in XenonUtil]in CMD
Was able to figure out my issue thanks to a friend of mine, though I didn't expect the results to be perfect, but it's a start for now. Now to figure out XenosRecomp for shaders.
Edit: also should note of unrecognized instructions "lfdu", "vandc", and with the build I compiled myself I got "stfdu" instead of Ifdu" not too sure if that counts or not tbh, as this was what I got here and there for the Open Season videogame.
Why not use clang++ over g++?
Why not use clang++ over g++?
To be blunt, it was a mistake on my part. However, I wanted to include it in the off-chance someone makes the same mistake I had as well. While I initially compiled the tools with Clang++, I had issues with the Analyzer and Recomp tools that took some time to sort out (in short, they were silly mistakes with providing the paths largely). By the time I got results out of the Recomp tool, I had forgotten that g++ was not recommended and attempted to compile the results with it.
Unimplemented Instructions
dcbstandfrsqrteare PowerPC instructions. Microsoft seems to just use the polyfill1.0 / sqrt(x)forfrsqrteon platforms that don't support the instruction. I don't think there is an easy answer fordcbst.Compilation Error with G++
__builtin_rotateleft32,__builtin_rotateleft64and__builtin_assumeseem to be Clang extensions, so you would have to find GCC equivalents. C++20 hasstd::rotlandstd::rotr. C++23 has[[assume]]Compilation Errors with Clang Try compiling with
-march=native
===
Thank you for the insight. Fortunately, I was able to implement FRSQRTE utilizing the polyfill you shared and the PPC_INST_FSQRT as a basis. Furthermore, I was able to get a little farther with Clang by including the -march=native flag as you recommended. However, I still ran into issues compiling as it seems there are a large amount of undefined references. After further review, it seems I was careless and failed to to review the results from XenonRecomp.exe well. There were a number of other instructions that were also noted as not implemented. For now, I'm redirecting my attention towards implementing the instructions that have not been yet in recompiler.cpp.
===
Unimplemented Instructions
It seems most unimplemented instructions relate to the Vector/SIMD extensions for PowerPC processors. I would like to note that after utilizing XenonRecomp.exe again did not produce a warning about dcbst not being implemented.
The following is a list of all instructions not implemented from the Vector/SIMD extensions for PowerPC:
- vnor
- vandc
- vsel128
- vavguh
- stvlxl128
- lvxl128
- vpkswss
- vpkswus
- vpkuhus
- vpkshss
- vspltish
- vctuxs
- vslh
- vsrh
- vsrah
- vsrab
- vsububm
- vaddsbs
- vmaxsh
- vsubshs
- vminsh
- vcmpgtsh
- vcmpequh
The following is a list of standard instructions not implemented:
Check this PR to see if any of the currently missing ones are implemented there: https://github.com/hedge-dev/XenonRecomp/pull/1