Alien-Build icon indicating copy to clipboard operation
Alien-Build copied to clipboard

MSWin32: pkg-config issues with C:/path and unix sep char

Open shawnlaffan opened this issue 6 years ago • 4 comments

This might be better reported against a plugin.

I'm getting failures in compiling a shared version of Alien::proj, which in turn depends on Alien::sqlite. This is on windows.

The Alien::proj alienfile calls the Build::SearchDep plugin to load Alien::sqlite, but later the configure call in the build process cannot find the sqlite3.pc file. The error report suggests that C:/berrybrew/ has been converted to C /berrybrew/, so something in the stack is not escaping the colon before it gets to MSYS. Or the configure script is not honouring MSYS handling of windows paths.

Sample code:

plugin 'Build::SearchDep' => (
  aliens   => ['Alien::sqlite'],
  public_I => 1,
  public_l => 1,
);

Relevant alienfile is at https://github.com/shawnlaffan/perl-alien-proj/blob/f78b8f22b49e7c0361cfa5eacd355aa52aa504f8/alienfile

Sample fail report is at https://ci.appveyor.com/project/shawnlaffan/perl-alien-proj/builds/27221239

If I set $ENV{PKG_CONFIG_PATH} to use a valid MSYS path then the reported configure error is the same, but there is a semicolon in the list of paths, e.g. /C/berrybrew/restofpath;C /berrybrew/restofpath /usr/lib/pkgconfig /usr/share/pkgconfig. This suggests that the handling code is using a windows separator to merge them, which is perhaps a clue as to where it is coming from.

shawnlaffan avatar Sep 06 '19 04:09 shawnlaffan

Interesting. We do some work to get --prefix to work with autoconf (which "helpfully" requires msys paths) and with Strawberry (which requires windows paths):

https://metacpan.org/source/PLICEASE/Alien-Build-1.85/lib/Alien/Build/Plugin/Build/Autoconf.pm#L48-53

But haven't ever extended that to PKG_CONFIG_PATH. Also PkgConfig.pm may have a role here to. Do you know which version of pkg-config is first in PATH? Both MSYS and Strawberry have their own versions. I suspect autoconf will not work with the one that comes bundled with Strawberry.

Interop between MSYS and Strawberry is a bit thorny and as a result has not been tested that much.

plicease avatar Sep 06 '19 11:09 plicease

The autoconf approach should work. Hopefully you'll have a better idea of where to add it.

I'm not sure which pkg-config is being used. My attempts to probe for it in the alien build process produced only errors.

The shell under Alien::MSYS has no pkg-config utility, but running where in the cmd shell returns:

>where ppkg-config
C:\berrybrew\5.28.0_64_PDL\perl\site\bin\ppkg-config
C:\berrybrew\5.28.0_64_PDL\perl\site\bin\ppkg-config.bat

>where pkg-config
C:\berrybrew\5.28.0_64_PDL\perl\site\bin\pkg-config
C:\berrybrew\5.28.0_64_PDL\perl\site\bin\pkg-config.bat
C:\berrybrew\5.28.0_64_PDL\perl\bin\pkg-config
C:\berrybrew\5.28.0_64_PDL\perl\bin\pkg-config.bat

shawnlaffan avatar Sep 06 '19 12:09 shawnlaffan

Could be in the block at https://metacpan.org/source/PLICEASE/Alien-Build-1.85/lib/Alien/Build/Plugin/Build/Autoconf.pm#L117

shawnlaffan avatar Sep 06 '19 12:09 shawnlaffan

I've not been able to find the best location to update the Alien system, but I do have a workaround in the alienfile.

A more generic approach would modify the PKG_CONFIG_PATH only if it was being passed down to an MSYS shell.

#  only the relevant parts of the alienfile are shown  

my $on_windows = $^O =~ /mswin/i;

share {
  ...
  build [
    \&update_pkg_conf_path,
    'echo PKG_CONFIG_PATH: %PKG_CONFIG_PATH%',
    "%{configure} $with_local $with_cpp11 $build_static",
    $make_cmd,
    $make_inst_cmd,
  ];
};

sub update_pkg_conf_path {
    return if !$on_windows; 
    use Env qw /@PKG_CONFIG_PATH/;
    @PKG_CONFIG_PATH = map {s{^([a-z]):}{/$1}ri} @PKG_CONFIG_PATH;
    return;
}

shawnlaffan avatar Sep 08 '19 01:09 shawnlaffan