compiler-rt, libcxxabi, libcxx: Drop libstdc++ usage

The configure scripts for these libraries was relying on
listdc++ installation for passing working compiler checks.

Replace with "STATIC_LIBRARY" target for compiler-rt
and mark the compiler as working for libc++/libc++abi.

BUG=chromium:1159292
TEST=CQ

Change-Id: I43b92578835aad9cb0a5e8b126f3a3cf355d54f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2594690
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Jian Cai <jiancai@google.com>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
diff --git a/sys-libs/compiler-rt/compiler-rt-12.0_pre408248-r1.ebuild b/sys-libs/compiler-rt/compiler-rt-12.0_pre408248-r2.ebuild
similarity index 100%
rename from sys-libs/compiler-rt/compiler-rt-12.0_pre408248-r1.ebuild
rename to sys-libs/compiler-rt/compiler-rt-12.0_pre408248-r2.ebuild
diff --git a/sys-libs/compiler-rt/compiler-rt-12.0_pre408248.ebuild b/sys-libs/compiler-rt/compiler-rt-12.0_pre408248.ebuild
index 63dfb76..2da73b1 100644
--- a/sys-libs/compiler-rt/compiler-rt-12.0_pre408248.ebuild
+++ b/sys-libs/compiler-rt/compiler-rt-12.0_pre408248.ebuild
@@ -51,16 +51,6 @@
 
 src_configure() {
 	setup_cross_toolchain
-	# Need libgcc for bootstrapping.
-	append-flags "-rtlib=libgcc"
-	# Compiler-rt libraries need to be built before libc++ when
-	# libc++ is default in clang.
-	# Compiler-rt builtins are C only.
-	# Even though building compiler-rt libraries does not require C++ compiler,
-	# CMake does not like a non-working C++ compiler.
-	# Avoid CMake complains about non-working C++ compiler
-	# by using libstdc++ since libc++ is built after compiler-rt in crossdev.
-	append-cxxflags "-stdlib=libstdc++"
 	append-flags "-fomit-frame-pointer"
 	if [[ ${CTARGET} == armv7a* ]]; then
 		# Use vfpv3 to be able to target non-neon targets
@@ -76,14 +66,18 @@
 
 	local mycmakeargs=(
 		"-DLLVM_ENABLE_PROJECTS=compiler-rt"
-
+		"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
 		# crbug/855759
 		"-DCOMPILER_RT_BUILD_CRT=$(usex llvm-crt)"
+		"-DCOMPILER_RT_USE_LIBCXX=yes"
+		"-DCOMPILER_RT_LIBCXXABI_PATH=${S}/libcxxabi"
+		"-DCOMPILER_RT_LIBCXX_PATH=${S}/libcxx"
+		"-DCOMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT=no"
+		"-DCOMPILER_RT_BUILD_LIBFUZZER=no"
 	)
 
 	if [[ ${CTARGET} == *-eabi ]]; then
 		mycmakeargs+=(
-			"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
 			"-DCOMPILER_RT_OS_DIR=baremetal"
 			"-DCOMPILER_RT_BAREMETAL_BUILD=yes"
 			"-DCMAKE_C_COMPILER_TARGET=${CTARGET}"
diff --git a/sys-libs/libcxx/libcxx-12.0_pre408248-r1.ebuild b/sys-libs/libcxx/libcxx-12.0_pre408248-r2.ebuild
similarity index 100%
rename from sys-libs/libcxx/libcxx-12.0_pre408248-r1.ebuild
rename to sys-libs/libcxx/libcxx-12.0_pre408248-r2.ebuild
diff --git a/sys-libs/libcxx/libcxx-12.0_pre408248.ebuild b/sys-libs/libcxx/libcxx-12.0_pre408248.ebuild
index 78d65cd..effdd3f 100644
--- a/sys-libs/libcxx/libcxx-12.0_pre408248.ebuild
+++ b/sys-libs/libcxx/libcxx-12.0_pre408248.ebuild
@@ -123,11 +123,12 @@
 		fi
 	fi
 
-	append-flags "-stdlib=libstdc++"
 	local libdir=$(get_libdir)
 	local mycmakeargs=(
 		"-DLLVM_ENABLE_PROJECTS=libcxx"
 		"-DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}"
+		"-DCMAKE_C_COMPILER_WORKS=yes"
+		"-DCMAKE_CXX_COMPILER_WORKS=yes"
 		"-DLIBCXX_ENABLE_SHARED=ON"
 		"-DLIBCXX_ENABLE_STATIC=$(usex static-libs)"
 		"-DLIBCXX_CXX_ABI=${cxxabi}"
diff --git a/sys-libs/libcxxabi/libcxxabi-12.0_pre408248-r1.ebuild b/sys-libs/libcxxabi/libcxxabi-12.0_pre408248-r2.ebuild
similarity index 100%
rename from sys-libs/libcxxabi/libcxxabi-12.0_pre408248-r1.ebuild
rename to sys-libs/libcxxabi/libcxxabi-12.0_pre408248-r2.ebuild
diff --git a/sys-libs/libcxxabi/libcxxabi-12.0_pre408248.ebuild b/sys-libs/libcxxabi/libcxxabi-12.0_pre408248.ebuild
index 4457bb8..512423f 100644
--- a/sys-libs/libcxxabi/libcxxabi-12.0_pre408248.ebuild
+++ b/sys-libs/libcxxabi/libcxxabi-12.0_pre408248.ebuild
@@ -72,12 +72,13 @@
 		append-flags -mfpu=vfpv3
 	fi
 	append-flags -I"${S}/libunwind/include"
-	append-flags "-stdlib=libstdc++"
 	# Enable futex in libc++abi to match prod toolchain.
 	append-cppflags -D_LIBCXXABI_USE_FUTEX
 	local libdir=$(get_libdir)
 	local mycmakeargs=(
 		"-DLLVM_ENABLE_PROJECTS=libcxxabi"
+		"-DCMAKE_C_COMPILER_WORKS=yes"
+		"-DCMAKE_CXX_COMPILER_WORKS=yes"
 		"-DLIBCXXABI_LIBDIR_SUFFIX=${libdir#lib}"
 		"-DLIBCXXABI_ENABLE_SHARED=ON"
 		"-DLIBCXXABI_ENABLE_STATIC=$(usex static-libs)"