Fix undefined PTHREAD_MUTEX_RECURSIVE compilation error#423
Fix undefined PTHREAD_MUTEX_RECURSIVE compilation error#423nathanweeks wants to merge 1 commit intosamtools:developfrom
Conversation
|
Seems legit, although I'm not sure we're using anything XSI so might prefer to define If these platforms use glibc, I suppose the problem is that they predate this fix. We should perhaps define this for all source files via config.h, or for all source files when it's needed via configure, rather than just for one file. Or is worrying about ODR overly pedantic when it comes to these POSIX mode defines? |
|
This system does have a pthread.h that predates that fix, and just defining _POSIX_C_SOURCE as 200809L doesn't work. Addding -D_POSIX_C_SOURCE=200809L to the compile command also uncovered a few XSI-isms (in addition to implicitly-declared functions that have been omitted here): As a matter of principle, I agree with enforcing some level of standard conformance globally, as it should enhance portability to lesser-used platforms---e.g., has anybody tried compiling htslib on Solaris recently?---and increase the likelihood of reproducibility (10 years from now will someone still be able to compile this version of htslib on, e.g., RHEL 9.x?). OTOH, I don't want to distract developers from issues currently affecting more users. |
|
Thanks for the reminder about all those maths constants etc being XSI. Re Solaris, in fact it compiles and passes the test suite just fine with some small build tweaks |
|
Thanks Nathan; merged as afd9b56. |
|
I'm curious whether XOPEN_SOURCE 700 was required, or whether something lower than 500 or 600 worked? I'm just experimenting at the moment with trying to work out what our actual minimum requirements are for compilation environments. This thread seems to imply 500 is necessary: |
|
Regarding -D_POSIX_C_SOURCE=200809L, we're using I think I'd prefer to simply state we have a dependency on c99 and _XOPEN_SOURCE=600 or higher, glossing over the slight bit of c11 (anonymous unions) for now until we observe whether it causes issues anywhere. We'll be testing changes more aggressively on various platforms at some stage, but for now I've done a few code tidyups over here: |
A portable (POSIX) way to address issue #420 , which I have also observed in the Cray Linux Environment (based on SuSE 11.3) is to define _XOPEN_SOURCE 700 at the top of the affected file.