pmmp / PHP-Binaries

Compile scripts used to build PHP for PocketMine-MP on multiple platforms
117 stars 169 forks source link

compile.sh -P option does not work #166

Closed ZizzyZizzy closed 1 year ago

ZizzyZizzy commented 1 year ago

From README:

Target Arguments
linux64 -t linux64 -j4 -f x86_64
linux64, PM5 -t linux64 -j4 -f x86_64 -P 5
mac64 -t mac-x86-64 -j4 -f
android-aarch64 -t android-aarch64 -x -j4 -f

Me running it on Ubuntu 18.04:

#./compile.sh -t linux64  -j6 -f x86_64
[PocketMine] PHP compiler for Linux, MacOS and Android
[INFO] Checking dependencies
[opt] Set target to linux64
[opt] Set make threads to 6
[opt] Enabling abusive optimizations...
Please specify PocketMine-MP major version target with -P (e.g. -P5)

# ./compile.sh -t linux64  -j6 -f x86_64 -P4
[PocketMine] PHP compiler for Linux, MacOS and Android
[INFO] Checking dependencies
[opt] Set target to linux64
[opt] Set make threads to 6
[opt] Enabling abusive optimizations...
Please specify PocketMine-MP major version target with -P (e.g. -P5)

# ./compile.sh -t linux64  -j6 -f x86_64 -P 4
[PocketMine] PHP compiler for Linux, MacOS and Android
[INFO] Checking dependencies
[opt] Set target to linux64
[opt] Set make threads to 6
[opt] Enabling abusive optimizations...
Please specify PocketMine-MP major version target with -P (e.g. -P5)

README also says "-P 4" is the default. This is not true. If the version is not specified, the script exits:

if [ "$PM_VERSION_MAJOR" == "" ]; then
    echo "Please specify PocketMine-MP major version target with -P (e.g. -P5)"
    exit 1
fi

I had to update the script to get it to run. No idea why getopts is not working here.

dktapps commented 1 year ago

You need to put -f x86_64 at the end. -f does some weird magic to optionally accept a parameter which breaks other stuff.

Incidentally, if you're compiling on the machine that's going to use the binary, you can drop the -t option and use -f without specifying arch, and it'll optimize for the current machine automatically. That can produce a slightly faster binary (if you specify -t in particular it will disable some newer instruction sets like AVX).