ruby-odbc
ruby-odbc copied to clipboard
Fail to compile utf-8 version with GCC version 14 with version 0.999992
Gem version: 0.999992 GCC version: 14+
I have also tried manually compiling according to README file and the result was the same
gem_make.out
current directory: /home/bimbal/.local/share/mise/installs/ruby/2.7.4/lib/ruby/gems/2.7.0/gems/ruby-odbc-0.999992/ext/utf8
/home/bimbal/.local/share/mise/installs/ruby/2.7.4/bin/ruby -I /home/bimbal/.local/share/mise/installs/ruby/2.7.4/lib/ruby/2.7.0 -r ./siteconf20241003-290100-sj65ul.rb extconf.rb
checking for version.h... no
checking for ruby/version.h... yes
checking for sql.h... yes
checking for sqlext.h... yes
checking for SQLTCHAR in sqltypes.h... yes
checking for SQLLEN in sqltypes.h... yes
checking for SQLULEN in sqltypes.h... yes
checking for odbcinst.h... yes
checking for SQLAllocConnect() in -lodbc... yes
checking for SQLConfigDataSource() in -lodbcinst... yes
checking for SQLConfigDataSourceW() in odbcinst.h... yes
checking for SQLWriteFileDSNW() in odbcinst.h... yes
checking for SQLReadFileDSNW() in odbcinst.h... yes
checking for SQLInstallerError() in odbcinst.h... yes
checking for SQLInstallerErrorW() in odbcinst.h... yes
creating Makefile
current directory: /home/bimbal/.local/share/mise/installs/ruby/2.7.4/lib/ruby/gems/2.7.0/gems/ruby-odbc-0.999992/ext/utf8
make "DESTDIR=" clean
current directory: /home/bimbal/.local/share/mise/installs/ruby/2.7.4/lib/ruby/gems/2.7.0/gems/ruby-odbc-0.999992/ext/utf8
make "DESTDIR="
compiling init.c
compiling odbc.c
In file included from odbc.c:17:
../odbc.c:94:9: warning: "RB_OBJ_TAINT" redefined
94 | #define RB_OBJ_TAINT(o) o
| ^~~~~~~~~~~~
In file included from /home/bimbal/.local/share/mise/installs/ruby/2.7.4/include/ruby-2.7.0/ruby.h:33,
from ../odbc.c:21:
/home/bimbal/.local/share/mise/installs/ruby/2.7.4/include/ruby-2.7.0/ruby/ruby.h:1333:9: note: this is the location of the previous definition
1333 | #define RB_OBJ_TAINT(x) (RB_OBJ_TAINTABLE(x) ? RB_OBJ_TAINT_RAW(x) : (void)0)
| ^~~~~~~~~~~~
../odbc.c: In function ‘dbc_getinfo’:
../odbc.c:4075:17: error: passing argument 1 of ‘sprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
4075 | sprintf(buffer, "Unknown info type %d for ODBC::Connection.get_info",
| ^~~~~~
| |
| SQLWCHAR * {aka short unsigned int *}
In file included from /home/bimbal/.local/share/mise/installs/ruby/2.7.4/include/ruby-2.7.0/ruby/defines.h:126,
from /home/bimbal/.local/share/mise/installs/ruby/2.7.4/include/ruby-2.7.0/ruby/ruby.h:29:
/usr/include/stdio.h:365:38: note: expected ‘char * restrict’ but argument is of type ‘SQLWCHAR *’ {aka ‘short unsigned int *’}
365 | extern int sprintf (char *__restrict __s,
| ~~~~~~~~~~~~~~~~~^~~
../odbc.c:4077:17: error: passing argument 1 of ‘set_err’ from incompatible pointer type [-Wincompatible-pointer-types]
4077 | set_err(buffer, 1);
| ^~~~~~
| |
| SQLWCHAR * {aka short unsigned int *}
../odbc.c:1891:21: note: expected ‘const char *’ but argument is of type ‘SQLWCHAR *’ {aka ‘short unsigned int *’}
1891 | set_err(const char *msg, int warn)
| ~~~~~~~~~~~~^~~
make: *** [Makefile:245: odbc.o] Error 1
make failed, exit code 2
@larskanis Hello, is this something you understand and have knowledge and time to fix, please?
Here's a possible fix for ruby-odbc-0.999992:
--- odbc.c.orig Mon Sep 4 11:50:32 2023
+++ odbc.c Thu Aug 21 11:38:40 2025
@@ -4072,9 +4072,9 @@
0));
return Qnil;
case 1:
- sprintf(buffer, "Unknown info type %d for ODBC::Connection.get_info",
- info);
- set_err(buffer, 1);
+ sprintf((char *) buffer,
+ "Unknown info type %d for ODBC::Connection.get_info", info);
+ set_err((char *) buffer, 1);
break;
}
if (vtype != Qnil) {
According to ChatGPT it's also possible to ignore it:
(Not recommended) add -Wno-incompatible-pointer-types to CFLAGS. That hides the error but keeps UB risk.
I've added:
bundle config build.ruby-odbc --with-cflags="-Wno-incompatible-pointer-types"
bundle install
And I was able to bundle install all gems. I'll see how this runs after deployment