libgit2/php-git

Error on compilation (OSX)

MattKetmo opened this issue · 6 comments

I wanted to compile this PHP extension after your update today (commit a18e511), but I can't make make works.

I'm on OSX 10.7 with PHP 5.3.10:

$ uname -a
Darwin mattketmo.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
$ php -v
PHP 5.3.10 with Suhosin-Patch (cli) (built: Feb 20 2012 22:55:53) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Here is the output for ./configure & make:

➜  php-git git:(develop) ./configure
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/local/bin/gsed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i386-apple-darwin11.4.0
checking host system type... i386-apple-darwin11.4.0
checking target system type... i386-apple-darwin11.4.0
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20090626
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking Whether to enable the "git2" extension... yes, shared
checking for libgit2... yes, shared
checking for ld used by cc... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld
checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) is GNU ld... no
checking for /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... rm: conftest.dSYM: is a directory
ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin11.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
➜  php-git git:(develop) make
/bin/sh /tmp/php-git/libtool --mode=compile cc  -I. -I/tmp/php-git -DPHP_ATOM_INC -I/tmp/php-git/include -I/tmp/php-git/main -I/tmp/php-git -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement -Wl,libgit2/build/libgit2.a   -c /tmp/php-git/git2.c -o git2.lo 
mkdir .libs
cc -I. -I/tmp/php-git -DPHP_ATOM_INC -I/tmp/php-git/include -I/tmp/php-git/main -I/tmp/php-git -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement -Wl,libgit2/build/libgit2.a -c /tmp/php-git/git2.c  -fno-common -DPIC -o .libs/git2.o
In file included from /usr/include/php/main/php.h:388,
                from /tmp/php-git/php_git2.h:35,
                from /tmp/php-git/git2.c:25:
