From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id D7C28385841D; Fri, 3 Mar 2023 05:23:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7C28385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677821030; bh=VK9LDku7k9r0qEQd1NCgwUX9uPmY8eSb+/ic2x/oJWM=; h=From:To:Subject:Date:From; b=Vd8bpzMldLM/ukM9g5Z+odcSazSEc1Bg2vtGsYUcNbMoPh6GgrT/Gc6OhIZeQqmvr 40I6L8AjJB4geMOfRzXzKlagkP+gmfFg4zHhmd7uNTA1vjbLNVH8wDazJsELvfJG3/ JRoMjlJQAVOmdjgbZAUngSlWKPGhpbxe94QHQbKY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] link pthread_join from std::thread ctor X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: dc1be3eb33c7f37ac45ad0ccf5be063134a513be X-Git-Newrev: 45fd40a3a15f083ea13e515e8b6ab62189736df8 Message-Id: <20230303052350.D7C28385841D@sourceware.org> Date: Fri, 3 Mar 2023 05:23:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:45fd40a3a15f083ea13e515e8b6ab62189736df8 commit 45fd40a3a15f083ea13e515e8b6ab62189736df8 Author: Alexandre Oliva Date: Fri Mar 3 02:14:53 2023 -0300 link pthread_join from std::thread ctor Like pthread_create, pthread_join may fail to be statically linked in absent strong uses, so add to user code strong references to both when std::thread objects are created. for libstdc++-v3/ChangeLog * include/bits/std_thread.h (std::thread ctor): Add strong reference to pthread_join. * testsuite/30_threads/jthread/95989.cc: Drop extraneous join call. Change-Id: I6c40875f7f7c2c08278f950f23e3b7163dd71c5c TN: W127-055 Diff: --- libstdc++-v3/include/bits/std_thread.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libstdc++-v3/include/bits/std_thread.h b/libstdc++-v3/include/bits/std_thread.h index adbd3928ff7..a504a0b48ed 100644 --- a/libstdc++-v3/include/bits/std_thread.h +++ b/libstdc++-v3/include/bits/std_thread.h @@ -145,6 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef GTHR_ACTIVE_PROXY // Create a reference to pthread_create, not just the gthr weak symbol. auto __depend = reinterpret_cast(&pthread_create); + static auto __attribute__((__unused__)) __depend_join = &pthread_join; #else auto __depend = nullptr; #endif