Skip to content

Commit

Permalink
[mypyc] Use more accurate flags with msvc (#12468)
Browse files Browse the repository at this point in the history
Co-authored-by: KotlinIsland <[email protected]>
  • Loading branch information
KotlinIsland and KotlinIsland authored Mar 28, 2022
1 parent ecef427 commit 466be21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mypyc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,20 @@ def mypycify(
# This flag is needed for gcc but does not exist on clang.
cflags += ['-Wno-unused-but-set-variable']
elif compiler.compiler_type == 'msvc':
if opt_level == '3':
# msvc doesn't have levels, '/O2' is full and '/Od' is disable
if opt_level == '0':
opt_level = 'd'
elif opt_level in ('1', '2', '3'):
opt_level = '2'
if debug_level == '0':
debug_level = "NONE"
elif debug_level == '1':
debug_level = "FASTLINK"
elif debug_level in ('2', '3'):
debug_level = "FULL"
cflags += [
'/O{}'.format(opt_level),
f'/DEBUG:{debug_level}',
'/wd4102', # unreferenced label
'/wd4101', # unreferenced local variable
'/wd4146', # negating unsigned int
Expand Down

0 comments on commit 466be21

Please sign in to comment.