@@ -2104,45 +2104,45 @@ def compile_args(march_flags=True):
21042104 )
21052105 detect_march = False
21062106
2107- if detect_march :
2108- GCC_compiler .march_flags = []
2107+ def get_lines (cmd , parse = True ):
2108+ p = subprocess_Popen (
2109+ cmd ,
2110+ stdout = subprocess .PIPE ,
2111+ stderr = subprocess .PIPE ,
2112+ stdin = subprocess .PIPE ,
2113+ shell = True ,
2114+ )
2115+ # For mingw64 with GCC >= 4.7, passing os.devnull
2116+ # as stdin (which is the default) results in the process
2117+ # waiting forever without returning. For that reason,
2118+ # we use a pipe, and use the empty string as input.
2119+ (stdout , stderr ) = p .communicate (input = b"" )
2120+ if p .returncode != 0 :
2121+ return None
21092122
2110- def get_lines (cmd , parse = True ):
2111- p = subprocess_Popen (
2112- cmd ,
2113- stdout = subprocess .PIPE ,
2114- stderr = subprocess .PIPE ,
2115- stdin = subprocess .PIPE ,
2116- shell = True ,
2117- )
2118- # For mingw64 with GCC >= 4.7, passing os.devnull
2119- # as stdin (which is the default) results in the process
2120- # waiting forever without returning. For that reason,
2121- # we use a pipe, and use the empty string as input.
2122- (stdout , stderr ) = p .communicate (input = b"" )
2123- if p .returncode != 0 :
2124- return None
2125-
2126- lines = BytesIO (stdout + stderr ).readlines ()
2127- lines = (l .decode () for l in lines )
2128- if parse :
2129- selected_lines = []
2130- for line in lines :
2131- if (
2132- "COLLECT_GCC_OPTIONS=" in line
2133- or "CFLAGS=" in line
2134- or "CXXFLAGS=" in line
2135- or "-march=native" in line
2136- ):
2137- continue
2138- selected_lines .extend (
2139- line .strip ()
2140- for reg in ("-march=" , "-mtune=" , "-target-cpu" , "-mabi=" )
2141- if reg in line
2142- )
2143- lines = list (set (selected_lines )) # to remove duplicate
2123+ lines = BytesIO (stdout + stderr ).readlines ()
2124+ lines = (l .decode () for l in lines )
2125+ if parse :
2126+ selected_lines = []
2127+ for line in lines :
2128+ if (
2129+ "COLLECT_GCC_OPTIONS=" in line
2130+ or "CFLAGS=" in line
2131+ or "CXXFLAGS=" in line
2132+ or "-march=native" in line
2133+ ):
2134+ continue
2135+ selected_lines .extend (
2136+ line .strip ()
2137+ for reg in ("-march=" , "-mtune=" , "-target-cpu" , "-mabi=" )
2138+ if reg in line
2139+ )
2140+ lines = list (set (selected_lines )) # to remove duplicate
21442141
2145- return lines
2142+ return lines
2143+
2144+ if detect_march :
2145+ GCC_compiler .march_flags = []
21462146
21472147 # The '-' at the end is needed. Otherwise, g++ do not output
21482148 # enough information.
0 commit comments