Skip to content

Undefined reference to `ffi_type_pointer' during run of makefile command #17691

@nick-melton

Description

@nick-melton

Description

Description
Makefile script could not load the constants from the libffi during make command

Environment

Amazon Linux
PHP 8.3.16
yum install --enablerepo=remi,remi-php83 -y php-devel librdkafka libxml2-devel sqlite-devel re2c autoconf bison make libtool

Step to reproduce:

  1. echo "extension=ffi.so" >> /opt/bref/php/conf.d/bref.ini
  2. ./buildconf
  3. cd /usr/src/php-src/ext/ffi
  4. /usr/bin/phpize
  5. cd /usr/src/php-src
  6. ./configure --with-ffi --with-config-file-scan-dir=/opt/bref/etc/php/conf.d --with-libdir=lib64 FFI_LIBS=/usr/src/php-src/ect/ffi FFI_CFLAGS=/usr/src/libffi/include
  7. make

Current behavior

ext/ffi/ffi.o: In function `zend_ffi_face_struct_add_fields':
/usr/src/php-src/ext/ffi/ffi.c:392: undefined reference to `ffi_type_pointer'
/usr/src/php-src/ext/ffi/ffi.c:389: undefined reference to `ffi_type_uint64'
/usr/src/php-src/ext/ffi/ffi.c:385: undefined reference to `ffi_type_uint32'
/usr/src/php-src/ext/ffi/ffi.c:381: undefined reference to `ffi_type_uint16'
/usr/src/php-src/ext/ffi/ffi.c:377: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:370: undefined reference to `ffi_type_longdouble'
/usr/src/php-src/ext/ffi/ffi.c:366: undefined reference to `ffi_type_double'
/usr/src/php-src/ext/ffi/ffi.c:363: undefined reference to `ffi_type_float'
/usr/src/php-src/ext/ffi/ffi.c:409: undefined reference to `ffi_type_void'
ext/ffi/ffi.o: In function `zend_ffi_get_type':
/usr/src/php-src/ext/ffi/ffi.c:457: undefined reference to `ffi_type_sint8'
/usr/src/php-src/ext/ffi/ffi.c:455: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:447: undefined reference to `ffi_type_float'
/usr/src/php-src/ext/ffi/ffi.c:463: undefined reference to `ffi_type_uint32'
/usr/src/php-src/ext/ffi/ffi.c:465: undefined reference to `ffi_type_sint32'
/usr/src/php-src/ext/ffi/ffi.c:467: undefined reference to `ffi_type_uint64'
/usr/src/php-src/ext/ffi/ffi.c:469: undefined reference to `ffi_type_sint64'
/usr/src/php-src/ext/ffi/ffi.c:459: undefined reference to `ffi_type_uint16'
/usr/src/php-src/ext/ffi/ffi.c:461: undefined reference to `ffi_type_sint16'
/usr/src/php-src/ext/ffi/ffi.c:452: undefined reference to `ffi_type_longdouble'
/usr/src/php-src/ext/ffi/ffi.c:473: undefined reference to `ffi_type_void'
/usr/src/php-src/ext/ffi/ffi.c:471: undefined reference to `ffi_type_pointer'
/usr/src/php-src/ext/ffi/ffi.c:449: undefined reference to `ffi_type_double'
ext/ffi/ffi.o: In function `zend_ffi_callback_hash_dtor':
/usr/src/php-src/ext/ffi/ffi.c:924: undefined reference to `ffi_closure_free'
ext/ffi/ffi.o: In function `zend_ffi_create_callback':
/usr/src/php-src/ext/ffi/ffi.c:1040: undefined reference to `ffi_closure_alloc'
/usr/src/php-src/ext/ffi/ffi.c:1087: undefined reference to `ffi_prep_cif'
/usr/src/php-src/ext/ffi/ffi.c:1092: undefined reference to `ffi_prep_closure_loc'
/usr/src/php-src/ext/ffi/ffi.c:1104: undefined reference to `ffi_closure_free'
ext/ffi/ffi.o: In function `zend_ffi_pass_arg':
/usr/src/php-src/ext/ffi/ffi.c:2581: undefined reference to `ffi_type_float'
/usr/src/php-src/ext/ffi/ffi.c:2586: undefined reference to `ffi_type_double'
/usr/src/php-src/ext/ffi/ffi.c:2592: undefined reference to `ffi_type_double'
/usr/src/php-src/ext/ffi/ffi.c:2598: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:2603: undefined reference to `ffi_type_sint8'
/usr/src/php-src/ext/ffi/ffi.c:2608: undefined reference to `ffi_type_uint16'
/usr/src/php-src/ext/ffi/ffi.c:2613: undefined reference to `ffi_type_sint16'
/usr/src/php-src/ext/ffi/ffi.c:2618: undefined reference to `ffi_type_uint32'
/usr/src/php-src/ext/ffi/ffi.c:2623: undefined reference to `ffi_type_sint32'
/usr/src/php-src/ext/ffi/ffi.c:2628: undefined reference to `ffi_type_uint64'
/usr/src/php-src/ext/ffi/ffi.c:2633: undefined reference to `ffi_type_sint64'
/usr/src/php-src/ext/ffi/ffi.c:2676: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:2681: undefined reference to `ffi_type_sint8'
/usr/src/php-src/ext/ffi/ffi.c:2637: undefined reference to `ffi_type_pointer'
/usr/src/php-src/ext/ffi/ffi.c:2681: undefined reference to `ffi_type_sint8'
ext/ffi/ffi.o: In function `zif_ffi_trampoline':
/usr/src/php-src/ext/ffi/ffi.c:2853: undefined reference to `ffi_prep_cif'
/usr/src/php-src/ext/ffi/ffi.c:2853: undefined reference to `ffi_prep_cif'
/usr/src/php-src/ext/ffi/ffi.c:2862: undefined reference to `ffi_call'
/usr/src/php-src/ext/ffi/ffi.c:2816: undefined reference to `ffi_prep_cif_var'
ext/ffi/ffi.o: In function `zend_ffi_pass_var_arg':
/usr/src/php-src/ext/ffi/ffi.c:2741: undefined reference to `ffi_type_pointer'
ext/ffi/ffi.o: In function `zif_ffi_trampoline':
/usr/src/php-src/ext/ffi/ffi.c:2816: undefined reference to `ffi_prep_cif_var'
ext/ffi/ffi.o: In function `zend_ffi_pass_var_arg':
/usr/src/php-src/ext/ffi/ffi.c:2737: undefined reference to `ffi_type_double'
/usr/src/php-src/ext/ffi/ffi.c:2724: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:2732: undefined reference to `ffi_type_sint64'
/usr/src/php-src/ext/ffi/ffi.c:2720: undefined reference to `ffi_type_uint8'
/usr/src/php-src/ext/ffi/ffi.c:2716: undefined reference to `ffi_type_pointer'
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

Expected outcome

make command finishes successfully so I can run make install as well and to have ffi extension working normally as expected

More info

Initially I already had an installed php in my docker image. I'm tied with this implementation so I gotta use PHP 8.3.16 and bref/php-83 with OS Amazon Linux 2, which is pretty close to CentOS. So I've downloaded your repo, installed appropriate dependencies (libxml2-devel, sqlite-devel, libffi-devel, php-devel, re2c, bison, autoconf, make, libtool, librdkafka), built the configure file, initialized ffi extension.

Then I ran ./configure with appropriate parameters and also passed a few environment variables with paths to the libs (in particular I passed the path to the libffi to FFI_CFLAGS as I assumed that it'll fetch these constants from there). By the way, I've downloaded that libffi as well, because once I installed libffi-devel it just created libffi.so in /usr/lib64

Could you please help me to figure out which values should I pass to the environment variables to make it work? I assume I'm passing some values wrong way, but can't figure out on how to make it right

PHP Version

PHP 8.3.16

Operating System

Amazon Linux 2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions