@@ -70,6 +70,10 @@ class ModDesc(NamedTuple):
7070 "base64/arch/neon64/codec.c" ,
7171 ],
7272 [
73+ "base64/arch/avx/enc_loop_asm.c" ,
74+ "base64/arch/avx2/enc_loop_asm.c" ,
75+ "base64/arch/avx2/dec_loop.c" ,
76+ "base64/arch/avx2/dec_reshuffle.c" ,
7377 "base64/arch/generic/32/enc_loop.c" ,
7478 "base64/arch/generic/64/enc_loop.c" ,
7579 "base64/arch/generic/32/dec_loop.c" ,
@@ -118,6 +122,51 @@ class ModDesc(NamedTuple):
118122else :
119123 from distutils import ccompiler , sysconfig
120124
125+ EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT = {
126+ "unix" : {
127+ "base64/arch/ssse3" : "-mssse3" ,
128+ "base64/arch/sse41" : "-msse4.1" ,
129+ "base64/arch/sse42" : "-msse4.2" ,
130+ "base64/arch/avx2" : "-mavx2" ,
131+ "base64/arch/avx" : "-mavx" ,
132+ },
133+ "msvc" : {
134+ "base64/arch/sse42" : "/arch:SSE4.2" ,
135+ "base64/arch/avx2" : "/arch:AVX2" ,
136+ "base64/arch/avx" : "/arch:AVX" ,
137+ }
138+ }
139+
140+
141+ def spawn (self : ccompiler .CCompiler , cmd : Iterable [str ], ** kwargs : Any ) -> None :
142+ compiler_type : str = self .compiler_type # type: ignore[attr-defined]
143+ extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT [compiler_type ]
144+ new_cmd = list (cmd )
145+ if extra_options is not None :
146+ # filenames are closer to the end of command line
147+ for argument in reversed (new_cmd ):
148+ # Check if argument contains a filename. We must check for all
149+ # possible extensions; checking for target extension is faster.
150+ if self .obj_extension and not str (argument ).endswith (self .obj_extension ): # type: ignore[attr-defined]
151+ continue
152+
153+ for path in extra_options .keys ():
154+ if path in str (argument ):
155+ if compiler_type == 'bcpp' :
156+ # Borland accepts a source file name at the end,
157+ # insert the options before it
158+ new_cmd [- 1 :- 1 ] = extra_options [path ]
159+ else :
160+ new_cmd .append (extra_options [path ])
161+
162+ # path component is found, no need to search any further
163+ break
164+ self .__spawn (new_cmd , ** kwargs ) # type: ignore[attr-defined]
165+
166+
167+ ccompiler .CCompiler .__spawn = ccompiler .CCompiler .spawn # type: ignore[attr-defined]
168+ ccompiler .CCompiler .spawn = spawn # type: ignore[method-assign]
169+
121170
122171def get_extension () -> type [Extension ]:
123172 # We can work with either setuptools or distutils, and pick setuptools
@@ -661,9 +710,6 @@ def mypycify(
661710 # See https://github.com/mypyc/mypyc/issues/956
662711 "-Wno-cpp" ,
663712 ]
664- if X86_64 :
665- # Enable SIMD extensions. All CPUs released since ~2010 support SSE4.2.
666- cflags .append ("-msse4.2" )
667713 if log_trace :
668714 cflags .append ("-DMYPYC_LOG_TRACE" )
669715 if experimental_features :
@@ -692,10 +738,6 @@ def mypycify(
692738 # that we actually get the compilation speed and memory
693739 # use wins that multi-file mode is intended for.
694740 cflags += ["/GL-" , "/wd9025" ] # warning about overriding /GL
695- if X86_64 :
696- # Enable SIMD extensions. All CPUs released since ~2010 support SSE4.2.
697- # Also Windows 11 requires SSE4.2 since 24H2.
698- cflags .append ("/arch:SSE4.2" )
699741 if log_trace :
700742 cflags .append ("/DMYPYC_LOG_TRACE" )
701743 if experimental_features :
0 commit comments