Skip to content

Commit 26d1878

Browse files
committed
EXPERIMENT: [Python][CI] Optimize for size with MSVC
1 parent c344446 commit 26d1878

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

ci/appveyor-cpp-build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ popd
117117

118118
pushd python
119119

120+
set PYARROW_BUILD_VERBOSE=1
120121
set PYARROW_CMAKE_GENERATOR=%GENERATOR%
121122
set PYARROW_CXXFLAGS=%ARROW_CXXFLAGS%
122123
set PYARROW_PARALLEL=2

ci/scripts/python_wheel_windows_build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ popd
104104

105105
echo "=== (%PYTHON_VERSION%) Building wheel ==="
106106
set PYARROW_BUILD_TYPE=%CMAKE_BUILD_TYPE%
107+
set PYARROW_BUILD_VERBOSE=1
107108
set PYARROW_BUNDLE_ARROW_CPP=ON
108109
set PYARROW_CMAKE_GENERATOR=%CMAKE_GENERATOR%
109110
set PYARROW_INSTALL_TESTS=ON

python/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ endif()
145145

146146
include(BuildUtils)
147147

148+
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE)
149+
148150
# Cython generated code emits way to many warnings at CHECKIN and EVERYTHING
149151
set(BUILD_WARNING_LEVEL "PRODUCTION")
150152

@@ -188,6 +190,10 @@ if(MSVC)
188190
# "unused function" warning but the code emits another "function
189191
# call missing argument list" warning.
190192
string(APPEND CMAKE_CXX_FLAGS " /wd4551")
193+
194+
string(REPLACE "/O2 /Ob2" "/O1 /Ob1" ${CMAKE_CXX_FLAGS_RELEASE} CMAKE_CXX_FLAGS_RELEASE)
195+
string(REPLACE "/O2 /Ob2" "/O1 /Ob1" ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CMAKE_CXX_FLAGS_RELWITHDEBINFO)
196+
191197
else()
192198
# Enable perf and other tools to work properly
193199
string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer")

python/setup.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,20 @@ def append_cmake_bool(value, varname):
291291

292292
cmake_options.append(
293293
f'-DCMAKE_BUILD_TYPE={self.build_type.lower()}')
294+
if os.environ.get('PYARROW_BUILD_VERBOSE', '0') == '1':
295+
cmake_options.append('-DCMAKE_VERBOSE_MAKEFILE=ON')
294296

295297
extra_cmake_args = shlex.split(self.extra_cmake_args)
296298

297-
build_tool_args = []
298299
if sys.platform == 'win32':
299300
if not is_64_bit:
300301
raise RuntimeError('Not supported on 32-bit Windows')
301-
else:
302-
build_tool_args.append('--')
303-
if os.environ.get('PYARROW_BUILD_VERBOSE', '0') == '1':
304-
cmake_options.append('-DCMAKE_VERBOSE_MAKEFILE=ON')
305-
parallel = os.environ.get('PYARROW_PARALLEL')
306-
if parallel:
307-
build_tool_args.append(f'-j{parallel}')
302+
303+
build_tool_args = []
304+
build_tool_args.append('--')
305+
parallel = os.environ.get('PYARROW_PARALLEL')
306+
if parallel:
307+
build_tool_args.append(f'-j{parallel}')
308308

309309
# Generate the build files
310310
print("-- Running cmake for PyArrow")

0 commit comments

Comments
 (0)