From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1008353-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id A79E21382C5
	for <garchives@archives.gentoo.org>; Fri,  9 Mar 2018 23:11:34 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id D4E9CE0814;
	Fri,  9 Mar 2018 23:11:33 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A7294E0814
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Mar 2018 23:11:33 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A0C2C335C31
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Mar 2018 23:11:32 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id E039F240
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Mar 2018 23:11:30 +0000 (UTC)
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Message-ID: <1520637086.54a35a5810b0475469b43d235f050cf8a8b7a54e.mgorny@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libcxx/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-libs/libcxx/libcxx-6.0.0.ebuild sys-libs/libcxx/libcxx-6.0.9999.ebuild sys-libs/libcxx/libcxx-9999.ebuild
X-VCS-Directories: sys-libs/libcxx/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: 54a35a5810b0475469b43d235f050cf8a8b7a54e
X-VCS-Branch: master
Date: Fri,  9 Mar 2018 23:11:30 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 939a9398-d45b-4b94-9ecf-68bdcc84fa9e
X-Archives-Hash: 5dcec607035d3fdc741e879df28539c6

commit:     54a35a5810b0475469b43d235f050cf8a8b7a54e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  9 23:05:14 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Mar  9 23:11:26 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54a35a58

sys-libs/libcxx: Try building with -nodefaultlibs for bootstrap

Add a hack that appends -nodefaultlibs if the C++ compiler fails to link
software otherwise. This is based on what we do in sys-libs/compiler-rt
already and it should make it possible to bootstrap libc++ on systems
without C++ standard library.

 sys-libs/libcxx/libcxx-6.0.0.ebuild    | 14 ++++++++++++++
 sys-libs/libcxx/libcxx-6.0.9999.ebuild | 14 ++++++++++++++
 sys-libs/libcxx/libcxx-9999.ebuild     | 14 ++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/sys-libs/libcxx/libcxx-6.0.0.ebuild b/sys-libs/libcxx/libcxx-6.0.0.ebuild
index 9c9b75e3d7f..0948ab0c682 100644
--- a/sys-libs/libcxx/libcxx-6.0.0.ebuild
+++ b/sys-libs/libcxx/libcxx-6.0.0.ebuild
@@ -73,6 +73,11 @@ pkg_setup() {
 	fi
 }
 
+test_compiler() {
+	$(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \
+		<<<'int main() { return 0; }' &>/dev/null
+}
+
 multilib_src_configure() {
 	local cxxabi cxxabi_incs
 	if use libcxxabi; then
@@ -109,6 +114,15 @@ multilib_src_configure() {
 		fi
 	fi
 
+	# bootstrap: cmake is unhappy if compiler can't link to stdlib
+	local nolib_flags=( -nodefaultlibs -lc )
+	if ! test_compiler; then
+		if test_compiler "${nolib_flags[@]}"; then
+			local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
+			ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+		fi
+	fi
+
 	local libdir=$(get_libdir)
 	local mycmakeargs=(
 		-DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}

diff --git a/sys-libs/libcxx/libcxx-6.0.9999.ebuild b/sys-libs/libcxx/libcxx-6.0.9999.ebuild
index cf76bba5fdf..4e687c722c6 100644
--- a/sys-libs/libcxx/libcxx-6.0.9999.ebuild
+++ b/sys-libs/libcxx/libcxx-6.0.9999.ebuild
@@ -85,6 +85,11 @@ pkg_setup() {
 	fi
 }
 
+test_compiler() {
+	$(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \
+		<<<'int main() { return 0; }' &>/dev/null
+}
+
 multilib_src_configure() {
 	local cxxabi cxxabi_incs
 	if use libcxxabi; then
@@ -121,6 +126,15 @@ multilib_src_configure() {
 		fi
 	fi
 
+	# bootstrap: cmake is unhappy if compiler can't link to stdlib
+	local nolib_flags=( -nodefaultlibs -lc )
+	if ! test_compiler; then
+		if test_compiler "${nolib_flags[@]}"; then
+			local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
+			ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+		fi
+	fi
+
 	local libdir=$(get_libdir)
 	local mycmakeargs=(
 		-DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}

diff --git a/sys-libs/libcxx/libcxx-9999.ebuild b/sys-libs/libcxx/libcxx-9999.ebuild
index 214c61d31f6..f304a076c17 100644
--- a/sys-libs/libcxx/libcxx-9999.ebuild
+++ b/sys-libs/libcxx/libcxx-9999.ebuild
@@ -84,6 +84,11 @@ pkg_setup() {
 	fi
 }
 
+test_compiler() {
+	$(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \
+		<<<'int main() { return 0; }' &>/dev/null
+}
+
 multilib_src_configure() {
 	local cxxabi cxxabi_incs
 	if use libcxxabi; then
@@ -120,6 +125,15 @@ multilib_src_configure() {
 		fi
 	fi
 
+	# bootstrap: cmake is unhappy if compiler can't link to stdlib
+	local nolib_flags=( -nodefaultlibs -lc )
+	if ! test_compiler; then
+		if test_compiler "${nolib_flags[@]}"; then
+			local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
+			ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+		fi
+	fi
+
 	local libdir=$(get_libdir)
 	local mycmakeargs=(
 		-DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}