rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

Adding support for running MacOS Universal binaries #58

Closed plk closed 2 years ago

plk commented 2 years ago

This patch only alters the boot.c code for MacOS. It:

I had to post-process the tmpdir used as par_mktmpdir results in paths with repeated slashes in it which execve doesn't like.

One thing to check is whether generic MacOS contains /usr/binb/lipo without having Developer Tools installed. The code checks for this anyway.

Tested with a Universal ARM64/x86_64 binary which, using this patch, runs on both now - before, it only runs the last binary in the FAT binary, the other(s) erroring out, as expected.

rschupp commented 2 years ago

I had to post-process the tmpdir used as par_mktmpdir results in paths with repeated slashes in it which execve doesn't like.

Do you have an example, e.g. what does

pp -o par_temp -E 'say $ENV{PAR_TEMP}'
./par_temp

print? I can't reproduce this on my Linux box (except when I deliberately set PAR_GLOBAL_TEMP to something that already contains consecutive slashes.

plk commented 2 years ago

Example of the double slash from your test program - the execve seems to have trouble with this as I believe that double slash ignoring is mostly a feature of things like shells and higher level programs:

/var/folders/9_/96fh404s6mndhsgy4_wcjn3w0000gn/T//par-7068696c6b696d65/cache-c0e725562916c6004b84eccba88a7e9f2218fc76
rschupp commented 2 years ago

Example of the double slash from you test program - the execve seems to have trouble with this as I believe that double slash ignoring is mostly a feature of things like shells and higher level programs

Nope, any *nix I know of ignores multiple slashes on the syscall level (except maybe for leading "//"). And my Linux will happily execve stuff with multiple slashes, but maybe MacOS is paranoid just for the exec family...

Anyway, your example is interesting: par_mktmpdir tries the following environment variables: PAR_TMPDIR, TMPDIR, TEMPDIR, TEMP, TMP. Maybe your environment sets it to something ending in a slash?

plk commented 2 years ago

Ah, wasn't aware of that. Yes, it seems this is default for MacOS:

[tree][PAR-Packer] > env | fgrep TMP 
TMPDIR=/var/folders/9_/96fh404s6mndhsgy4_wcjn3w0000gn/T/
plk commented 2 years ago

Should be tidier now as requested and the biber-specific stuff removed.