crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.26k stars 215 forks source link

Build error with Postgres because of libxml2 #405

Closed dunglas closed 5 months ago

dunglas commented 5 months ago

Since a few days, Postgres build fails because libxml2 isn't detected (while it looks present):

configure: error: library 'xml2' (version >= 2.6.23) is required for XML support
checking for xmlSaveToBuffer in -lxml2... no

https://github.com/dunglas/frankenphp/actions/runs/8631360668/job/23659621879?pr=712

In the config.log of Postgres, we can see that the problem looks related to ICU:

configure:13082: checking for xmlSaveToBuffer in -lxml2
configure:13107: clang -o conftest -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk  -DLIBXML_STATIC -I/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/include/libxml2 -I/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk  -L/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot//Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib -L/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib  conftest.c -lxml2  -lssl -lcrypto -lz -lreadline -ltermcap -lm  >&5
ld: warning: search path '/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot//Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib' not found
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[2](buf.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[4](catalog.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[5](chvalid.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[6](debugXML.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[7](dict.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[8](encoding.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[9](entities.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[10](error.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[11](globals.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[12](hash.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[13](HTMLparser.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[14](HTMLtree.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[16](list.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[18](nanohttp.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[19](parser.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[20](parserInternals.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[21](pattern.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[22](relaxng.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[24](SAX2.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[26](threads.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[27](tree.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[28](uri.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[29](valid.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[30](xinclude.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[32](xmlIO.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[33](xmlmemory.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[35](xmlreader.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[36](xmlregexp.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[37](xmlsave.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[38](xmlschemas.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[39](xmlschemastypes.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[40](xmlstring.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[41](xmlunicode.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[43](xpath.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
ld: warning: object file (/Users/dunglas/workspace/frankenphp/dist/static-php-cli/buildroot/lib/libxml2.a[44](xpointer.c.o)) was built for newer 'macOS' version (14.3) than being linked (14.0)
Undefined symbols for architecture arm64:
  "_UCNV_FROM_U_CALLBACK_STOP_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
  "_UCNV_TO_U_CALLBACK_STOP_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
  "_libiconv", referenced from:
      _xmlIconvWrapper in libxml2.a[8](encoding.c.o)
  "_libiconv_close", referenced from:
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      ...
  "_libiconv_open", referenced from:
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
      _xmlFindCharEncodingHandler in libxml2.a[8](encoding.c.o)
  "_ucnv_close_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
      _closeIcuConverter in libxml2.a[8](encoding.c.o)
      _closeIcuConverter in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      _xmlCharEncCloseFunc in libxml2.a[8](encoding.c.o)
      ...
  "_ucnv_convertEx_74", referenced from:
      _xmlEncInputChunk in libxml2.a[8](encoding.c.o)
      _xmlEncOutputChunk in libxml2.a[8](encoding.c.o)
  "_ucnv_open_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
      _openIcuConverter in libxml2.a[8](encoding.c.o)
  "_ucnv_setFromUCallBack_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
  "_ucnv_setToUCallBack_74", referenced from:
      _openIcuConverter in libxml2.a[8](encoding.c.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note: the problem seems to also happen on Linux.

crazywhalecc commented 5 months ago

strange.. my local builds are always successful and CI failed. This bug should be fixed a few month ago. Maybe patching postgresql build file is a possible solution (add icu as dep)

crazywhalecc commented 5 months ago

Oh. The reason why postgresql cannot be compiled is actually openssl.

The solution is also simple: Patch libssl.pc, libcrypto.pc and openssl.pc, add prefix lines. But we may also need to check retcode after execWithResult in postgresql build function.

dunglas commented 5 months ago

Thank you very much for the investigation! I was on it but very far :)