RFR: 8351322: Parameterize link option for pthreads
Magnus Ihse Bursie
ihse at openjdk.org
Fri Mar 7 11:34:53 UTC 2025
On Fri, 7 Mar 2025 00:18:14 GMT, David Holmes <dholmes at openjdk.org> wrote:
>>> What is the intended way of using this? Do you run make with LIBPTHREAD=-pthread or do you apply a patch on libraries.m4 for the specific way of linking to pthread?
>>
>> This is in preparation of the upcoming BSD port, which uses `-pthread` instead of `-pthread`. It was me who suggested that this is done separately with the existing code, to minimize the patch of the BSD port.
>
> @magicus why can't we just use `-pthread` everywhere? My recollection is that `-pthread` both sets compiler directives needed for pthread programming and links to libpthread, so it seems to be what we should be using. ??
@dholmes-ora Good question. I don't know the answer. I know we used `-pthread` exclusively on Solaris, and that we've used `-lpthread` on Linux (but apparently not in all cases?). I guess this difference would not have been introduced when the Linux port was created from the Solaris port unless it made sense. So maybe at that time, GCC did not support `-pthread`. Otoh, that might have changed by now.
Regardless, I would still like to see this change. We have generalized almost all system libraries to variable (like `$LIBM`, `$LIBDL` etc), and this is the last remaining (I think).
We can then check if we can turn `-lpthread` into `-pthread` on Linux as a follow up.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23930#issuecomment-2706220845
More information about the build-dev
mailing list