@@ -105,21 +105,40 @@ def add_optimization_flags(self):
105
105
"""
106
106
107
107
env = os .environ .copy ()
108
- if not setupext .config .getboolean ('libs' , 'enable_lto' , fallback = True ):
109
- return env
110
108
if sys .platform == 'win32' :
111
109
return env
112
-
110
+ enable_lto = setupext .config .getboolean ('libs' , 'enable_lto' ,
111
+ fallback = None )
112
+
113
+ if 'CFLAGS' in os .environ :
114
+ if '-fno-lto' in os .environ ['CFLAGS' ]:
115
+ if enable_lto is True :
116
+ raise ValueError ('Configuration enable_lto=True, but '
117
+ 'CFLAGS contains -fno-lto' )
118
+ enable_lto = False
113
119
cppflags = []
114
120
if 'CPPFLAGS' in os .environ :
115
121
cppflags .append (os .environ ['CPPFLAGS' ])
122
+ if '-fno-lto' in os .environ ['CPPFLAGS' ]:
123
+ if enable_lto is True :
124
+ raise ValueError ('Configuration enable_lto=True, but '
125
+ 'CPPFLAGS contains -fno-lto' )
126
+ enable_lto = False
116
127
cxxflags = []
117
128
if 'CXXFLAGS' in os .environ :
118
129
cxxflags .append (os .environ ['CXXFLAGS' ])
130
+ if '-fno-lto' in os .environ ['CXXFLAGS' ]:
131
+ if enable_lto is True :
132
+ raise ValueError ('Configuration enable_lto=True, but '
133
+ 'CXXFLAGS contains -fno-lto' )
134
+ enable_lto = False
119
135
ldflags = []
120
136
if 'LDFLAGS' in os .environ :
121
137
ldflags .append (os .environ ['LDFLAGS' ])
122
138
139
+ if enable_lto is False :
140
+ return env
141
+
123
142
if has_flag (self .compiler , '-fvisibility=hidden' ):
124
143
for ext in self .extensions :
125
144
ext .extra_compile_args .append ('-fvisibility=hidden' )
0 commit comments