From 466be215e431ddc7540840f814eed45163a141cc Mon Sep 17 00:00:00 2001 From: KotlinIsland <65446343+KotlinIsland@users.noreply.github.com> Date: Mon, 28 Mar 2022 13:23:52 +1000 Subject: [PATCH] [mypyc] Use more accurate flags with msvc (#12468) Co-authored-by: KotlinIsland --- mypyc/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mypyc/build.py b/mypyc/build.py index 8528aa088ac0..2c04eed9e64c 100644 --- a/mypyc/build.py +++ b/mypyc/build.py @@ -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