Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-4297: [C++] Fix build error with MinGW-w64 32-bit #3693

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions appveyor.yml
Expand Up @@ -36,14 +36,6 @@ cache:

matrix:
fast_finish: true
allow_failures:
# Can't build with 32-bit MinGW for now.
# See https://issues.apache.org/jira/browse/ARROW-4297
- JOB: "MinGW32"
MINGW_PACKAGE_PREFIX: mingw-w64-i686
MINGW_PREFIX: c:\msys64\mingw32
MSYSTEM: MINGW32
USE_CLCACHE: false

environment:
global:
Expand Down
3 changes: 3 additions & 0 deletions ci/appveyor-cpp-build-mingw.bat
Expand Up @@ -44,8 +44,11 @@ cmake ^
-DARROW_PYTHON=ON ^
-DPythonInterp_FIND_VERSION=ON ^
-DPythonInterp_FIND_VERSION_MAJOR=3 ^
-DARROW_BUILD_TESTS=ON ^
-DARROW_PYTHON=OFF ^
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?
Could you show details of the error by resolving this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kou, sure:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
The following patch will solve this.

diff --git a/ci/appveyor-cpp-build-mingw.bat b/ci/appveyor-cpp-build-mingw.bat
index 06e8b7f7..3a853031 100644
--- a/ci/appveyor-cpp-build-mingw.bat
+++ b/ci/appveyor-cpp-build-mingw.bat
@@ -24,6 +24,15 @@ set INSTALL_DIR=%HOMEDRIVE%%HOMEPATH%\install
 set PATH=%INSTALL_DIR%\bin;%PATH%
 set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig
 
+for /f "usebackq" %%v in (`python3 -c "import sys; print('.'.join(map(str, sys.version_info[0:2])))"`) do (
+  set PYTHON_VERSION=%%v
+)
+
+set PYTHONHOME=%MINGW_PREFIX%\lib\python%PYTHON_VERSION%
+set PYTHONPATH=%PYTHONHOME%
+set PYTHONPATH=%PYTHONPATH%;%MINGW_PREFIX%\lib\python%PYTHON_VERSION%\lib-dynload
+set PYTHONPATH=%PYTHONPATH%;%MINGW_PREFIX%\lib\python%PYTHON_VERSION%\site-packages
+
 set CPP_BUILD_DIR=cpp\build
 mkdir %CPP_BUILD_DIR%
 pushd %CPP_BUILD_DIR%

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you set PYTHONHOME you shouldn't have to set PYTHONPATH as well. Python will infer the path automatically from PYTHONHOME.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try that, give me a sec...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the original suggestion breaks the build, see https://ci.appveyor.com/project/ApacheSoftwareFoundation/arrow/builds/22735113/job/y7dijp1ym0y1q87g, which triggers:

