Build fails on 32-bit Linux and FreeBSD with Clang
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
./buildconf
./configure
make
Resulted in this output on FreeBSD 14 32-bit with Clang 16.0.6 (default compiler selected by the system):
ld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in ext/opcache/.libs/zend_accelerator_debug.o
>>> referenced by zend_accelerator_debug.c:58 (ext/opcache/zend_accelerator_debug.c:58)
>>> ext/opcache/.libs/zend_accelerator_debug.o:(zend_accel_error_va_args)
make: stopped in .../php-src
But I expected this output instead:
# builds successfullly
On Debian 32-bit with Clang this happens:
ext/standard/base64.o: unsupported non-PIC call to IFUNC `php_base64_encode_ex'
/usr/bin/ld: failed to set dynamic section sizes: bad value
/usr/bin/ld: /usr/bin/ld: ext/standard/base64.o: unsupported non-PIC call to IFUNC `ext/standard/base64.ophp_base64_encode_ex: unsupported non-PIC call to IFUNC `'php_base64_encode_ex
When using GCC it works ok. Issue is that there is a check to disable PIC mode for shared extensions on 32-bit Linux and FreeBSD: https://github.com/php/php-src/blob/bbbe56eecc6ff6b3971ba4f924d51c9aa11955c5/configure.ac#L242-L257
(Probably solution would be to skip the non-PIC mode for Clang on 32-bit)
PHP Version
PHP 8.2, 8.3 and 8.4-dev
Operating System
32-bit Linux and FreeBSD
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with ./buildconf, ./configure, and make on 32-bit Linux or FreeBSD using Clang. Start by inspecting configure.ac around lines 242-257 and the affected ext/opcache and ext/standard build output. Done means the PHP source builds successfully with Clang on the reported 32-bit systems without the relocation or non-PIC errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100