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

Try new appveyor.yml #384

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

dveeden
Copy link
Collaborator

@dveeden dveeden commented Nov 1, 2023

Closes #359

@dveeden
Copy link
Collaborator Author

dveeden commented Nov 1, 2023

Status update:

  • Appveyor Visual Studio 2022 comes with MySQL 8.0.34
  • This image has Strawberry Perl 5.32.1
  • Strawbery Perl comes with MySQL 5.7.16 client libraries (which are too old for DBD::mysql)

With a batch file that emulates mysql_config this manages to find mysql.h from MySQL 8.0. However ld.exe then fails to find things like mysql_init and mysql_real_connect. This is probably due to different compilers and compiler options being used for MySQL and Strawberry Perl.

https://dev.mysql.com/doc/c-api/8.2/en/c-api-building-clients.html#c-api-building-clients-compiling-mysql-clients-on-microsoft-windows

@dveeden
Copy link
Collaborator Author

dveeden commented Nov 1, 2023

Related: StrawberryPerl/build-extlibs#1

@dveeden dveeden marked this pull request as draft November 1, 2023 14:33
@dveeden dveeden added the CI label Sep 19, 2024
@dveeden
Copy link
Collaborator Author

dveeden commented Dec 17, 2024

I got DBD::mysql working on Windows:

Details:

  • Microsoft Windows [Version 10.0.19045.5247]
  • Win32 strawberry-perl 5.38.0.1
  • MySQL 8.0.35 for Win64 on x86_64 (Community Edition) (Installed via MySQL Installer iirc)
  • DBD::mysql 49cbce2 (5.010 with one unrelated Win32 patch)

With this mysql_config.bat:

@echo off
rem simplified replacement for the original shell script
set ROOT=c:\Program Files\MySQL\MySQL Server 8.0

set XCFLAGS="-I%ROOT%\include"
set XLIBS="-L%ROOT%\lib" -lmysql
set XVERSION=8.0.35
set XPREFIX=%ROOT%..\

for %%p in (%*) do (
  if x%%p == x--cflags     echo %XCFLAGS%
  if x%%p == x--libs       echo %XLIBS%
  if x%%p == x--version    echo %XVERSION%
  if x%%p == x--prefix     echo %XPREFIX%
) 

Configure output:

