From b04b03ff065a85c7c635feb719e0a203dad68283 Mon Sep 17 00:00:00 2001 From: animalize Date: Mon, 8 Mar 2021 11:22:31 +0800 Subject: [PATCH] Use /O2 compiler option instead of /Ox for MSVC Compared to /Ox, /O2 has two additional options: /GF: Eliminate Duplicate Strings /Gy: Enable Function-Level Linking Co-Authored-By: Nikita Kniazev <2743474+Kojoley@users.noreply.github.com> --- distutils/_msvccompiler.py | 2 +- distutils/msvc9compiler.py | 4 ++-- distutils/msvccompiler.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/distutils/_msvccompiler.py b/distutils/_msvccompiler.py index e9af4cf5..b7a06082 100644 --- a/distutils/_msvccompiler.py +++ b/distutils/_msvccompiler.py @@ -248,7 +248,7 @@ def initialize(self, plat_name=None): # Future releases of Python 3.x will include all past # versions of vcruntime*.dll for compatibility. self.compile_options = [ - '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG', '/MD' + '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD' ] self.compile_options_debug = [ diff --git a/distutils/msvc9compiler.py b/distutils/msvc9compiler.py index 6934e964..a1b3b02f 100644 --- a/distutils/msvc9compiler.py +++ b/distutils/msvc9compiler.py @@ -399,13 +399,13 @@ def initialize(self, plat_name=None): self.preprocess_options = None if self.__arch == "x86": - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/Z7', '/D_DEBUG'] else: # Win64 - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', '/Z7', '/D_DEBUG'] diff --git a/distutils/msvccompiler.py b/distutils/msvccompiler.py index d5857cb1..2d447b85 100644 --- a/distutils/msvccompiler.py +++ b/distutils/msvccompiler.py @@ -283,13 +283,13 @@ def initialize(self): self.preprocess_options = None if self.__arch == "Intel": - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GX' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG'] else: # Win64 - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , + self.compile_options = [ '/nologo', '/O2', '/MD', '/W3', '/GS-' , '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', '/Z7', '/D_DEBUG']