Bug #100356 MySQL server fails to build on RISC-V 64
Submitted: 28 Jul 2020 18:41 Modified: 29 Jul 2020 12:48
Reporter: Sergio D. Jr. Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.21 OS:Linux
Assigned to: CPU Architecture:Other (riscv64)

[28 Jul 2020 18:41] Sergio D. Jr.
Description:
MySQL server fails to build on the riscv64 architecture.

The problem happens because, on RISC-V, the always-lock-free property cannot be guaranteed for certain types, like boolean. MySQL server started requiring this property since:

https://github.com/mysql/mysql-server/commit/a36bd8b297d654f88a5fd58e8dc8dc5c1538851d

And now the compilation fails on RISC-V. Fortunately, in that same commit the author implemented a failsafe mechanism: an encapsulation for the "largest always-lock-free type in the architecture", which can be used to mitigate this exact scenario. Unfortunately, in order to make the RISC-V compilation happy again, I had to resort to some ifdef'ery to make sure that the original always-lock-free mechanism is not included when compiling on the architecture. I've tried to keep the patch as clean as possible, and provide comments on it explaining the reasoning behind these decisions.

I've tested everything locally using a RISC-V virtual machine, and the compilation suceeded (after almost 24 hours compiling!). I've also tested on amd64, and it worked OK.

How to repeat:
- Compile MySQL server on a riscv64 system (bare metal or emulated).

Suggested fix:
On Ubuntu, we are now carrying the following patch in order to make the compilation work:

https://git.launchpad.net/ubuntu/+source/mysql-8.0/commit/?id=152424bbd175737d9805aeffd63f...

Arguably, the patch is mostly a hack which disabled Lock_free_type_selector on riscv64, and forces the use of Largest_lock_free_type_selector, which works fine there.  I am not sure how important riscv64 is to you guys, but I thought I'd open this bug report to make sure you're aware of the problem.
[29 Jul 2020 6:19] Lars Tangvald
Hi,

Thanks for the fix! We don't support RISC-V, so to avoid having code we'd never test, I suggest we keep this patch downstream (we already have a couple of others there:  https://git.launchpad.net/ubuntu/+source/mysql-8.0/tree/debian/patches/series?id=02529b3de...)
[29 Jul 2020 12:48] MySQL Verification Team
Hi Mr. Jr.

Thank you for your contribution.

Since this CPU is not supported (yet), we shall keep it downstream, just in case.

Thanks again.