Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#71053 - [openttd] OpenTTD does not run on older CPUs due to use of SSE 4.1 instructions

Attached to Project: Community Packages
Opened by David Kolossa (yayachiken) - Saturday, 29 May 2021, 16:48 GMT
Last edited by Alexander F. Rødseth (xyproto) - Saturday, 29 May 2021, 21:18 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Laurent Carlier (lordheavy)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Using an "AMD Phenom(tm) II X6 1090T Processor", openttd will crash on startup after receiving SIGILL.

Running the application under gdb and disassembling the last instruction shows that openttd crashed after encountering the pinsrq instruction from the SSE 4.1 instruction set, which AMD did not support until the Bulldozer architecture (released 2011).

I was able to work around that issue by amending the PKGBUILD file. I added CXXFLAGS="-mtune=native" to the cmake call, thus building with the correct instruction set for my machine. Of course, this workaround will not work for pre-built distribution packages, as the buildnodes hopefully have a more capable CPU than I have :)

I don't know how the packaging guidelines are. But Phenom II CPUs are not that old (~10 years), and OpenTTD is not that much of a high-end game, so I would expect it to work.

Additional info:

* package version: openttd 1.11.2-2

Steps to reproduce:

* On a machine with an AMD Phenom II CPU run gdb openttd
* openttd will crash on startup
* Enter the gdb command bt to get the backtrace
* disassemble the executable in the vincinity of the last instruction, for me that showed

(gdb) disassemble 0x0000555555af3266,0x0000555555af3270
Dump of assembler code from 0x555555af3266 to 0x555555af3270:
=> 0x0000555555af3266: pinsrq $0x1,%rbp,%xmm0
0x0000555555af326d: movups %xmm1,0x10(%rbx)
End of assembler dump.
This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Saturday, 29 May 2021, 21:18 GMT
Reason for closing:  Fixed
Comment by loqs (loqs) - Saturday, 29 May 2021, 17:27 GMT
Building on a system without SSE4 will produce a version does not use SSE4, see [1] and [2].

This change on a system that does have SSE4 disables the check and prevents its use.
sed -i 's/SSE_FOUND/DISABLE_SSE_FOUND/' $pkgname-$pkgver/cmake/FindSSE.cmake

[1] https://github.com/OpenTTD/OpenTTD/blob/1.11.2/cmake/FindSSE.cmake#L16
[2] https://github.com/OpenTTD/OpenTTD/blob/1.11.2/src/blitter/CMakeLists.txt#L42
Comment by David Kolossa (yayachiken) - Saturday, 29 May 2021, 17:34 GMT
> Building on a system without SSE4 will produce a version does not use SSE4, see [1] and [2].

I cannot confirm that behaviour.

I actually tried just rebuilding the package first with no changes. But without the change to CXXFLAGS that I mentioned, I just built a package with the identical problem.


Comment by David Kolossa (yayachiken) - Saturday, 29 May 2021, 17:43 GMT
By the way, would it be acceptable by the packaging policies to just use my workaround, but changing to CXXFLAGS="-mtune=generic"?
Comment by loqs (loqs) - Saturday, 29 May 2021, 17:48 GMT
An issue in FindSSE.cmake that causes it to pass when it should fail?
Not sure I understand exactly how the test should work, compiling with -msse4.1 can be performed on any host.
Edit:
I missed FindSSE.cmake only checks what the compiler supports. There is nothing in the code to limit support to what the host or a target can support, should that be less than that of the compiler.
Comment by Alexander F. Rødseth (xyproto) - Saturday, 29 May 2021, 20:44 GMT
Thanks for reporting.

I removed all lines with 'sse' or 'SSE' from CMakeLists.txt and rebuilt with -D CMAKE_CXX_FLAGS=' -mtune=generic'.

objdump -d of the executable looks promising.

I updated the package in [community].

Please confirm that it's now working as expected.
Comment by loqs (loqs) - Saturday, 29 May 2021, 20:55 GMT
-D CMAKE_CXX_FLAGS=' -mtune=generic' \
Could you drop the above as it is not required to fix the issue and removes Arch's hardening flags?
Edit:
It changes CXXFLAGS from '-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' to ' -mtune=generic' it does not change -mtune=generic
Comment by Alexander F. Rødseth (xyproto) - Saturday, 29 May 2021, 21:16 GMT
Thanks loqs, you're right. I removed the CMAKE_CSS_FLAGS, checked with objdump and updated the package again.

Loading...