SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL2 threading config in ./cmake/sdlchecks.cmake not correct for non-GNU compiler (e.g. SunPro cc)

Open joncox123 opened this issue 8 months ago • 2 comments

Within the cmake config script, ./cmake/sdlchecks.cmake, there is a check that decides how to enable pthread support for different platforms. If this check detects a platform of either "Solaris" or "SunOS", it issues set(PTHREAD_LDFLAGS "-pthread -lposix4"). However this is only correct for the GNU toolchain, such as gcc. As a result, configure and CMake will fail trying to find threading support on Solaris 10 1/13 (SPARC), and the build will fail, if it is being compiled with Sun's Solaris Studio 12.4 compilers, for example.

According to the Oracle documentation, the correct way to enabled pthread support is to use -mt -lpthread. Therefore, I suggest that a check be made more sophisticated, such that if GNU is not being used, the command is instead set(PTHREAD_LDFLAGS "-mt -lpthread"). I think there are other places in the CMake scripts that do check for GNU, so this should be trivial to add.

I don't think we should be assuming use of the GNU toolchain because they continue to introduce incompatible, breaking features and flags. FSF is great, but they have become so successful they are almost like Microsoft was in the 90s in that regard.

joncox123 avatar Jun 23 '24 15:06 joncox123