From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53482 invoked by alias); 17 Jan 2020 17:04:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 53465 invoked by uid 89); 17 Jan 2020 17:04:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=6666 X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Jan 2020 17:04:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579280675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=u97U7eihy2MhSK3L8mgr16AKZ79fSPrv8uNgu/tTiHo=; b=ER0aakKucV6DTJYSYIMbH1F035L24/UPgPld4W76B+eIC3bLaOcJDjJd83M6RMa4iI5NLW chYj+N8LprGlUPklbZX1Xf124wS23JN2PhmSV1UtiPp6P2z9opYkTALgowri1oQh927cs3 FlWc/6kF/o9I++QCdqqCEsUR/93gUJA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-251-uge8A0naMJC1sl_3OhHPug-1; Fri, 17 Jan 2020 12:04:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E7A8800D4C; Fri, 17 Jan 2020 17:04:31 +0000 (UTC) Received: from localhost (unknown [10.33.36.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA4FA48; Fri, 17 Jan 2020 17:04:30 +0000 (UTC) Date: Fri, 17 Jan 2020 18:18:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix freestanding build PR 92376) Message-ID: <20200117170429.GA874754@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline X-SW-Source: 2020-01/txt/msg01054.txt.bz2 --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 533 In a freestanding library we don't install the header, so don't try to include it unless it exists. Explicitly declare aligned alloc functions for freestanding, because doesn't declare them. PR libstdc++/92376 * include/bits/c++config: Only do PSTL config when the header is present, to fix freestanding. * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation functions if they were detected by configure. Tested powerpc64le-linux, committed to trunk. This needs to be backported too. --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 2388 commit 0ba6a850b597236832140bf57bf6083b6fab93f9 Author: Jonathan Wakely Date: Fri Jan 17 15:49:02 2020 +0000 libstdc++: Fix freestanding build PR 92376) =20=20=20=20 In a freestanding library we don't install the header, so don't try to include it unless it exists. =20=20=20=20 Explicitly declare aligned alloc functions for freestanding, because doesn't declare them. =20=20=20=20 PR libstdc++/92376 * include/bits/c++config: Only do PSTL config when the header is present, to fix freestanding. * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation functions if they were detected by configure. diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bit= s/c++config index 875a5e76890..b1fad59d4b3 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -666,6 +666,8 @@ namespace std // PSTL configuration =20 #if __cplusplus >=3D 201703L +// This header is not installed for freestanding: +#if __has_include() // Preserved here so we have some idea which version of upstream we've pul= led in // #define PSTL_VERSION 9000 =20 @@ -684,6 +686,7 @@ namespace std # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Conditio= n) =20 #include +#endif // __has_include +#endif // C++17 =20 -#endif // End of prewritten config; the settings discovered at configure time fol= low. diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new= _opa.cc index 4e36fbf589d..8fac193cc7e 100644 --- a/libstdc++-v3/libsupc++/new_opa.cc +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -43,6 +43,21 @@ extern "C" void *memalign(std::size_t boundary, std::siz= e_t size); using std::new_handler; using std::bad_alloc; =20 +#if ! _GLIBCXX_HOSTED +extern "C" +{ +# if _GLIBCXX_HAVE_ALIGNED_ALLOC + void *aligned_alloc(size_t alignment, size_t size); +# elif _GLIBCXX_HAVE__ALIGNED_MALLOC + void *_aligned_malloc(size_t size, size_t alignment); +# elif _GLIBCXX_HAVE_POSIX_MEMALIGN + void *posix_memalign(void **, size_t alignment, size_t size); +# elif _GLIBCXX_HAVE_MEMALIGN + void *memalign(size_t alignment, size_t size); +# endif +} +#endif + namespace __gnu_cxx { #if _GLIBCXX_HAVE_ALIGNED_ALLOC using ::aligned_alloc; --bp/iNruPH9dso1Pn--