/usr/include/php/main/php_output.h:49: warning: redundant redeclaration of ‘php_ob_get_buffer’
/usr/include/php/main/php_output.h:40: warning: previous declaration of ‘php_ob_get_buffer’ was here
/usr/include/php/main/php_output.h:50: warning: redundant redeclaration of ‘php_ob_get_length’
/usr/include/php/main/php_output.h:41: warning: previous declaration of ‘php_ob_get_length’ was here
In file included from /tmp/php-git/git2.c:25:
/tmp/php-git/php_git2.h:40:20: error: git2.h: No such file or directory
/tmp/php-git/php_git2.h:41:27: error: git2/errors.h: No such file or directory
/tmp/php-git/php_git2.h:42:32: error: git2/odb_backend.h: No such file or directory
In file included from /tmp/php-git/git2.c:25:
/tmp/php-git/php_git2.h:69: error: expected specifier-qualifier-list before ‘git_repository’
/tmp/php-git/php_git2.h:74: error: expected specifier-qualifier-list before ‘git_commit’
/tmp/php-git/php_git2.h:79: error: expected specifier-qualifier-list before ‘git_blob’
/tmp/php-git/php_git2.h:84: error: expected specifier-qualifier-list before ‘git_tree’
/tmp/php-git/php_git2.h:91: error: expected specifier-qualifier-list before ‘git_tree_entry’
/tmp/php-git/php_git2.h:96: error: expected specifier-qualifier-list before ‘git_treebuilder’
/tmp/php-git/php_git2.h:101: error: expected specifier-qualifier-list before ‘git_signature’
/tmp/php-git/php_git2.h:106: error: expected specifier-qualifier-list before ‘git_reference’
/tmp/php-git/php_git2.h:111: error: expected specifier-qualifier-list before ‘git_revwalk’
/tmp/php-git/php_git2.h:118: error: expected specifier-qualifier-list before ‘git_index’
/tmp/php-git/php_git2.h:124: error: expected specifier-qualifier-list before ‘git_index_entry’
/tmp/php-git/php_git2.h:129: error: expected specifier-qualifier-list before ‘git_config’
/tmp/php-git/php_git2.h:134: error: expected specifier-qualifier-list before ‘git_remote’
/tmp/php-git/php_git2.h:139: error: expected specifier-qualifier-list before ‘git_tag’
/tmp/php-git/php_git2.h:144: error: expected specifier-qualifier-list before ‘git_odb’
/tmp/php-git/php_git2.h:149: error: expected specifier-qualifier-list before ‘git_odb_object’
/tmp/php-git/php_git2.h:158: error: expected specifier-qualifier-list before ‘git_odb_backend’
/tmp/php-git/php_git2.h:198: error: expected ‘)’ before ‘*’ token
/tmp/php-git/php_git2.h:216: error: expected declaration specifiers or ‘...’ before ‘git_commit’
/tmp/php-git/php_git2.h: In function ‘php_git2_create_signature_from_commit’:
/tmp/php-git/php_git2.h:220: error: nested functions are disabled, use -fnested-functions to re-enable
/tmp/php-git/php_git2.h:220: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/tmp/php-git/php_git2.h:220: error: ‘author’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:220: error: (Each undeclared identifier is reported only once
/tmp/php-git/php_git2.h:220: error: for each function it appears in.)
/tmp/php-git/php_git2.h:221: warning: ISO C90 forbids mixed declarations and code
/tmp/php-git/php_git2.h:224: warning: implicit declaration of function ‘git_commit_author’
/tmp/php-git/php_git2.h:224: error: ‘commit’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:226: warning: implicit declaration of function ‘git_commit_committer’
/tmp/php-git/php_git2.h: At top level:
/tmp/php-git/php_git2.h:258: error: expected declaration specifiers or ‘...’ before ‘git_tree_entry’
/tmp/php-git/php_git2.h:258: error: expected declaration specifiers or ‘...’ before ‘git_repository’
/tmp/php-git/php_git2.h: In function ‘create_tree_entry_from_entry’:
/tmp/php-git/php_git2.h:261: error: ‘GIT_OID_HEXSZ’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:261: warning: ISO C90 forbids mixed declarations and code
/tmp/php-git/php_git2.h:262: error: nested functions are disabled, use -fnested-functions to re-enable
/tmp/php-git/php_git2.h:262: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/tmp/php-git/php_git2.h:262: error: ‘oid’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:263: warning: ISO C90 forbids mixed declarations and code
/tmp/php-git/php_git2.h:269: error: ‘php_git2_tree_entry’ has no member named ‘entry’
/tmp/php-git/php_git2.h:269: error: ‘entry’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:270: warning: implicit declaration of function ‘git_tree_entry_id’
/tmp/php-git/php_git2.h:271: warning: implicit declaration of function ‘git_oid_tostr’
/tmp/php-git/php_git2.h:273: warning: implicit declaration of function ‘git_tree_entry_name’
/tmp/php-git/php_git2.h:273: warning: cast to pointer from integer of different size
/tmp/php-git/php_git2.h:275: warning: implicit declaration of function ‘git_tree_entry_attributes’
/tmp/php-git/php_git2.h:261: warning: unused variable ‘buf’
/tmp/php-git/php_git2.h: At top level:
/tmp/php-git/php_git2.h:278: error: expected declaration specifiers or ‘...’ before ‘git_index_entry’
/tmp/php-git/php_git2.h: In function ‘php_git2_create_index_entry’:
/tmp/php-git/php_git2.h:281: error: ‘GIT_OID_HEXSZ’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:285: warning: implicit declaration of function ‘git_oid_fmt’
/tmp/php-git/php_git2.h:285: error: ‘entry’ undeclared (first use in this function)
/tmp/php-git/php_git2.h:281: warning: unused variable ‘oid_out’
/tmp/php-git/php_git2.h: In function ‘php_git2_exception_check’:
/tmp/php-git/php_git2.h:313: warning: implicit declaration of function ‘giterr_last’
/tmp/php-git/php_git2.h:314: warning: implicit declaration of function ‘giterr_clear’
/tmp/php-git/git2.c: At top level:
/tmp/php-git/git2.c:88: error: expected ‘)’ before ‘*’ token
/tmp/php-git/git2.c: In function ‘zm_info_git2’:
/tmp/php-git/git2.c:245: error: ‘LIBGIT2_VERSION’ undeclared (first use in this function)
make: *** [git2.lo] Error 1

Which is your current configuration (OS & PHP)?

By cloning with git-submodule as marked in the README, I'm on commit e460739 of libgit2. Should I change its position?

Thank you.

/tmp/php-git/php_git2.h:40:20: error: git2.h: No such file or directory
/tmp/php-git/php_git2.h:41:27: error: git2/errors.h: No such file or directory
/tmp/php-git/php_git2.h:42:32: error: git2/odb_backend.h: No such file or directory

let me take a look today. probably i made some mistakes.

Indeed, I changed those lines with relative path of the header files and it passed:

-#  include <git2.h>
-#  include <git2/errors.h>
-#  include <git2/odb_backend.h>
+#  include "libgit2/include/git2.h"
+#  include "libgit2/include/git2/errors.h"
+#  include "libgit2/include/git2/odb_backend.h"

... but I guess that's not a pretty solution.

So maybe there is something to change in the construction of libgit2 ?

sorry. I've forgotten to add PHP_ADD_INCLUDE to config.mr.
https://github.com/libgit2/php-git/blob/develop/config.m4

probably I'll fix this issue today. but i drunk too much today at work. anyway i'll do my best

@MattKetmo can you try to build php-git2 with latest develop branch?
you need to do phpize --clean before build.

I tested it on OSX and Debian and it works perfectly. Thanks.

For information, I'm on commit fe4cb28 of php-git and e4607392b5cbdcaf6a5dc810ca77b5dd1afcb147 of libgit2.

😸

At least current testcases passed. but it may contains several bugs as php-git2 jumped libgit2 version at this time.
if you have some troubles regarding php-git2. please ask me directly or make an issue.