Build: x86-64 needs an explicit -msse4.1 for clang/GCC, since the generated code uses SSE4.1 intrinsics
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cmake, cpp
- Domain
- build-system
Research direction
Open the root CMakeLists.txt and find the if(PS2X_IS_ARM_TARGET) block. Add an else that, for Clang or GNU, calls add_compile_options(-msse4.1) as in the issue (do not replace CMAKE_CXX_FLAGS). Rebuild with clang or GCC on x86-64; done when the SSE4.1 intrinsic errors are gone and the project still links.
Written by the indexing model from the issue text.
Description
What happens
The generated runner code emits SSE4.1 intrinsics -- _mm_blendv_ps (442 occurrences in our output), _mm_mullo_epi32, _mm_extract_epi32. The root CMakeLists.txt only sets an architecture flag for ARM targets (the if(PS2X_IS_ARM_TARGET) block); there is no else branch for x86, and no SSE4.1 handling anywhere in the tree at 75d729ce or on main.
MSVC has no notion of target features and accepts these intrinsics unconditionally on x64, so the defect is invisible when building with cl.exe. clang and GCC keep clang's semantics and refuse:
error: always_inline function '_mm_mullo_epi32' requires target feature 'sse4.1',
but would be inlined into function 'main' that is compiled without
support for 'sse4.1'
Measured on this host with clang-cl 22.1.3, flag by flag on a neutral file: without -msse4.1 the intrinsic is rejected; with -msse4.1, /clang:-msse4.1 or /arch:AVX it compiles, links and runs. cl.exe accepts it with no flag at all. On Linux with clang the build broke at unity_85_cxx.cxx.o.
Issue #166 shows another user's configure log containing -- x86 target detected, enabling SSE4.1 and -- SSE4.1 compiler flag enabled. Those strings appear nowhere in this repository's history, on any branch, so that was a local fix on their side rather than an upstream one.
Suggested fix
Give the if(PS2X_IS_ARM_TARGET) block an else branch, so the flag is added rather than left to the caller:
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "x86-64 Clang/GCC detected - adding -msse4.1")
add_compile_options(-msse4.1)
endif()
endif()
add_compile_options adds to the flag set. Worth preferring over telling users to pass -DCMAKE_CXX_FLAGS=-msse4.1, because that form replaces CMake's defaults (/DWIN32 /D_WINDOWS /EHsc) and silently disables exceptions -- which then fails ps2xRecomp with "cannot use 'throw' with exceptions disabled". That cost us a build cycle to diagnose.
Found while statically recompiling Ridge Racer V (NTSC-U, SLUS_200.02) with PS2Recomp.
Tested on commit 75d729ce; main was c5a9d02 at the time of writing, one README-only commit ahead.
Host: Windows 11 x64, clang-cl 22.1.3 + Ninja, MSVC toolset 14.51.36231, Windows SDK 10.0.26100.0, CMake 4.2.3.
None of these are specific to this game.
- Dominant language
- C++
- Stars
- 3.3k
- Forks
- 149
- Avg merge
- 8h 46m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ran-j/PS2Recomp
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ran-j/PS2Recomp#393 · 1 comment ·
Maintainers usually reply within 5 days
-
EE sceCdStatus stub always reports READ (6), hanging games that wait for PAUSEPossibly taken @ahmedgamalalzatary claimed this 12 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 5 days
-
VU0 macro VSQI / VSQD: address and source registers swapped in generated codePossibly taken @yanm1103 claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 5 days
-
Runtime: SampleTexture casts unbounded or NaN texture coordinates to int, which is undefined behaviourMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ran-j/PS2Recomp#273 · 2 comments ·
Maintainers usually reply within 5 days
-
Build: /Qspectre- is MSVC-only and breaks every Release target under clang-clPossibly taken @ahmedgamalalzatary claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 5 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
SCIInstitute/SCIRun#2909 ·
Maintainers usually reply within 2 days
-
bug libcudf
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Triage: Needed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days