3

On my OSX machine, deep within a jungle of lib directories, I was able to see this

-r-xr-xr-x 1 user users 45700 Feb 01 1:47 LibXSLT.bundle*

1) What are these .bundle files ?

2) Who creates them ? CPAN modules ?

3) If so, then can we control its generation via some Makefile artifact ?

Recker
  • 1,915
  • 25
  • 55
  • 2
    http://superuser.com/questions/67249/what-is-a-bundle-file-and-how-do-i-run-it - doesn't seem to be Perl specific. – melpomene Feb 21 '17 at 10:58
  • 1
    I am specifically looking for .bundle files related to Perl CPAN. – Recker Feb 21 '17 at 11:45
  • These file may be related to this module: [XML::LibXSLT](http://search.cpan.org/~shlomif/XML-LibXSLT-1.94/LibXSLT.pm) – AbhiNickz Feb 21 '17 at 12:23
  • 1
    Yes it gets install during installation of above module. Discussion on [Perlmonk](http://www.perlmonks.org/bare/?node_id=528106). – AbhiNickz Feb 21 '17 at 12:24
  • @AbhiNickz That discussion is about module tests crashing, not .bundle files. – melpomene Feb 21 '17 at 12:48
  • @melpomene Yes, Correct but as OP has asked **Who creates them ? CPAN modules ?** that's why I gave that link. – AbhiNickz Feb 21 '17 at 12:49
  • OK, the relevant command is `LD_RUN_PATH="/sw/lib:/usr/lib" MACOSX_DEPLOYMENT_TARGET=10.3 cc -bundle -undefined dynamic_lookup -L/usr/local/lib LibXSLT.o perl-libxml-mm.o -o blib/arch/auto/XML/LibXSLT/LibXSLT.bundle -L/sw/lib -lxslt -lexslt -lxml2 -lz -lpthread -liconv -lm`, which looks like it creates a shared library / application plug-in, as described in https://en.wikipedia.org/wiki/Bundle_(macOS)#macOS_loadable_bundles. – melpomene Feb 21 '17 at 12:55
  • Seems to be specific to OS/X. `cc` (`gcc`) on Linux doesn't recognize `-bundle`. – ikegami Mar 30 '17 at 13:03
  • [About Bundles](https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html) – ikegami Mar 30 '17 at 13:06

1 Answers1

1
  1. What are these .bundle files ?

The *.bundle files, in this case, are Mach-O universal binary files.

file can be used to check the file type including architectures.

file …/Perl/…/XML/LibXSLT/LibXSLT.bundle
# /LibXSLT.bundle: Mach-O universal binary with 2 architectures: 
#    [x86_64:Mach-O 64-bit bundle x86_64] 
#    [arm64e:Mach-O 64-bit bundle arm64e]
  1. Who creates them ? CPAN modules ?

lipo is the tool used for combining one or more architecture specific executables into a Mach-O universal binary. (In general, although Perl may need the extension, the .bundle file extension is optional.)

which -a lipo
# /usr/bin/lipo

man lipo
# NAME
#        lipo - create or operate on universal files
  1. If so, then can we control its generation via some Makefile artifact ?

The Apple article "Building a Universal macOS Binary" mentions how to use a (C/C++/Swift) makefile to create a universal binary by merging the resulting executable files together with the lipo tool.

The following example shows a makefile that compiles a single-source file twice—once for each architecture. It then creates a universal binary by merging the resulting executable files together with the lipo tool.

x86_app: main.c
    $(CC) main.c -o x86_app -target x86_64-apple-macos10.12
arm_app: main.c
    $(CC) main.c -o arm_app -target arm64-apple-macos11
universal_app: x86_app arm_app
    lipo -create -output universal_app x86_app arm_app

Conceptually, the above approach could be used with a ExtUtils::MakeMaker Makefile.PL.

marc-medley
  • 8,931
  • 5
  • 60
  • 66