Opened 3 years ago

Closed 3 months ago

#62086 closed defect (fixed)

p5.28-dbd-mysql +mysql8: Error: Failed to configure p5.28-dbd-mysql: configure failure: command execution failed

Reported by: jhoyt4 Owned by: jhoyt4
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: jhoyt4, ctreleaven (Craig Treleaven)
Port: p5-dbd-mysql

Description

I am unable to install the mysql8 variant of p5.28-dbd-mysql - here is the output error

--->  Configuring p5.28-dbd-mysql
Executing:  cd "/opt/local/var/macports/build/_opt_mports_macports-ports_perl_p5-dbd-mysql/p5.28-dbd-mysql/work/DBD-mysql-4.050" && /opt/local/bin/perl5.28 Makefile.PL INSTALLDIRS=vendor CC="/usr/bin/clang" LD="/usr/bin/clang" --mysql_config=/opt/local/lib/mysql8/bin/mysql_config 


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'root' 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> grant all privileges on test.* to 'root'@'localhost' identified by 's3kr1t';

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) = -I/opt/local/include/mysql8/mysql
  embedded      (guessed     ) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/opt/local/lib/mysql8/mysql -lmysqlclient
  mysql_config  (Users choice) = /opt/local/lib/mysql8/bin/mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = root

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

Checking if libs are available for compiling...
Can't link/include C library 'mysqlclient', aborting.
Command failed:  cd "/opt/local/var/macports/build/_opt_mports_macports-ports_perl_p5-dbd-mysql/p5.28-dbd-mysql/work/DBD-mysql-4.050" && /opt/local/bin/perl5.28 Makefile.PL INSTALLDIRS=vendor CC="/usr/bin/clang" LD="/usr/bin/clang" --mysql_config=/opt/local/lib/mysql8/bin/mysql_config 
Exit code: 2
Error: Failed to configure p5.28-dbd-mysql: configure failure: command execution failed
Error: See /opt/local/var/macports/logs/_opt_mports_macports-ports_perl_p5-dbd-mysql/p5.28-dbd-mysql/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port p5.28-dbd-mysql failed
% ls /opt/local/lib/mysql8/mysql 
libcrypto.1.1.dylib           libmysqlclient.a              libprotobuf-lite.3.11.4.dylib libprotobuf.dylib
libcrypto.dylib               libmysqlclient.dylib          libprotobuf-lite.dylib        libssl.1.1.dylib
libmysqlclient.21.dylib       libmysqlservices.a            libprotobuf.3.11.4.dylib      libssl.dylib

Attachments (1)

main.log (42.2 KB) - added by jhoyt4 3 years ago.
main.log - macOS 11.1

Download all attachments as: .zip

Change History (16)

comment:1 Changed 3 years ago by jhoyt4

Cc: jhoyt4 added

comment:2 Changed 3 years ago by jhoyt4

I also received a similar error trying to build with mariadb-10.5.

Swapped to p5.28-dbd-mariadb for mariadb-10.5 and everything worked.

...still need the mysql8 variant working :)

comment:3 Changed 3 years ago by mf2k (Frank Schima)

Port: p5-dbd-mysql added; p5.28-dbd-mysql removed

comment:4 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Please attach the main.log file.

It works for me on High Sierra.

Changed 3 years ago by jhoyt4

Attachment: main.log added

main.log - macOS 11.1

comment:5 Changed 3 years ago by jhoyt4

Attached. Failing on:

:debug:sysinfo macOS 11.1 (darwin/20.2.0) arch i386 :debug:sysinfo MacPorts 2.6.4 :debug:sysinfo Xcode 12.3 :debug:sysinfo SDK 11.1 :debug:sysinfo MACOSX_DEPLOYMENT_TARGET: 11.1

Version 0, edited 3 years ago by jhoyt4 (next)

comment:6 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

I wish perl wrote something like a config.log that would tell us why it Can't link/include C library 'mysqlclient' but I don't think perl does that.

We know that perl remembers the compiler and the flags that were used to configure perl and uses that compiler and those flags again when building modules, unless told otherwise. The MacPorts perl5 portgroup does tell it otherwise, telling it to use the currently-chosen compiler and flags, which may be different from the compiler or flags that were chosen when perl5.x was built. Specifically, perl5.28 was built on our server with the macOS 11.0 SDK, so the -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk flag was used and recorded. There are some modules that ignore what we tell them and try to build using the old perl-remembered compiler and flags. Maybe p5-dbd-myql is one of those. If so, and if you got a binary of perl5.28 from our server rather than building it from source, then it might by trying to build p5-dbd-mysql using the 11.0 SDK, which exists on our build system but does not exist on your system.

To test this theory, you could try rebuilding perl5.28 from source on your system using sudo port -ns upgrade --force perl5.28. It will then record the fact that it was built with the 11.1 SDK. After that, sudo port clean p5.28-dbd-mysql and sudo port install p5.28-dbd-mysql +mysql8 again. If that works, great, we can investigate why p5-dbd-mysql is ignoring the flags we're sending it.

