Skip to content

Compile errors on M1 ARM Mac #32

@janzikmund

Description

@janzikmund

On my old, Intel-based MacBook (BigSur, PHP7.4, Firebird 3.0.10), I managed to compile the driver just fine using the following steps:

  1. git clone https://github.com/FirebirdSQL/php-firebird.git
  2. cd php-firebird
  3. phpize
  4. CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Versions/Current/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Versions/Current/Libraries ./configure
  5. make

This gave me the compiled modules/interbase.so file, which I then copied to my extension_dir and enabled in php.ini.

Now when attempting the same on the new M1 ARM MacBook with MacOS Monterey, it just fails on step 4 with the following:
configure: error: libfbclient, libgds or libib_util not found! Check config.log for more information.

Unfortunately the log doesn't give me many pointers, but I have checked that /Library/Frameworks/Firebird.framework/Versions/Current/Libraries contains libfbclient.dylib and libib_util.dylib but libgds.dylib is missing, not sure how far that's an issue. I tried to look it up, but without success. I even replaced Firebird 3.0.10 by older 3.0.5 LIPO package from here , but even here the libgds is missing.

I found out that if I do step 4 with additionally passing architecture flag, it helps and the following compiles successfully:
CFLAGS='-arch x86_64' CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Resources/lib ./configure

The problem is, that after moving the resulting interbase.so to php extension_dir, it just doesn't load and PHP states the following error, which is probably reasonable:
Warning: PHP Startup: Unable to load dynamic library 'interbase.so' (tried: /opt/homebrew/lib/php/pecl/20190902/interbase.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/interbase.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/interbase.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))), /opt/homebrew/lib/php/pecl/20190902/interbase.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/interbase.so.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/interbase.so.so' (no such file))) in Unknown on line 0

.. where the important part imo is the mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')

So I try from scratch and replace step 4 with CFLAGS='-arch arm64e' CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Resources/lib ./configure , but that terminates after a few lines of output with the following:

checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for pkg-config... no
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in /Users/ziki/Desktop/php-firebird:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use --host.

I even tried with -arch arm64 instead of -arch arm64e, but in that case I just get the configure: error: libfbclient, libgds or libib_util not found! error again.

Has anyone managed to do it successfully? Only guidelines I found is this SO thread, but that suggests replacing PHP and other brew dependecies by 64bit versions, and I am not sure if that would work at all with my webserver (Laravel Valet).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions