8000 Enabling cxx interop on Arch with GCC 15 causes lots of errors · Issue #81774 · swiftlang/swift · GitHub
[go: up one dir, main page]

Skip to content

Enabling cxx interop on Arch with GCC 15 causes lots of errors #81774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gonsolo opened this issue May 26, 2025 · 3 comments
Open

Enabling cxx interop on Arch with GCC 15 causes lots of errors #81774

gonsolo opened this issue May 26, 2025 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++

Comments

@gonsolo
Copy link
Contributor
gonsolo commented May 26, 2025

Description

Enabling cxx interop on a simple example generates lots of errors with latest GCC on Arch Linux:

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:100:3: error: redefinition of 'acos'
  98 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  99 |   inline _GLIBCXX_CONSTEXPR float
 100 |   acos(float __x)
     |   |- error: redefinition of 'acos'
     |   `- note: previous definition is here
 101 |   { return __builtin_acosf(__x); }
 102 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:104:3: error: redefinition of 'acos'
 102 | 
 103 |   inline _GLIBCXX_CONSTEXPR long double
 104 |   acos(long double __x)
     |   |- error: redefinition of 'acos'
     |   `- note: previous definition is here
 105 |   { return __builtin_acosl(__x); }
 106 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:112:5: error: redefinition of 'acos'
 110 |     typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
 111 |                                     double>::__type
 112 |     acos(_Tp __x)
     |     |- error: redefinition of 'acos'
     |     `- note: previous definition is here
 113 |     { return __builtin_acos(__x); }
 114 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:119:3: error: redefinition of 'asin'
 117 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 118 |   inline _GLIBCXX_CONSTEXPR float
 119 |   asin(float __x)
     |   |- error: redefinition of 'asin'
     |   `- note: previous definition is here
 120 |   { return __builtin_asinf(__x); }
 121 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:123:3: error: redefinition of 'asin'
 121 | 
 122 |   inline _GLIBCXX_CONSTEXPR long double
 123 |   asin(long double __x)
     |   |- error: redefinition of 'asin'
     |   `- note: previous definition is here
 124 |   { return __builtin_asinl(__x); }
 125 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:131:5: error: redefinition of 'asin'
 129 |     typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
 130 |                                     double>::__type
 131 |     asin(_Tp __x)
     |     |- error: redefinition of 'asin'
     |     `- note: previous definition is here
 132 |     { return __builtin_asin(__x); }
 133 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:138:3: error: redefinition of 'atan'
 136 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 137 |   inline _GLIBCXX_CONSTEXPR float
 138 |   atan(float __x)
     |   |- error: redefinition of 'atan'
     |   `- note: previous definition is here
 139 |   { return __builtin_atanf(__x); }
 140 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:142:3: error: redefinition of 'atan'
 140 | 
 141 |   inline _GLIBCXX_CONSTEXPR long double
 142 |   atan(long double __x)
     |   |- error: redefinition of 'atan'
     |   `- note: previous definition is here
 143 |   { return __builtin_atanl(__x); }
 144 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:150:5: error: redefinition of 'atan'
 148 |     typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
 149 |                                     double>::__type
 150 |     atan(_Tp __x)
     |     |- error: redefinition of 'atan'
     |     `- note: previous definition is here
 151 |     { return __builtin_atan(__x); }
 152 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:157:3: error: redefinition of 'atan2'
 155 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 156 |   inline _GLIBCXX_CONSTEXPR float
 157 |   atan2(float __y, float __x)
     |   |- error: redefinition of 'atan2'
     |   `- note: previous definition is here
 158 |   { return __builtin_atan2f(__y, __x); }
 159 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:161:3: error: redefinition of 'atan2'
 159 | 
 160 |   inline _GLIBCXX_CONSTEXPR long double
 161 |   atan2(long double __y, long double __x)
     |   |- error: redefinition of 'atan2'
     |   `- note: previous definition is here
 162 |   { return __builtin_atan2l(__y, __x); }
 163 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:169:3: error: redefinition of 'ceil'
 167 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 168 |   inline _GLIBCXX_CONSTEXPR float
 169 |   ceil(float __x)
     |   |- error: redefinition of 'ceil'
     |   `- note: previous definition is here
 170 |   { return __builtin_ceilf(__x); }
 171 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:173:3: error: redefinition of 'ceil'
 171 | 
 172 |   inline _GLIBCXX_CONSTEXPR long double
 173 |   ceil(long double __x)
     |   |- error: redefinition of 'ceil'
     |   `- note: previous definition is here
 174 |   { return __builtin_ceill(__x); }
 175 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in fil
8000
e included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:181:5: error: redefinition of 'ceil'
 179 |     typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
 180 |                                     double>::__type
 181 |     ceil(_Tp __x)
     |     |- error: redefinition of 'ceil'
     |     `- note: previous definition is here
 182 |     { return __builtin_ceil(__x); }
 183 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:188:3: error: redefinition of 'cos'
 186 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 187 |   inline _GLIBCXX_CONSTEXPR float
 188 |   cos(float __x)
     |   |- error: redefinition of 'cos'
     |   `- note: previous definition is here
 189 |   { return __builtin_cosf(__x); }
 190 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:192:3: error: redefinition of 'cos'
 190 | 
 191 |   inline _GLIBCXX_CONSTEXPR long double
 192 |   cos(long double __x)
     |   |- error: redefinition of 'cos'
     |   `- note: previous definition is here
 193 |   { return __builtin_cosl(__x); }
 194 | #endif

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:200:5: error: redefinition of 'cos'
 198 |     typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
 199 |                                     double>::__type
 200 |     cos(_Tp __x)
     |     |- error: redefinition of 'cos'
     |     `- note: previous definition is here
 201 |     { return __builtin_cos(__x); }
 202 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:207:3: error: redefinition of 'cosh'
 205 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
 206 |   inline _GLIBCXX_CONSTEXPR float
 207 |   cosh(float __x)
     |   |- error: redefinition of 'cosh'
     |   `- note: previous definition is here
 208 |   { return __builtin_coshf(__x); }
 209 | 

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "_FoundationCShims.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
15 | 
16 | #include "_CShimsTargetConditionals.h"
17 | #include "_CStdlib.h"
   |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_FoundationCShims.h:17:
18 | #include "CFUniCharBitmapData.inc.h"
19 | #include "CFUniCharBitmapData.h"

/usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:10: note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 53 | 
 54 | #if __has_include(<math.h>)
 55 | #include <math.h>
    |          `- note: in file included from /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h:55:
 56 | #endif
 57 | 

/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:11: note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 34 | #define _GLIBCXX_MATH_H 1
 35 | 
 36 | # include <cmath>
    |           `- note: in file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/math.h:36:
 37 | 
 38 | using std::abs;

<unknown>:0: error: too many errors emitted, stopping now
<unknown>:0: error: could not build C module '_FoundationCShims'
/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/cmath:211:3: error: redefinition of 'cosh'
 209 | 
 210 |   inline _GLIBCXX_CONSTEXPR long double
 211 |   cosh(long double __x)
     |   |- error: redefinition of 'cosh'
     |   `- note: previous definition is here
 212 |   { return __builtin_coshl(__x); }
 213 | #endif
make: *** [Makefile:3: all] Fehler 1

Reproduction

Expected behavior

Just compile without errors.

Environment

Swift version 6.1.1 (swift-6.1.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

No response

@gonsolo gonsolo added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 26, 2025
@egorzhdan egorzhdan self-assigned this May 30, 2025
@egorzhdan egorzhdan added c++ interop Feature: Interoperability with C++ and removed triage needed This issue needs more specific labels labels May 30, 2025
@egorzhdan
Copy link
Contributor

Seems like a modularization issue on the intersection of CoreFoundation and libstdc++.

@gonsolo
Copy link
Contributor Author
gonsolo commented May 30, 2025

This helps:

+ #if 0
#if __has_include(<math.h>)
#endif
+ #endif

In /usr/lib/swift/lib/swift/_FoundationCShims/_CStdlib.h +55

@gonsolo
Copy link
Contributor Author
gonsolo commented Jun 1, 2025

It should be noted that math related functions still work:

let x = sin(3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++
Projects
None yet
Development

No branches or pull requests

2 participants
0