comment:7 Changed 3 years ago by jhoyt4

That got it compiling. Thank you!

Happy to help troubleshoot why it's ignoring the flags where I can.

Last edited 3 years ago by jhoyt4 (previous) (diff)

comment:8 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

The relevant code in p5-dbd-mysql's Makefile.PL is:

print "Checking if libs are available for compiling...\n";

assert_lib(
  LIBS => ($opt->{'embedded'} ? $opt->{'embedded'} : $opt->{libs}),
);

print "Looks good.\n\n";

assert_lib is a function from p5-dbd-mysql's dependency p5-devel-checklib. It's documented here and its source code is here. It looks like it accepts additional ccflags and ldflags being passed to it, but p5-dbd-mysql isn't doing so. Looking at assert_lib's source, I see that it adds any ccflags supplied in the function invocation to $Config{ccflags}, which are the ccflags that perl was built with. I don't see anywhere that assert_lib attempts to add the contents of the CFLAGS environment variable, which is what would fix this. I don't know if assert_lib should be fixed to do this (and presumably the same for the LDFLAGS environment variable) or whether such code belongs everywhere that assert_lib is invoked. (There's only one invocation in p5-dbd-mysql but there are a dozen ports in MacPorts that depend on p5-devel-checklib that might be using it.)

comment:9 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Here's a relevant upstream bug report on the perils of using perl's ccflags/ldflags, filed in 2012. Here's an even more relevant upstream bug report requesting that flags from the environment be honored, filed in 2020.

comment:10 Changed 3 years ago by jhoyt4

Looking at p5-dbd-mariadb for reference as to why it works, they have this for assert_lib call

print "Checking if libs and header files are available for compiling...\n";

assert_lib(
  LIBS => (join ' ', @libdirs, $main_lib, @libs),
  ccflags => (join ' ', $opt->{cflags}, ($Config{usedl} ? $Config{cccdlflags} : ())),
  ldflags => (join ' ', @libdirs, @ldflags, ($Config{usedl} ? $Config{lddlflags} : ())),
  header => \@mysql_headers,
  not_execute => 1,
);

print "Checking if correct version of MariaDB or MySQL client is present...\n";

check_lib(
  LIBS => (join ' ', @libdirs, $main_lib),
  ccflags => $opt->{cflags},
  ldflags => (join ' ', @libdirs, @libs, @ldflags),
  header => \@mysql_headers,
  function => "\n#ifndef MYSQL_VERSION_ID\n#include <mysql_version.h>\n#endif\nreturn (MYSQL_VERSION_ID >= 40108) ? 0 : 1;\n",
) or die <<"MSG";

ERROR: Wrong version or unable to check version of MariaDB/MySQL include files.
To build DBD::MariaDB it is needed MariaDB or MySQL client >= 4.1.8.

MSG

print "Looks good.\n\n";

I'm wondering if this would be patched in potentially fixing the issue?

Also - an alternative solution would be to update the p5-dbd-mariadb Portfile to include mysql variants since the code claims to work with mysql

comment:11 Changed 3 years ago by jhoyt4

I've created a fork and branch on github to try to resolve the issue with a patch: https://github.com/jhoyt4/macports-ports/tree/p5-dbd-mysql

This successfully compiles currently, but I was unfortunately unable to fully test as installing perl5.28 from source has now made the initial issue disappear even after doing an uninstall/clean/install from packages.

comment:12 Changed 3 years ago by ctreleaven (Craig Treleaven)

Cc: ctreleaven added

comment:13 Changed 3 years ago by jhoyt4

I was able to recreate the bug on a different machine. Unfortunately the patch did not work (caused additional config issues). Back to the drawing board...

comment:14 Changed 3 years ago by jhoyt4

After failing to graft the p5-dbd-mariadb Makefile.pl onto p5-dbd-mysql, I decided to see if I could add a mysql8 variant of p5-dbd-mariadb to work.

I was much more successful there and will be pushing that update shortly from here: https://github.com/jhoyt4/macports-ports/tree/p5-dbd-mariadb

Unfortunately, this doesn't solve the base issue of p5-dbd-mysql not compiling on all configurations...

Last edited 3 years ago by jhoyt4 (previous) (diff)

comment:15 Changed 3 months ago by jhoyt4

Owner: set to jhoyt4
Resolution: fixed
Status: newclosed

In d32f8c769065cf2e7157aa599469d537a89eb232/macports-ports (master):

p5-dbd-mysql: upgrade version, remove EOL variants, add mysql82

  • Upgrade to version 5.003
  • Remove end of life mariaDB variants
  • Remove unsupported mysql variants
  • Update defaults to mysql8 for supported OSs, mariadB 10-6 (LTS) for older OSes
  • Add additional mysql82 variant

Closes: #62086

Note: See TracTickets for help on using tickets.