Help wanted for compiling PHP for a-shell
- Dominant language
- Perl
- Stars
- 3.9k
- Forks
- 213
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
I was attempting to compile PHP for a-shell using the following script.
```sh
#!/bin/bash
make clean
PLATFORM=iPhoneOS # iPhoneSimulator # iPhoneOS
HOST=arm-apple-darwin # i386-apple-darwin10 # arm-apple-darwin10
ARCH=arm64 # i386 # armv7s #armv7
SDK_VERSION=14.5
XCODE_ROOT=`xcode-select -print-path`
PLATFORM_PATH=$XCODE_ROOT/Platforms/$PLATFORM.platform/Developer
SDK_PATH=$PLATFORM_PATH/SDKs/$PLATFORM$SDK_VERSION.sdk
FLAGS="-isysroot $SDK_PATH -arch $ARCH -miphoneos-version-min=$SDK_VERSION"
PLATFORM_BIN_PATH=$XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin
CFLAGS="$FLAGS -std=gnu99"
CXXFLAGS="$FLAGS -std=gnu++11 -stdlib=libc++"
LDFLAGS="$FLAGS -lresolv -nostartfiles"
export CFLAGS CXXFLAGS LDFLAGS # PCRE2_CFLAGS PCRE2_LIBS
CONFIGURE_FLAGS="--host=$HOST --enable-embed=static --enable-cli --disable-phpdbg --disable-phar --enable-static --without-pear --disable-opcache --disable-opcache-jit --without-iconv --disable-cgi --disable-shared --enable-mysqlnd --with-pdo-mysql --with-mysqli --with-tsrm-pthreads --without-pcre-jit"
./configure $CONFIGURE_FLAGS
make
cp sapi/cli/php iOS/php
cd iOS
mkdir php.framework
mv php php.framework/php
cp Info.plist php.framework/Info.plist
xcodebuild -create-xcframework -framework php.framework -output php.xcframework
```
It worked fine and produced a php cli executable to be used in a-shell. However, when I called the command from the app, the following error shows:
```
Failed loading php from php.framework/php, cause = dlopen(php.framework/php, 9): no suitable image found. Did find:
/private/var/containers/Bundle/Application/CE45D906-0B67-4AF8-824D-1643D66BABFE/WKConsole.app/Frameworks/php.framework/php: out of address space
```
So I renamed `main()` function in `sapi/cli/php_cli.c` to `command_main()`.
Then I have the following error during the build:
```
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _virtual_cwd_main_cwd_init, _command_main )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
```
I suspect the linker expects a main function when creating an executable. How can I overcome this limitation?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.