Opened 7 years ago

Closed 6 years ago

#54220 closed defect (worksforme)

texinfo @6.3.0 +universal: build fails for non-native architecture when binary perl modules are not installed as universal

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mojca (Mojca Miklavec), dbevans (David B. Evans)
Port: texinfo perl5.24 p5-encode

Description

I will start this by admitting I don't know a lot about perl, or the perl library search paths. I'm not sure if this is a problem with texinfo, or more likely a problem with the perl5.24 +universal installation. I defer to the gurus here.

I am trying to install some software +universal, and it calls in a +universal build of texinfo, which fails:

$ sudo port -v upgrade --enforce-variants gnutls +universal
--->  Computing dependencies for texinfo.
--->  Configuring texinfo
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_texinfo/texinfo/work/texinfo-6.3" && ./configure --prefix=/opt/local --disable-dependency-tracking 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '503' is supported by ustar format... yes
checking whether GID '500' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking for perl... /opt/local/bin/perl5.24
checking Perl version and Encode module... no
configure: error: perl >= 5.7.3 with Encode required by Texinfo.
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_texinfo/texinfo/work/texinfo-6.3" && ./configure --prefix=/opt/local --disable-dependency-tracking 
Exit code: 1
Error: Failed to configure texinfo, consult /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_texinfo/texinfo/work/texinfo-6.3/config.log
Error: Failed to configure texinfo: configure failure: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_texinfo/texinfo/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.

during the configure phase for texinfo, it calls this test, which fails:

$ /opt/local/bin/perl5.24 -e "use 5.007_003; use Encode;"
Can't load '/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle' for module Encode: dlopen(/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle, 1): no suitable image found.  Did find:
	/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: mach-o, but wrong architecture at /opt/local/lib/perl5/5.24/XSLoader.pm line 99.
 at /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/Encode.pm line 10.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

There are a couple of versions of the Encode.bundle installed. The vendor_perl one is ppc only (even though perl5.24 is installed as +universal):

$ file /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: Mach-O bundle ppc

This other one is a fat binary, though:

$ file /opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: Mach-O universal binary with 4 architectures
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture i386):	Mach-O bundle i386
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture ppc7400):	Mach-O bundle ppc
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture ppc64):	Mach-O 64-bit bundle ppc64

The default perl search path is like this, and finds the wrong (non-universal) version of Encode.bundle first:

  @INC:
    /opt/local/lib/perl5/site_perl/5.24/darwin-thread-multi-2level
    /opt/local/lib/perl5/site_perl/5.24
    /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level
    /opt/local/lib/perl5/vendor_perl/5.24
    /opt/local/lib/perl5/5.24/darwin-thread-multi-2level
    /opt/local/lib/perl5/5.24

So running the configure test like this works:

$ export PERL5LIB=/opt/local/lib/perl5/5.24/darwin-thread-multi-2level
$ /opt/local/bin/perl5.24 -e "use 5.007_003; use Encode;"

And that leads to what I found to be a fix for installing texinfo as +universal. Adding these two lines to the texinfo Portile:

configure.env-append  PERL5LIB=/opt/local/lib/perl5/5.24/darwin-thread-multi-2level
build.env-append     PERL5LIB=/opt/local/lib/perl5/5.24/darwin-thread-multi-2level

and texinfo installs correctly as +universal in the end:

$ port -v installed texinfo
The following ports are currently installed:
  texinfo @6.3_0 platform='darwin 9' archs='ppc' date='2016-10-02T18:25:22-0700'
  texinfo @6.3_0+universal (active) platform='darwin 9' archs='i386 ppc ppc64 x86_64' date='2017-05-23T17:46:15-0700'

Change History (8)

comment:1 Changed 7 years ago by mojca (Mojca Miklavec)

Cc: dbevans added

comment:2 Changed 7 years ago by mojca (Mojca Miklavec)

I see a couple problems here.

  • The first one is that if you are building perl as universal, it should probably install all files universal. I need some time to figure out what exactly goes wrong and why the Encode.bundle is not universal. Is perl indeed universal? (I guess it is, just double-checking.)
  • The fat Encode.bundle comes from p5.24-encode, the other one comes from perl5.24. I don't know which one should have the priority. I would probably need to ask the Perl developers.
  • Personally I see no reason why universal build of any port (including gnutls) would ask for universal build of texinfo. From what I understand texinfo is only ever needed to build the documentation and I see no benefit of having universal texinfo. Likely you don't need universal autotools to build a project universally. I would list texinfo under depends_skip_archcheck of the port in question.

