# Issues with custom extension.

- Thread: https://externals.io/message/31626
- Original archive: https://news-web.php.net/php.internals/31626
- Started by BuildSmart on 2007-08-16T13:37:44+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #31626 — BuildSmart — 2007-08-16T13:37:44+00:00

URL: https://externals.io/message/31626#31626

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wrote an extension/module (quite some time ago) for PHP4, for the  
last year or so (on and off) I've been rewriting it for PHP5.

Under PHP4 it works properly as an embedded extension or a loadable  
module.

Under PHP5 it only appears to work properly as an embedded extension  
but when it's a loadable module it fails to work properly.

What I mean by 'fails to work' properly is that it doesn't perform  
the tasks it's supposed to perform.

I realize that this is not very explanatory and I really don't know  
how else to explain it.

Since I don't know what the problem is or where to begin I was hoping  
I could find some kind soul with a little time could assist me in  
resolving this problem.

- -- Dale
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)

iD8DBQFGxFMp0hzWbkf0eKgRAoEsAKCn0XM4NEuo2vZQUciZEZ/t8KfCfwCfb4jE
hCttSqcjFpXG/oYB4V+t8oY=
=2XmB
-----END PGP SIGNATURE

---

## #31627 — Alexey Zakhlestin — 2007-08-16T14:08:12+00:00

URL: https://externals.io/message/31626#31627 · In reply to: #31626

1) did you try to hook into your extension with debugger?
2) is your extension open-source (I mean: can you show the actual source-code?)
3) do you develop your extension with both zts and debug modes enabled?



> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I wrote an extension/module (quite some time ago) for PHP4, for the
> last year or so (on and off) I've been rewriting it for PHP5.
>
> Under PHP4 it works properly as an embedded extension or a loadable
> module.
>
> Under PHP5 it only appears to work properly as an embedded extension
> but when it's a loadable module it fails to work properly.
>
> What I mean by 'fails to work' properly is that it doesn't perform
> the tasks it's supposed to perform.
>
> I realize that this is not very explanatory and I really don't know
> how else to explain it.
>
> Since I don't know what the problem is or where to begin I was hoping
> I could find some kind soul with a little time could assist me in
> resolving this problem.
>
> - -- Dale
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (Darwin)
>
> iD8DBQFGxFMp0hzWbkf0eKgRAoEsAKCn0XM4NEuo2vZQUciZEZ/t8KfCfwCfb4jE
> hCttSqcjFpXG/oYB4V+t8oY=
> =2XmB
> -----END PGP SIGNATURE-----
>
> --
> 
> 
>
>


-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

---

## #31719 — BuildSmart — 2007-08-18T18:37:47+00:00

URL: https://externals.io/message/31626#31719 · In reply to: #31627

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1




> 1) did you try to hook into your extension with debugger?
> 2) is your extension open-source (I mean: can you show the actual  
> source-code?)
> 3) do you develop your extension with both zts and debug modes  
> enabled?

Digging a little further into the issue which I thought was just  
related to my module (it appears that all of the shared extensions  
don't work as expected either), I came up with the following.

After examining the build/link phases it appears that it doesn't seem  
to like the allow_undefined_tag if you build using gcc 3.3 or gcc 3.5  
or you build for more than one cpu architecture.

I tried adding the '-flat_namespace' to the CFLAGS as a possible  
solution however it complains that you cannot specify '- 
flat_namespace' and '-twolevel_namespace' at the same time which is  
understandable

I edited the Makefile and removed the '--silent' directives so I  
could see the actual build take place and for some reason it appears  
to default to using the non-pic items even for the shared extensions  
but if you force the creation of just the shared extension with the '- 
dynamic' flag it then utilizes the pic objects which is strange  
because you would think that the '-prefer-pic' would force the use of  
the pic objects if they are available.

Since Apple has crossed over the platform bridge with it's intel line  
of hardware, building in multiple architecture is going to become a  
normal way of life so perhaps a more dynamic solution might be in order.

I substantiated my findings with the following edits (in two places)  
to the configure file: (this was a temporary workaround pending a  
proper solution by the dev-team)

     darwin* | rhapsody*)
       case $host_os in
         rhapsody* | darwin1.[012])
          allow_undefined_flag='${wl}-undefined ${wl}suppress'
          ;;
        *) # Darwin 1.3 on
          if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
            allow_undefined_flag='${wl}-flat_namespace ${wl}- 
undefined ${wl}suppress'
          else
            case ${MACOSX_DEPLOYMENT_TARGET} in
              10.[012])
                allow_undefined_flag='${wl}-flat_namespace ${wl}- 
undefined ${wl}suppress'
                ;;
              10.*)
                 # allow_undefined_flag, $1)='${wl}-undefined ${wl} 
dynamic_lookup'
                 allow_undefined_flag='${wl}-flat_namespace ${wl}- 
undefined ${wl}suppress'
                ;;
            esac
          fi
          ;;
       esac

Now that I've isolated the build issue, can this be resolved without  
requiring manual edits to the configure script?

Perhaps a test of the active gcc version?

Testing the CFLAGS/CPPFLAGS/LDFLAGS for '-arch' might be a bit  
problematic since they are sometimes provided before the configure  
command, sometimes as part of the environment.



As well, to avoid wasting build time on static libs that aren't used  
in Mac OS X, I made an additional change to the configure script:  
(not really required)

     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
         archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib  
$libobjs $deplibs $compiler_flags -install_name $rpath/$soname  
$verstring'
       #module_cmds='$CC $allow_undefined_flag -o $lib -bundle  
$libobjs $deplibs$compiler_flags'
       module_cmds='$CC $allow_undefined_flag -o $lib -dynamic - 
bundle $libobjs $deplibs$compiler_flags'

All this does is prevent the static modules from being built (no  
name.a files, only name.so files).

>
> 
> > […]
>
>
> -- 
> Alexey Zakhlestin
> http://blog.milkfarmsoft.com/

- -- Dale


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)

iD8DBQFGxzx70hzWbkf0eKgRAr0qAJ4pHdbQRp+xx4zoLS1eyZtUIxEDyACfcWMy
bvT0nONFhUKCSsXMMTfgG8s=
=Y1ue
-----END PGP SIGNATURE
