Skip to content

Commit 7d78e50

Browse files
committed
setup.py: Make sure CFLAGS has at least one -O
1 parent dc8aefb commit 7d78e50

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import subprocess
34
import sys
45
import unittest
@@ -39,10 +40,11 @@ def initialize_options(self):
3940
def build_libuv(self):
4041
env = os.environ.copy()
4142

42-
env['CFLAGS'] = ('-fPIC ' +
43-
env.get('CFLAGS', '-O2') +
44-
' ' +
45-
env.get('ARCHFLAGS', ''))
43+
cur_cflags = env.get('CFLAGS', '')
44+
if not re.search('-O\d', cur_cflags):
45+
cur_cflags += ' -O2'
46+
47+
env['CFLAGS'] = (cur_cflags + ' -fPIC' + env.get('ARCHFLAGS', ''))
4648

4749
j_flag = '-j{}'.format(os.cpu_count() or 1)
4850

0 commit comments

Comments
 (0)