C:\Users\danie\DBD-mysql>perl Makefile.PL --mysql_config=c:\Users\danie\mysql_config.bat


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user '' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> CREATE USER ''@'localhost' IDENTIFIED BY 's3kr1t';
mysql> GRANT ALL PRIVILEGES ON test.* TO ''@'localhost';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = "-Ic:\Program Files\MySQL\MySQL Server 8.0\include"
  ldflags       (mysql_config ) =
  libs          (mysql_config ) = "-Lc:\Program Files\MySQL\MySQL Server 8.0\lib" -lmysql
  mysql_config  (Users choice ) = c:\Users\danie\mysql_config.bat
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  testdb        (User's choice) = test
  testhost      (default      ) =
  testpassword  (default      ) =
  testport      (default      ) =
  testsocket    (default      ) =
  testuser      (guessed      ) =
  version       (mysql_config ) = 8.0.35

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Looks good.

Checking if your kit is complete...
Looks good
Using DBI 1.643 (for perl 5.038000 on MSWin32-x64-multi-thread) installed in C:/Strawberry/perl/vendor/lib/auto/DBI/
Generating a gmake-style Makefile
Writing Makefile for DBD::mysql
"\x{0159}" does not map to cp850 at C:/Strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271.
"\x{0159}" does not map to cp850 at C:/Strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271.
"\x{0159}" does not map to cp850 at C:/Strawberry/perl/lib/ExtUtils/MakeMaker.pm line 1271.
Writing MYMETA.yml and MYMETA.json

Build output:

C:\Users\danie\DBD-mysql>make
cp lib/DBD/mysql/GetInfo.pm blib\lib\DBD\mysql\GetInfo.pm
cp lib/DBD/mysql/INSTALL.pod blib\lib\DBD\mysql\INSTALL.pod
cp lib/DBD/mysql.pm blib\lib\DBD\mysql.pm
Running Mkbootstrap for mysql ()
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "mysql.bs"
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- mysql.bs blib\arch\auto\DBD\mysql\mysql.bs 644
gcc -c  -IC:\Strawberry\perl\vendor\lib\auto\DBI "-Ic:\Program Files\MySQL\MySQL Server 8.0\include" -g  -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os   -DVERSION=\"5.010\" -DXS_VERSION=\"5.010\"  "-IC:\STRAWB~1\perl\lib\CORE"   dbdimp.c
"C:\Strawberry\perl\bin\perl.exe" -p -e "s/~DRIVER~/mysql/g" C:\Strawberry\perl\vendor\lib\auto\DBI\Driver.xst > mysql.xsi
"C:\Strawberry\perl\bin\perl.exe" "C:\Strawberry\perl\lib\ExtUtils/xsubpp"  -typemap C:\STRAWB~1\perl\lib\ExtUtils\typemap  mysql.xs > mysql.xsc
Warning: duplicate function definition 'do' detected in mysql.xs, line 142
Warning: duplicate function definition 'rows' detected in mysql.xs, line 550
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e mv -- mysql.xsc mysql.c
gcc -c  -IC:\Strawberry\perl\vendor\lib\auto\DBI "-Ic:\Program Files\MySQL\MySQL Server 8.0\include" -g  -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os   -DVERSION=\"5.010\" -DXS_VERSION=\"5.010\"  "-IC:\STRAWB~1\perl\lib\CORE"   mysql.c
./mysql.xsi: In function 'XS_DBD__mysql__db_selectrow_arrayref':
./mysql.xsi:234:9: warning: 'Perl_dowantarray' is deprecated [-Wdeprecated-declarations]
  234 |         if (GIMME == G_SCALAR)
      |         ^~
In file included from C:\STRAWB~1\perl\lib\CORE/perl.h:6188,
                 from C:\Strawberry\perl\vendor\lib\auto\DBI/DBIXS.h:23,
                 from dbdimp.h:21,
                 from mysql.xs:12:
C:\STRAWB~1\perl\lib\CORE/proto.h:1019:1: note: declared here
 1019 | Perl_dowantarray(pTHX)
      | ^~~~~~~~~~~~~~~~
./mysql.xsi:240:9: warning: 'Perl_dowantarray' is deprecated [-Wdeprecated-declarations]
  240 |         if (GIMME == G_SCALAR)
      |         ^~
C:\STRAWB~1\perl\lib\CORE/proto.h:1019:1: note: declared here
 1019 | Perl_dowantarray(pTHX)
      | ^~~~~~~~~~~~~~~~
gcc -c  -IC:\Strawberry\perl\vendor\lib\auto\DBI "-Ic:\Program Files\MySQL\MySQL Server 8.0\include" -g  -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os   -DVERSION=\"5.010\" -DXS_VERSION=\"5.010\"  "-IC:\STRAWB~1\perl\lib\CORE"   socket.c
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"DBD::mysql\", 'DLBASE' => 'mysql', 'DL_FUNCS' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
g++ mysql.def -o blib\arch\auto\DBD\mysql\mysql.xs.dll -shared -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib" -L"C:\STRAWB~1\c\x86_64-w64-mingw32\lib" -L"C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\13.1.0" dbdimp.o mysql.o socket.o   "C:\STRAWB~1\perl\lib\CORE\libperl538.a" "C:\STRAWB~1\c\lib\libmysql.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libmoldname.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libkernel32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libuser32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libgdi32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libwinspool.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libcomdlg32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libadvapi32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libshell32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libole32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\liboleaut32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libnetapi32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libuuid.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libws2_32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libmpr.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libwinmm.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libversion.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libodbc32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libodbccp32.a" "C:\STRAWB~1\c\x86_64-w64-mingw32\lib\libcomctl32.a" -Wl,--enable-auto-image-base
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 755 blib\arch\auto\DBD\mysql\mysql.xs.dll

C:\Users\danie\DBD-mysql>

And when running this I also don't see any obvious issues.

C:\Users\danie\DBD-mysql>perl
use DBI;

DBI->connect("DBI:mysql:database=test","root","secret");
^D
DBI connect('database=test','root',...) failed: Can't connect to MySQL server on 'localhost' (10061) at - line 3.

C:\Users\danie\DBD-mysql>

@dveeden
Copy link
Collaborator Author

dveeden commented Dec 17, 2024

Some more testing showed that this isn't fully working yet.

What I described works for MySQL 8.0 with skip-ssl in the my.ini and an account that uses mysql_native_password.

It failed for SSL/TLS connections (more or less required for caching_sha2_password).

With set DBI_TRACE=3 and the following script it reports this:

use v5.22.0;
use strict;
use warnings;
use DBI;
use Net::SSLeay;

printf("OpenSSL version num: %lX\n",  Net::SSLeay::OpenSSL_version_num());

say "connecting";
my $dbh = DBI->connect("DBI:mysql:","oldroot","oldroot");

say "SELECT 1";
$dbh->do("SELECT 1");

say "preparing SELECT VERSION() AS v";
my $sth = $dbh->prepare("SELECT VERSION() AS v") or die("failed to prepare");
$sth->execute or die("failed to execute");
while (my $ref = $sth->fetchrow_hashref()) {
	print "Version: $ref->{'v'}\n";
}
say "exiting";
C:\Users\danie\DBD-mysql>perl ..\foo.pl
    DBI 1.643-ithread default trace level set to 0x0/3 (pid 5380 pi 1ccd43f6ff0) at DBI.pm line 294 via foo.pl line 4
OpenSSL version num: 1010111F
connecting
    -> DBI->connect(DBI:mysql:, oldroot, ****)
    -> DBI->install_driver(mysql) for MSWin32 perl=5.038000 pid=5380 ruid=0 euid=0
       install_driver: DBD::mysql version 5.010 loaded from C:/Strawberry/perl/site/lib/DBD/mysql.pm
    <- install_driver= DBI::dr=HASH(0x1ccd42c96b0)
    !! The warn '0' was CLEARED by call to connect method
    -> connect for DBD::mysql::dr (DBI::dr=HASH(0x1ccd42c96b0)~0xd5f136d8 '' 'oldroot' **** HASH(0x1ccd5c8fd10)) thr#1ccd43f6ff0
imp_dbh->connect: dsn = , uid = oldroot, pwd = oldroot
imp_dbh->my_login : dbname = NULL, uid = oldroot, pwd = oldroot,host = NULL, port = NULL
imp_dbh->mysql_dr_connect: host = |NULL|, port = 0, uid = oldroot, pwd = oldroot
imp_dbh->bind_type_guessing: 0
imp_dbh->use_server_side_prepare: 0
imp_dbh->disable_fallback_for_server_prepare: 0
imp_dbh->mysql_dr_connect: client_flags = 2
imp_dbh->mysql_dr_connect: <-           --> do_error
SSL connection error: unknown error number error 2026 recorded: SSL connection error: unknown error number
                <-- do_error

C:\Users\danie\DBD-mysql>perl ..\foo.pl
    DBI 1.643-ithread default trace level set to 0x0/3 (pid 2416 pi 15b845d6ff0) at DBI.pm line 294 via foo.pl line 4
OpenSSL version num: 1010111F
connecting
    -> DBI->connect(DBI:mysql:, oldroot, ****)
    -> DBI->install_driver(mysql) for MSWin32 perl=5.038000 pid=2416 ruid=0 euid=0
       install_driver: DBD::mysql version 5.010 loaded from C:/Strawberry/perl/site/lib/DBD/mysql.pm
    <- install_driver= DBI::dr=HASH(0x15b84449580)
    !! The warn '0' was CLEARED by call to connect method
    -> connect for DBD::mysql::dr (DBI::dr=HASH(0x15b84449580)~0x860faf28 '' 'oldroot' **** HASH(0x15b85e6dd50)) thr#15b845d6ff0
imp_dbh->connect: dsn = , uid = oldroot, pwd = oldroot
imp_dbh->my_login : dbname = NULL, uid = oldroot, pwd = oldroot,host = NULL, port = NULL
imp_dbh->mysql_dr_connect: host = |NULL|, port = 0, uid = oldroot, pwd = oldroot
imp_dbh->bind_type_guessing: 0
imp_dbh->use_server_side_prepare: 0
imp_dbh->disable_fallback_for_server_prepare: 0
imp_dbh->mysql_dr_connect: client_flags = 2
imp_dbh->mysql_dr_connect: <-           --> do_error
SSL connection error: unknown error number error 2026 recorded: SSL connection error: unknown error number
                <-- do_error

C:\Users\danie\DBD-mysql>

The 1010111F means that it is OpenSSL 1.1.x which might be too old for MySQL. It is also not the OpenSSL version that libmysqlclient is compiled against.

Luckily there is a new Strawberry Perl version with a newer OpenSSL:

  • "Win32 strawberry-perl 5.40.0.1"

This brings the following:

C:\Users\danie\DBD-mysql>perl ..\foo.pl
    DBI 1.643-ithread default trace level set to 0x0/3 (pid 5716 pi 27841e79520) at DBI.pm line 294 via foo.pl line 4
OpenSSL version num: 30300000
connecting
    -> DBI->connect(DBI:mysql:, oldroot, ****)
    -> DBI->install_driver(mysql) for MSWin32 perl=5.040000 pid=5716 ruid=0 euid=0
install_driver(mysql) failed: Can't load 'C:/Strawberry/perl/site/lib/auto/DBD/mysql/mysql.xs.dll' for module DBD::mysql: load_file:The specified module could not be found at C:/Strawberry/perl/lib/DynaLoader.pm line 206.
  at (eval 8) line 3.
Compilation failed in require at (eval 8) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at ..\foo.pl line 10.
    -- DBI::END ($@: , $!: )

C:\Users\danie\DBD-mysql>

So this has OpenSSL 3.3.0, which is a good step forward, but the (recompiled) mysql.xs.ddl now won't load...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup CI job for Windows and MySQL 8.x
1 participant