From 1cd1b67b0ba87471304b046649316d466c5364bc Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Wed, 17 Aug 2022 16:08:45 +0200
Subject: [PATCH] [compiler-rt] fix building by GCC

---
 compiler-rt/cmake/config-ix.cmake | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index f0444eec0656..0e035afb9f10 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -403,11 +403,16 @@ if(APPLE)
   # We're setting the flag manually for each target OS
   set(CMAKE_OSX_DEPLOYMENT_TARGET "")
 
-  set(DARWIN_COMMON_CFLAGS -stdlib=libc++)
-  set(DARWIN_COMMON_LINK_FLAGS
-    -stdlib=libc++
-    -lc++
-    -lc++abi)
+  if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+    set(DARWIN_COMMON_CFLAGS -stdlib=libc++)
+    set(DARWIN_COMMON_LINK_FLAGS
+      -stdlib=libc++
+      -lc++
+      -lc++abi)
+  else()
+    set(DARWIN_COMMON_CFLAGS "")
+    set(DARWIN_COMMON_LINK_FLAGS "")
+  endif()
 
   check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
   if(COMPILER_RT_HAS_APP_EXTENSION)
-- 
2.37.2

