PerlAlien / Alien-Libxml2

Install the C libxml2 library on your system
4 stars 3 forks source link

Another macOS challenge #13

Closed kiwiroy closed 5 years ago

kiwiroy commented 5 years ago

I have a test fail in t/alien_libxml2.t with cpanm Alien::Libxml2

# perl                                     5.030000
# Alien::Base                              1.79
# Alien::Build                             1.79
# Alien::Build::MM                         1.79
# Alien::Build::Plugin::Build::SearchDep   1.79
# Alien::Build::Plugin::Prefer::BadVersion 1.79
# ExtUtils::CBuilder                       0.280231
# ExtUtils::MakeMaker                      7.34
# Test2::V0                                0.000122
# Test::Alien                              1.79
#
# version        = 2.9.9
# cflags         = -I/Volumes/300GB/opt/local/include/libxml2
# cflags_static  = -I/Volumes/300GB/opt/local/include/libxml2
# libs           = -L/Volumes/300GB/opt/local/lib -lxml2
# libs_static    = -L/Volumes/300GB/opt/local/lib -lxml2 -licui18n -licuuc -licudata -lpthread -lz -llzma -liconv -lm
# 
# 
# 
t/00_diag.t ........ ok

# Failed test 'xs'
# at t/alien_libxml2.t line 10.
#   ExtUtils::CBuilder->compile failed
#     error building testalienQGIuR/test.o from 'testalienQGIuR/test.c' at /Volumes/300GB/perlbrew/perls/perl-5.30.0/lib/5.30.0/ExtUtils/CBuilder/Base.pm line 185.
#     cc -I/Volumes/300GB/perlbrew/perls/perl-5.30.0/lib/5.30.0/darwin-2level/CORE -I/Volumes/300GB/opt/local/include/libxml2 -c -fno-common -DPERL_DARWIN -mmacosx-version-min=10.13 -fno-strict-aliasing -pipe -fstack-pro
#     In file included from testalienQGIuR/test.xs:5:
#     In file included from /Volumes/300GB/opt/local/include/libxml2/libxml/parser.h:810:
#     In file included from /Volumes/300GB/opt/local/include/libxml2/libxml/encoding.h:31:
#     /Volumes/300GB/opt/local/include/unicode/ucnv.h:52:10: fatal error: 'unicode/ucnv_err.h' file not found
#     #include "unicode/ucnv_err.h"
#              ^~~~~~~~~~~~~~~~~~~~
#     1 error generated.
t/alien_libxml2.t .. 

I'm a macports user.

$ which pkg-config
/Volumes/300GB/opt/local/bin/pkg-config
$ pkg-config libxml-2.0 --cflags
-I/Volumes/300GB/opt/local/include/libxml2
$ pkg-config libxml-2.0 --static
$ pkg-config libxml-2.0 --modversion
2.9.9
$ port list icu
icu                            @58.2           devel/icu
$ ls -l /Volumes/300GB/opt/local/include/unicode/ucnv*
-rw-r--r--  1 root  wheel  85066  5 Jul 16:04 /Volumes/300GB/opt/local/include/unicode/ucnv.h
-rw-r--r--  1 root  wheel   6759  5 Jul 16:04 /Volumes/300GB/opt/local/include/unicode/ucnv_cb.h
-rw-r--r--  1 root  wheel  21499  5 Jul 16:04 /Volumes/300GB/opt/local/include/unicode/ucnv_err.h
-rw-r--r--  1 root  wheel   6294  5 Jul 16:04 /Volumes/300GB/opt/local/include/unicode/ucnvsel.h

icu 58.2 is a little old, but latest is essentially the same

plicease commented 5 years ago

I'm curious how it found /Volumes/300GB/opt/local/include/unicode/ucnv.h since that isn't explicitly included. I wonder if (and this would be weird) maybe there is an include of ucnv.h with an absolute path somewhere? That would explain the failure, although it would surprise me.

can you verify if this C program works or not:

#include <libxml/parser.h>
#include <libxml/tree.h>

int
main(int argc, char *argv[])
{
  xmlDoc *doc = NULL;
  xmlNode *root_element = NULL;
  const char *filename = "corpus/basic.xml";
  doc = xmlReadFile(filename, NULL, 0);
  if(doc == NULL)
  {
    printf("error reading %s\n", filename);
    return  2;
  }
  else
  {
    xmlFreeDoc(doc);
    xmlCleanupParser();
    printf("ok\n");
    return 0;
  }
}

With this incantation (run from the Alien-Libxml2 root):

$ cc `pkg-config --cflags libxml-2.0` test.c `pkg-config --libs libxml-2.0` && ./a.out
ok
kiwiroy commented 5 years ago

See https://gist.github.com/kiwiroy/ff5c0e2b54b2f316924066a673eaae9a and macports/macports-ports@dcef2c3 I'm not sure what it is sane for Alien::Libxml2 to do.

plicease commented 5 years ago

... that is crazy. Honestly this is a macports issue and should be fixed there.

If we can from the alienfile

  1. detect the bug (not just the fact that we are running under macports, but the bug itself)
  2. add the appropriate include path for just the aflicted configuration,
  3. include an appropriate comment with ticket numbers etc.
  4. not break anything that is currently working

it's not trivial to do correctly, and it's probably best to push back and see if they can fix it properly first.

kiwiroy commented 5 years ago

I have to assume @ryandesign is guarding against more recent versions of ICU being installed elsewhere. I’ve commented to link discussions.

genio commented 5 years ago

https://trac.macports.org/ticket/58350

kiwiroy commented 5 years ago

fixed in macports.