Opened 16 years ago
#2669 new defect
unnecessary link flags for shared lib on OSX
Reported by: | kyngchaos | Owned by: | dmorissette |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Build Problems | Version: | 5.0 |
Severity: | normal | Keywords: | |
Cc: |
Description
LD_SHARED and PHP_LD_SHARED have some unnecessary flags for OSX "Darwin".
-flat_namespace - the standard, and default, for OSX is two-level namespaces. According to the docs, two-level namespace libraries load faster.
-undefined suppress - for a normal library on OSX, if a symbol can't be found at compile time because a library isn't specified for it, the symbol won't be found at runtime. So it's good to catch link errors at compile time.
But for a loadable module (bundle), like PHP extensions, where some symbols are expected to be in the loader (PHP CGI or Apache module), there will be undefined symbols. In this case -undefined dynamic_lookup is an option, though this requires at least OSX 10.4. Better would be to use the -bundle_loader flag to specify the loader. ie: -bundle_loader /path/to/cgi/php. Though this would need an extra configure option to specify where the PHP CGI or Apache module is since that info is not available in php_config.
Undefined suppress may work for a loadable module (there haven't been complaints yet).
Summary, for configure, "Darwin" sections:
LD_SHARED="${CXX} -dynamiclib -single_module"
and (best option for PHP, needs configure flag to specify path to PHP CGI or Apache module, such as --with-php-loader)
PHP_LD_SHARED="${CXX} -bundle -bundle_loader ${PHP_LOADER}"