akihikodaki / cld3-ruby

cld3-ruby is an interface of Compact Language Detector v3 (CLD3) for Ruby.
Apache License 2.0
77 stars 22 forks source link

3.5.2 fails to install on amazonlinux:2 #43

Closed josh-m-sharpe closed 1 year ago

josh-m-sharpe commented 1 year ago
compiling nnet_language_identifier_c.cc
nnet_language_identifier_c.cc:110:1: sorry, unimplemented: non-trivial designated initializers not supported
 };
 ^
nnet_language_identifier_c.cc:110:1: sorry, unimplemented: non-trivial designated initializers not supported
nnet_language_identifier_c.cc:110:1: sorry, unimplemented: non-trivial designated initializers not supported
make: *** [nnet_language_identifier_c.o] Error 1

make failed, exit code 2

3.5.1 also fails with the same error 3.5.0 installs and works

My C is rusty. Various googling suggests this is some kind of "using the wrong compiler issue" - but isn't that something the ruby gem should obfuscate away? Here's a SO with that error: https://stackoverflow.com/questions/31215971/non-trivial-designated-initializers-not-supported

Not sure if this is relevant, but I have this gcc:

gcc --version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
jsharpe-ctm commented 1 year ago

I managed to get gcc 10 installed, but I still get the same error:

gcc --version
gcc (GCC) 10.4.1 20221124 (Red Hat 10.4.0-1)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This SO suggests some 'extension' can be installed to support this? https://stackoverflow.com/a/48841597

josh-m-sharpe commented 1 year ago

Seems like the way these rb_data_type_t constants are defined is different in other gems:

date: https://github.com/ruby/date/blob/master/ext/date/date_core.c#L3023-L3028 puma: https://github.com/puma/puma/blob/master/ext/puma_http11/puma_http11.c#L276-L280

vs:

https://github.com/akihikodaki/cld3-ruby/blob/master/ext/cld3/nnet_language_identifier_c.cc#L103-L110

akihikodaki commented 1 year ago

This is a C++ problem. C supports designated initializers since C99 but C++ supports them only since C++20, and Amazon Linux does not have C++20. I wonder why date and puma don't use designated initializers... perhaps they are written by C++ programmer, not a C programmer like me.

Fixed with commit 7ea683cd9a716d7218ba268a23386095a00b453e and released as version 3.5.3: https://github.com/akihikodaki/cld3-ruby/releases/tag/v3.5.3

josh-m-sharpe commented 1 year ago

Awesome - thank you!