[ 43%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/json-simple.cc.obj
[ 44%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/message.cc.obj
[ 44%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/metadata-internal.cc.obj
[ 45%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/reader.cc.obj
[ 45%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/writer.cc.obj
[ 45%] Built target arrow_objlib
make: *** [Makefile:141: all] Error 2
C:\projects\arrow\cpp\build>goto scriptexit 
C:\projects\arrow\cpp\build>set lastexitcode=2 
C:\projects\arrow\cpp\build>set  1>C:\Users\appveyor\AppData\Local\Temp\1\tmp56B0.tmp 
C:\projects\arrow\cpp\build>echo C:\projects\arrow\cpp\build  1>C:\Users\appveyor\AppData\Local\Temp\1\tmp56B1.tmp 
C:\projects\arrow\cpp\build>exit /b 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't resolve without PYTHONPATH on local:

> set PYTHONHOME=c:\msys64\mingw64\lib\python3.7
> python3 -vv -c 1
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'zipimport' # <class '_frozen_importlib.BuiltinImporter'>
# installed zipimport hook
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'nt' # <class '_frozen_importlib.BuiltinImporter'>
import _thread # previously loaded ('_thread')
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import _weakref # previously loaded ('_weakref')
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import 'winreg' # <class '_frozen_importlib.BuiltinImporter'>
# trying C:/msys64/mingw64/bin\encodings-cpython-37m.dll
# trying C:/msys64/mingw64/bin\encodings-abi3.dll
# trying C:/msys64/mingw64/bin\encodings.cp37.pyd
# trying C:/msys64/mingw64/bin\encodings.pyd
# trying C:/msys64/mingw64/bin\encodings.py
# trying C:/msys64/mingw64/bin\encodings.pyw
# trying C:/msys64/mingw64/bin\encodings.pyc
Fatal Python error: initfsencoding: unable to load the file system codec
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
# trying C:/msys64/mingw64/bin\io-cpython-37m.dll
# trying C:/msys64/mingw64/bin\io-abi3.dll
# trying C:/msys64/mingw64/bin\io.cp37.pyd
# trying C:/msys64/mingw64/bin\io.pyd
# trying C:/msys64/mingw64/bin\io.py
# trying C:/msys64/mingw64/bin\io.pyw
# trying C:/msys64/mingw64/bin\io.pyc
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
# trying C:/msys64/mingw64/bin\io-cpython-37m.dll
# trying C:/msys64/mingw64/bin\io-abi3.dll
# trying C:/msys64/mingw64/bin\io.cp37.pyd
# trying C:/msys64/mingw64/bin\io.pyd
# trying C:/msys64/mingw64/bin\io.py
# trying C:/msys64/mingw64/bin\io.pyw
# trying C:/msys64/mingw64/bin\io.pyc
ModuleNotFoundError: No module named 'encodings'

With PYTHONPATH:

> set PYTHONHOME=c:\msys64\mingw64\lib\python3.7
> set PYTHONPATH=%PYTHONHOME%
> set PYTHONPATH=%PYTHONPATH%;c:\msys64\mingw64\lib\python3.7\lib-dynload
> set PYTHONPATH=%PYTHONPATH%;c:\msys64\mingw64\lib\python3.7\site-packages
> python3 -vv -c 1
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'zipimport' # <class '_frozen_importlib.BuiltinImporter'>
# installed zipimport hook
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'nt' # <class '_frozen_importlib.BuiltinImporter'>
import _thread # previously loaded ('_thread')
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import _weakref # previously loaded ('_weakref')
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import 'winreg' # <class '_frozen_importlib.BuiltinImporter'>
# c:\msys64\mingw64\lib\python3.7\encodings\__pycache__\__init__.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\encodings\__init__.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\encodings\\__pycache__\\__init__.cpython-37.pyc'
# trying c:\msys64\mingw64\lib\python3.7\codecs-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\codecs-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\codecs.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\codecs.pyd
# trying c:\msys64\mingw64\lib\python3.7\codecs.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\codecs.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\codecs.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\codecs.cpython-37.pyc'
import '_codecs' # <class '_frozen_importlib.BuiltinImporter'>
import 'codecs' # <_frozen_importlib_external.SourceFileLoader object at 0x00000000029fe080>
# trying c:\msys64\mingw64\lib\python3.7\encodings\aliases-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\aliases-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\aliases.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\aliases.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\aliases.py
# c:\msys64\mingw64\lib\python3.7\encodings\__pycache__\aliases.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\encodings\aliases.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\encodings\\__pycache__\\aliases.cpython-37.pyc'
import 'encodings.aliases' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a099b0>
import 'encodings' # <_frozen_importlib_external.SourceFileLoader object at 0x00000000029f02e8>
# trying c:\msys64\mingw64\lib\python3.7\encodings\utf_8-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\utf_8-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\utf_8.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\utf_8.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\utf_8.py
# c:\msys64\mingw64\lib\python3.7\encodings\__pycache__\utf_8.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\encodings\utf_8.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\encodings\\__pycache__\\utf_8.cpython-37.pyc'
import 'encodings.utf_8' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a1aa58>
import '_signal' # <class '_frozen_importlib.BuiltinImporter'>
# trying c:\msys64\mingw64\lib\python3.7\encodings\latin_1-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\latin_1-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\encodings\latin_1.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\latin_1.pyd
# trying c:\msys64\mingw64\lib\python3.7\encodings\latin_1.py
# c:\msys64\mingw64\lib\python3.7\encodings\__pycache__\latin_1.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\encodings\latin_1.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\encodings\\__pycache__\\latin_1.cpython-37.pyc'
import 'encodings.latin_1' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a1ae80>
# trying c:\msys64\mingw64\lib\python3.7\io-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\io-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\io.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\io.pyd
# trying c:\msys64\mingw64\lib\python3.7\io.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\io.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\io.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\io.cpython-37.pyc'
# trying c:\msys64\mingw64\lib\python3.7\abc-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\abc-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\abc.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\abc.pyd
# trying c:\msys64\mingw64\lib\python3.7\abc.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\abc.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\abc.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\abc.cpython-37.pyc'
import '_abc' # <class '_frozen_importlib.BuiltinImporter'>
import 'abc' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a1e4a8>
import 'io' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a1e0f0>
# trying c:\msys64\mingw64\lib\python3.7\site-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\site-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\site.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\site.pyd
# trying c:\msys64\mingw64\lib\python3.7\site.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\site.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\site.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\site.cpython-37.pyc'
# trying c:\msys64\mingw64\lib\python3.7\os-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\os-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\os.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\os.pyd
# trying c:\msys64\mingw64\lib\python3.7\os.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\os.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\os.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\os.cpython-37.pyc'
# trying c:\msys64\mingw64\lib\python3.7\stat-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\stat-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\stat.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\stat.pyd
# trying c:\msys64\mingw64\lib\python3.7\stat.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\stat.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\stat.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\stat.cpython-37.pyc'
import '_stat' # <class '_frozen_importlib.BuiltinImporter'>
import 'stat' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002b1a7b8>
# trying c:\msys64\mingw64\lib\python3.7\ntpath-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\ntpath-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\ntpath.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\ntpath.pyd
# trying c:\msys64\mingw64\lib\python3.7\ntpath.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\ntpath.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\ntpath.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\ntpath.cpython-37.pyc'
# trying c:\msys64\mingw64\lib\python3.7\genericpath-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\genericpath-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\genericpath.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\genericpath.pyd
# trying c:\msys64\mingw64\lib\python3.7\genericpath.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\genericpath.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\genericpath.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\genericpath.cpython-37.pyc'
import 'genericpath' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002b278d0>
import 'ntpath' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002b1ae10>
# trying c:\msys64\mingw64\lib\python3.7\_collections_abc-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\_collections_abc-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\_collections_abc.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\_collections_abc.pyd
# trying c:\msys64\mingw64\lib\python3.7\_collections_abc.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\_collections_abc.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\_collections_abc.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\_collections_abc.cpython-37.pyc'
import '_collections_abc' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002b27e10>
import 'os' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a2e3c8>
# trying c:\msys64\mingw64\lib\python3.7\_sitebuiltins-cpython-37m.dll
# trying c:\msys64\mingw64\lib\python3.7\_sitebuiltins-abi3.dll
# trying c:\msys64\mingw64\lib\python3.7\_sitebuiltins.cp37.pyd
# trying c:\msys64\mingw64\lib\python3.7\_sitebuiltins.pyd
# trying c:\msys64\mingw64\lib\python3.7\_sitebuiltins.py
# c:\msys64\mingw64\lib\python3.7\__pycache__\_sitebuiltins.cpython-37.pyc matches c:\msys64\mingw64\lib\python3.7\_sitebuiltins.py
# code object from 'c:\\msys64\\mingw64\\lib\\python3.7\\__pycache__\\_sitebuiltins.cpython-37.pyc'
import '_sitebuiltins' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a2ec50>
# trying C:/msys64/mingw64/lib/python3.7\sysconfig-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7\sysconfig-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7\sysconfig.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7\sysconfig.pyd
# trying C:/msys64/mingw64/lib/python3.7\sysconfig.py
# C:/msys64/mingw64/lib/python3.7\__pycache__\sysconfig.cpython-37.pyc matches C:/msys64/mingw64/lib/python3.7\sysconfig.py
# code object from 'C:/msys64/mingw64/lib/python3.7\\__pycache__\\sysconfig.cpython-37.pyc'
import 'sysconfig' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a2eda0>
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize.py
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7\sitecustomize.pyc
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize.py
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\sitecustomize.pyc
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize.py
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7/site-packages\sitecustomize.pyc
# trying C:/msys64/mingw64/bin\sitecustomize-cpython-37m.dll
# trying C:/msys64/mingw64/bin\sitecustomize-abi3.dll
# trying C:/msys64/mingw64/bin\sitecustomize.cp37.pyd
# trying C:/msys64/mingw64/bin\sitecustomize.pyd
# trying C:/msys64/mingw64/bin\sitecustomize.py
# trying C:/msys64/mingw64/bin\sitecustomize.pyw
# trying C:/msys64/mingw64/bin\sitecustomize.pyc
# trying C:/msys64/mingw64/lib/python3.7\usercustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7\usercustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7\usercustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7\usercustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7\usercustomize.py
# trying C:/msys64/mingw64/lib/python3.7\usercustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7\usercustomize.pyc
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize.py
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7/lib-dynload\usercustomize.pyc
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize-cpython-37m.dll
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize-abi3.dll
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize.cp37.pyd
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize.pyd
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize.py
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize.pyw
# trying C:/msys64/mingw64/lib/python3.7/site-packages\usercustomize.pyc
# trying C:/msys64/mingw64/bin\usercustomize-cpython-37m.dll
# trying C:/msys64/mingw64/bin\usercustomize-abi3.dll
# trying C:/msys64/mingw64/bin\usercustomize.cp37.pyd
# trying C:/msys64/mingw64/bin\usercustomize.pyd
# trying C:/msys64/mingw64/bin\usercustomize.py
# trying C:/msys64/mingw64/bin\usercustomize.pyw
# trying C:/msys64/mingw64/bin\usercustomize.pyc
import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x0000000002a1ef60>
Python 3.7.0 (default, Aug  3 2018, 11:56:18)  [GCC 8.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
# clear builtins._
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to set environment variables for Python only around testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to work this on another pull request, could you open an issue on JIRA?

.. || exit /B
make -j4 || exit /B
ctest --output-on-failure -j2 || exit /B
make install || exit /B
popd

Expand Down
1 change: 1 addition & 0 deletions ci/appveyor-cpp-setup-mingw.bat
Expand Up @@ -25,6 +25,7 @@ pacman -S --noconfirm ^
"%MINGW_PACKAGE_PREFIX%-cmake" ^
"%MINGW_PACKAGE_PREFIX%-flatbuffers" ^
"%MINGW_PACKAGE_PREFIX%-gcc" ^
"%MINGW_PACKAGE_PREFIX%-gflags" ^
"%MINGW_PACKAGE_PREFIX%-gobject-introspection" ^
"%MINGW_PACKAGE_PREFIX%-gtk-doc" ^
"%MINGW_PACKAGE_PREFIX%-lz4" ^
Expand Down
25 changes: 18 additions & 7 deletions cpp/src/arrow/CMakeLists.txt
Expand Up @@ -301,13 +301,24 @@ arrow_add_pkg_config("arrow")
#

add_arrow_test(allocator-test)
add_arrow_test(array-test
SOURCES
array-test.cc
array-binary-test.cc
array-dict-test.cc
array-list-test.cc
array-struct-test.cc)

if(WIN32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javierluraschi @kou In the future, please add a comment when you add a special case like this, so that we know why it is there.
(also, this test should really be more narrow)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Sorry for this.
(I should have pushed a change for #3693 (comment) by myself.)

add_arrow_test(array-test
SOURCES
array-test.cc
array-binary-test.cc
array-list-test.cc
array-struct-test.cc)
else()
add_arrow_test(array-test
SOURCES
array-test.cc
array-binary-test.cc
array-dict-test.cc
array-list-test.cc
array-struct-test.cc)
endif()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it needed?
Could you show error details?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I wasn't able to reproduce this one on my local MinGW 32-bit environment, but let me disable it and hopefully your new test command will output something in appveyor that can point us in the right direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so from AppVeyor, looks like this is causing:

/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0xb9a2): undefined reference to `arrow::DictionaryBuilder<arrow::FixedSizeBinaryType>::DictionaryBuilder(std::shared_ptr<arrow::DataType> const&, arrow::MemoryPool*)'
CMakeFiles/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0xcb8a): undefined reference to `arrow::DictionaryBuilder<arrow::FixedSizeBinaryType>::DictionaryBuilder(std::shared_ptr<arrow::DataType> const&, arrow::MemoryPool*)'
CMakeFiles/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0xeef8): undefined reference to `arrow::DictionaryBuilder<arrow::FixedSizeBinaryType>::DictionaryBuilder(std::shared_ptr<arrow::DataType> const&, arrow::MemoryPool*)'
CMakeFiles/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0x10240): undefined reference to `arrow::DictionaryBuilder<arrow::FixedSizeBinaryType>::DictionaryBuilder(std::shared_ptr<arrow::DataType> const&, arrow::MemoryPool*)'
CMakeFiles/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0x104fc): undefined reference to `arrow::DictionaryBuilder<arrow::FixedSizeBinaryType>::AppendArray(arrow::Array const&)'
CMakeFiles/arrow-array-test.dir/objects.a(array-dict-test.cc.obj):array-dict-test.cc:(.text+0x108ef): undefined reference to `arrow

Which again, I can't repro locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me re-skip this test to have them back at passing... My suggestion would be to merge with a couple tests skipped and then open JIRA issues to investigate further. Otherwise, the longer it take us to merge this PR, the more likely something else will break Windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
We need to stop using template and ARROW_EXPORT for arrow::DictionaryBuilder like #3509.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you open an issue on JIRA to work this on another pull request?
if(WIN32) is too general. It matches build with MSVC.
if(WIN32 AND "${COMPILER_FAMIL}" STREQUAL "gcc") is better.

add_arrow_test(buffer-test)

if(ARROW_IPC)
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/compute/kernels/cast-test.cc
Expand Up @@ -424,6 +424,7 @@ TEST_F(TestCast, FloatingPointToInt) {
options);
}

#if ARROW_BITNESS >= 64
TEST_F(TestCast, IntToFloatingPoint) {
auto options = CastOptions::Safe();

Expand All @@ -438,6 +439,7 @@ TEST_F(TestCast, IntToFloatingPoint) {
UnsafeVectorCast<double, int64_t>(v1),
options);
}
#endif

TEST_F(TestCast, TimestampToTimestamp) {
CastOptions options;
Expand Down
65 changes: 13 additions & 52 deletions cpp/src/arrow/util/hash-util.h
Expand Up @@ -81,10 +81,13 @@ class HashUtil {
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
const uint8_t* end = p + nbytes;

#if ARROW_BITNESS >= 64
while (p <= end - 8) {
hash = HW_crc32_u64(hash, *reinterpret_cast<const uint64_t*>(p));
p += 8;
}
#endif

while (p <= end - 4) {
hash = HW_crc32_u32(hash, *reinterpret_cast<const uint32_t*>(p));
p += 4;
Expand Down Expand Up @@ -113,6 +116,7 @@ class HashUtil {
uint32_t h1 = static_cast<uint32_t>(hash >> 32);
uint32_t h2 = static_cast<uint32_t>(hash);

#if ARROW_BITNESS >= 64
while (nbytes >= 16) {
h1 = HW_crc32_u64(h1, *reinterpret_cast<const uint64_t*>(p));
h2 = HW_crc32_u64(h2, *reinterpret_cast<const uint64_t*>(p + 8));
Expand All @@ -125,6 +129,15 @@ class HashUtil {
nbytes -= 8;
p += 8;
}
#else
while (nbytes >= 8) {
h1 = HW_crc32_u32(h1, *reinterpret_cast<const uint32_t*>(p));
h2 = HW_crc32_u32(h2, *reinterpret_cast<const uint32_t*>(p + 4));
nbytes -= 8;
p += 8;
}
#endif

if (nbytes >= 4) {
h1 = HW_crc32_u16(h1, *reinterpret_cast<const uint16_t*>(p));
h2 = HW_crc32_u16(h2, *reinterpret_cast<const uint16_t*>(p + 2));
Expand All @@ -151,58 +164,6 @@ class HashUtil {
return (static_cast<uint64_t>(h1) << 32) + h2;
}

/// CrcHash() specialized for 1-byte data
static inline uint32_t CrcHash1(const void* v, uint32_t hash) {
const uint8_t* s = reinterpret_cast<const uint8_t*>(v);
hash = HW_crc32_u8(hash, *s);
hash = (hash << 16) | (hash >> 16);
return hash;
}

/// CrcHash() specialized for 2-byte data
static inline uint32_t CrcHash2(const void* v, uint32_t hash) {
const uint16_t* s = reinterpret_cast<const uint16_t*>(v);
hash = HW_crc32_u16(hash, *s);
hash = (hash << 16) | (hash >> 16);
return hash;
}

/// CrcHash() specialized for 4-byte data
static inline uint32_t CrcHash4(const void* v, uint32_t hash) {
const uint32_t* p = reinterpret_cast<const uint32_t*>(v);
hash = HW_crc32_u32(hash, *p);
hash = (hash << 16) | (hash >> 16);
return hash;
}

/// CrcHash() specialized for 8-byte data
static inline uint32_t CrcHash8(const void* v, uint32_t hash) {
const uint64_t* p = reinterpret_cast<const uint64_t*>(v);
hash = HW_crc32_u64(hash, *p);
hash = (hash << 16) | (hash >> 16);
return hash;
}

/// CrcHash() specialized for 12-byte data
static inline uint32_t CrcHash12(const void* v, uint32_t hash) {
const uint64_t* p = reinterpret_cast<const uint64_t*>(v);
hash = HW_crc32_u64(hash, *p);
++p;
hash = HW_crc32_u32(hash, *reinterpret_cast<const uint32_t*>(p));
hash = (hash << 16) | (hash >> 16);
return hash;
}

/// CrcHash() specialized for 16-byte data
static inline uint32_t CrcHash16(const void* v, uint32_t hash) {
const uint64_t* p = reinterpret_cast<const uint64_t*>(v);
hash = HW_crc32_u64(hash, *p);
++p;
hash = HW_crc32_u64(hash, *p);
hash = (hash << 16) | (hash >> 16);
return hash;
}

static const uint64_t MURMUR_PRIME = 0xc6a4a7935bd1e995;
static const int MURMUR_R = 47;

Expand Down
13 changes: 13 additions & 0 deletions cpp/src/arrow/util/macros.h
Expand Up @@ -18,6 +18,8 @@
#ifndef ARROW_UTIL_MACROS_H
#define ARROW_UTIL_MACROS_H

#include <cstdint>

#define ARROW_STRINGIFY(x) #x
#define ARROW_CONCAT(x, y) x##y

Expand Down Expand Up @@ -123,6 +125,17 @@
#define ARROW_DISABLE_UBSAN(feature)
#endif

// ----------------------------------------------------------------------
// Machine information

#if INTPTR_MAX == INT64_MAX
#define ARROW_BITNESS 64
#elif INTPTR_MAX == INT32_MAX
#define ARROW_BITNESS 32
#else
#error Unexpected INTPTR_MAX
#endif

// ----------------------------------------------------------------------
// From googletest
// (also in parquet-cpp)
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/util/sse-util.h
Expand Up @@ -110,7 +110,11 @@ static inline uint32_t SSE4_crc32_u32(uint32_t crc, uint32_t v) {
}

static inline uint32_t SSE4_crc32_u64(uint32_t crc, uint64_t v) {
#if ARROW_BITNESS == 32
return 0;
Copy link
Member

@pitrou pitrou Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect a std::abort call or equivalent here (you can also use ARROW_LOG(FATAL)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aborting with std::abort.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this introduced the following build error, so reverted the change:

[ 44%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/reader.cc.obj
[ 44%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/ipc/writer.cc.obj
[ 44%] Built target arrow_objlib
make: *** [Makefile:141: all] Error 2
C:\projects\arrow\cpp\build>goto scriptexit 

Unfortunately, this build error does not reproduce in my local environment and further information is not available in appveyor.

#else
return static_cast<uint32_t>(_mm_crc32_u64(crc, v));
#endif
}

#else // without SSE 4.2.
Expand Down