Just curious. If I see it correctly, you are building i386/x86_64/ppc/ppc64 on 10.5/ppc. How exactly do you use that?

comment:3 Changed 7 years ago by mojca (Mojca Miklavec)

OK, sorry, I mixed things up.

This fat binary:

$ file /opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: Mach-O universal binary with 4 architectures
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture i386):	Mach-O bundle i386
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture ppc7400):	Mach-O bundle ppc
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle (for architecture ppc64):	Mach-O 64-bit bundle ppc64

belongs to perl5.24:

$ port provides /opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle is provided by: perl5.24

While this binary:

$ file /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: Mach-O bundle ppc

belongs to p5.24-encode:

$ port provides /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle
/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle is provided by: p5.24-encode

Apparently your p5.24-encode was not installed as universal.

I don't believe that this port should be listed as dependency since it should be sufficient to use the one that's built-in, but one of the other packages must have asked for it and it did not install as universal then. In fact I'm not even sure why we have it in the first place. Maybe it was needed to support older versions of perl, but that's moot now.

I'm still confused why perl would not find the encode module. Did you in fact run perl in i386 mode?

So as a summary:

  • Perhaps we should just delete the p5-encode module?
  • I still think that texinfo should not be installed as universal even if some universal port needs it as dependency and that should be fixed in that port.

comment:4 Changed 7 years ago by mojca (Mojca Miklavec)

Were you cross-compiling on 10.5/i386 for ppc?

The only way I could trigger the error myself is by running:

> arch -arch i386 /opt/local/bin/perl5.24 -e "use 5.007_003; use Encode;"
Can't load '/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle' for module Encode: dlopen(/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle, 1): no suitable image found.  Did find:
	/opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/auto/Encode/Encode.bundle: mach-o, but wrong architecture at /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/XSLoader.pm line 99.
 at /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level/Encode.pm line 10.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

So I assume that you configured your MacPorts to only build for ppc by default on an i386 machine. And then the i386 version of perl was started once you had universal perl build. There's no way we could possibly properly support such scenarios to the latest details.

That's just guessing. Please be more verbose about what you are doing next time.

I was sure that part of the perl build was broken, but I get that module built universally as expected.

Last edited 7 years ago by mojca (Mojca Miklavec) (previous) (diff)

comment:5 Changed 7 years ago by mojca (Mojca Miklavec)

Port: p5-encode added
Summary: texinfo @6.3.0 +universal build fails due to perl5.24 library search pathtexinfo @6.3.0 +universal: build fails for non-native architecture when binary perl modules are not installed as universal

comment:6 Changed 7 years ago by mf2k (Frank Schima)

Port: texinfo, perl5.24, p5-encodetexinfo perl5.24 p5-encode

comment:7 Changed 7 years ago by kencu (Ken)

Mojca, I think you've hit directly on the issue. I didn't realize the non-universal Encode module came from a separate port.

Once perl was upgraded +universal with a ppc64 slice, MacOSX will preferentially run ppc64 on the DualG5 if it is available, so all perl modules need to have the ppc64 architecture available. You can get the same error if perl is installed i386/x86_64 but p5.24-encode is installed as i386.

I can fix the error by rebuilding p5-encode +universal, or by deactivating p5-encode completely. Thanks for the pointer -- I'll check my other p5.24* modules to ensure they are built with the correct architectures as well.

Your question as to why the p5-encode port exists at all is a good one, as it seems perl5.24 has a perfectly good version already.

You are correct that there should be no arch check for texinfo -- I can't figure out which port is actually asking for it, though, to add that into the Portfile. It's not gnutls asking for it.

Your title change to the 'non-native architecture' is not quite correct. This can happen on any machine, if there is the correct perl / p5.24-encode architecture mismatch.

Background: This is all on a DualG5 PPC machine. Ultimately I'm trying to build some software as ppc64 on the DualG5 that won't build as ppc. I'm building super-fat binaries with all architectures so I can move them over to a Leopard i386/x86_64 machine if needed.

comment:8 Changed 6 years ago by kencu (Ken)

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.