tonytonyjan / jaro_winkler

Ruby & C implementation of Jaro-Winkler distance algorithm which supports UTF-8 string.
MIT License
195 stars 29 forks source link

Windows mswin build - failing #41

Open MSP-Greg opened 4 years ago

MSP-Greg commented 4 years ago

Although most people using Ruby on Windows use MSYS2/MinGW builds, ruby/ruby has been testing on mswin (msvc) builds for quite a while. The build does pass all tests, so all the extension stdlib/default gems included with Ruby compile.

While trying to compile Puma with it, Puma uses RuboCop in CI, and it wouldn't compile jaro_winkler when running bundle install. Below is the log. I ran this locally, so happy to test anything. Using VS 2019. FYI, Puma compiled on mswin with OpenSSL.

mkdir -p tmp/x64-mswin64_140/jaro_winkler_ext/2.8.0
cd tmp/x64-mswin64_140/jaro_winkler_ext/2.8.0
C:/Greg/Ruby99-x64m/bin/ruby.exe -I. ../../../../ext/jaro_winkler/extconf.rb
creating Makefile
cd -
cd tmp/x64-mswin64_140/jaro_winkler_ext/2.8.0
nmake

Microsoft (R) Program Maintenance Utility Version 14.24.28314.0
Copyright (C) Microsoft Corporation.  All rights reserved.

generating jaro_winkler_ext-x64-mswin64_140.def
compiling ../../../../ext/jaro_winkler/adj_matrix.c
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
adj_matrix.c
compiling ../../../../ext/jaro_winkler/codepoints.c
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
codepoints.c
compiling ../../../../ext/jaro_winkler/jaro.c
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
jaro.c
../../../../ext/jaro_winkler/jaro.c(30): error C2146: syntax error: missing ';' before identifier 'SWAP'
../../../../ext/jaro_winkler/jaro.c(30): error C2065: 'SWAP': undeclared identifier
../../../../ext/jaro_winkler/jaro.c(30): error C4047: '=': 'int' differs in levels of indirection from 'uint32_t *'
../../../../ext/jaro_winkler/jaro.c(30): error C4047: '=': 'uint32_t *' differs in levels of indirection from 'int'
../../../../ext/jaro_winkler/jaro.c(31): error C2146: syntax error: missing ';' before identifier 'SWAP'
../../../../ext/jaro_winkler/jaro.c(31): error C2065: 'SWAP': undeclared identifier
../../../../ext/jaro_winkler/jaro.c(45): error C2057: expected constant expression
../../../../ext/jaro_winkler/jaro.c(45): error C2466: cannot allocate an array of constant size 0
../../../../ext/jaro_winkler/jaro.c(45): error C2133: 'short_codes_flag': unknown size
../../../../ext/jaro_winkler/jaro.c(46): error C2057: expected constant expression
../../../../ext/jaro_winkler/jaro.c(46): error C2466: cannot allocate an array of constant size 0
../../../../ext/jaro_winkler/jaro.c(46): error C2133: 'long_codes_flag': unknown size
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
rake aborted!
Command failed with status (2): [nmake...]

Note: Puma has been running CI against Ruby Windows MSYS2/MinGW builds for quite while with no problem (compiling jaro_winkler or Puma). MSYS2 is using gcc 9.2.0.

MSP-Greg commented 4 years ago

I didn't mention that I'm not really a c type, so I'm not comfortable trying to fix this on the c side.

I could submit a PR forcing mswin platform to run in 'pure ruby' mode?

jmarrec commented 4 years ago

I implemented a fix in #43 (and found this issue afterwards)