From:             alex dot php at epathology dot com dot au
Operating system: OpenBSD 3.3
PHP version:      4.3.4
PHP Bug Type:     CGI related
Bug description:  CLI SAPI module variable name conflict

Description:
------------
Trying to compile PHP 4.3.4 with the CLI SAPI module on OpenBSD 3.3 gives
the warnings listed under 'actual result' related to the optind and optarg
variables.

The CLI binary produced then doesn't interpret its command line arguments
properly.

Fix:
This seems to be due to the static optarg and optind variables in
sapi/cli/php_cli.c conflicting with those of the standard library. The
problem went away when I renamed these two variables.

Reproduce code:
---------------
./configure \
        --with-config-file-path=/var/www/conf \
        --with-apxs \
        --with-openssl \
        --with-zlib \
        --with-iconv \
        --with-gettext \
        --with-recode \
        --with-pgsql \
        --without-mysql \
        --without-xml \
        --enable-inline-optimization \
        --enable-shared \
        --enable-dio \
        --enable-bcmath \
        --enable-calendar \
        --enable-sockets \
        --disable-static
make
sapi/cli/php --help

Expected result:
----------------
Compilation without problems, with help text shown when running
'sapi/cli/php --help'.

Actual result:
--------------
When the CLI is being compiled the following warnings appear, and then
'sapi/cli/php --help' ignores the --help argument.

/bin/sh /home/alex/src/php-4.3.4/libtool --silent --preserve-dup-deps
--mode=compile gcc  -Isapi/cli/ -I/home/alex/src/php-4.3.4/sapi/cli/
-DPHP_ATOM_INC -I/home/alex/src/php-4.3.4/include
-I/home/alex/src/php-4.3.4/main -I/home/alex/src/php-4.3.4
-I/home/alex/src/php-4.3.4/Zend -I/usr/local/include
-I/usr/local/pgsql/include -I/home/alex/src/php-4.3.4/ext/xml/expat 
-I/home/alex/src/php-4.3.4/TSRM  -g -O2  -prefer-pic -c
/home/alex/src/php-4.3.4/sapi/cli/php_cli.c -o sapi/cli/php_cli.lo
/tmp/ccN17837.s: Assembler messages:
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be
global
/tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be
global
/bin/sh /home/alex/src/php-4.3.4/libtool --silent --preserve-dup-deps
--mode=link gcc -export-dynamic -g -O2  -L/usr/local/lib
-L/usr/local/pgsql/lib  -R /usr/local/lib -R /usr/local/pgsql/lib
ext/openssl/openssl.lo ext/zlib/zlib.lo (many .lo files)
main/internal_functions_cli.lo -lrecode -lpq -liconv -lintl -lz -lssl
-lcrypto -lm  -o sapi/cli/php
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1872
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1742
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1735
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1711
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x16bd
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1661
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x164a
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1609
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1420
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1413
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x11c4
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x11bd
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1100
ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x10f5


-- 
Edit bug report at http://bugs.php.net/?id=27104&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27104&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27104&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27104&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27104&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27104&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27104&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27104&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27104&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27104&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27104&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27104&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27104&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27104&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27104&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27104&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27104&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27104&r=float

Reply via email to