Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add librt for opcache #4794

Closed
wants to merge 2 commits into from
Closed

add librt for opcache #4794

wants to merge 2 commits into from

Conversation

remicollet
Copy link
Member

In some build case with have an undefined symbol: shm_unlink so we need to explicitly add this library.

Notice: this only happens in Fedora >= 31 so with recent gcc 9.2 and glibc 2.30

In older versions (Fedora <= 30) PHP is linked against librt which is enough
In new version, this lib disappear (linker optimization because uneeded ?), so have to be added.

BTW the patch is incomplete, as we also need to build using --enable-opcache=shared
didn't find the way to have proper default value = "shared" (there is some PHP_ALWARS_SHARED macro, but can't find it definition)

@remicollet
Copy link
Member Author

FYI On Fedora 29

# ldd $(which php)
	linux-vdso.so.1 (0x00007ffd7dfab000)
	libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f4a67d9d000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4a67d83000)
	libncurses.so.6 => /lib64/libncurses.so.6 (0x00007f4a67d56000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f4a67d27000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f4a67b8f000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f4a67b85000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f4a679ff000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f4a679f9000)
	libxml2.so.2 => /lib64/libxml2.so.2 (0x00007f4a6788f000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f4a6783d000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f4a6774c000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f4a6772e000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f4a67725000)
	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f4a6768f000)
	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f4a673b3000)
	libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4a67324000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f4a6730a000)
	libedit.so.0 => /lib64/libedit.so.0 (0x00007f4a672cf000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f4a67107000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f4a6883f000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4a670ec000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4a670cb000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f4a670a2000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f4a67090000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f4a6708a000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4a6705b000)

On Fedora 31

# ldd $(which php)
	linux-vdso.so.1 (0x00007ffd801bb000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4ce3cd2000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f4ce3b8c000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f4ce3b85000)
	libxml2.so.2 => /lib64/libxml2.so.2 (0x00007f4ce3a1a000)
	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f4ce3984000)
	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f4ce36a8000)
	libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4ce3618000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f4ce35fe000)
	libedit.so.0 => /lib64/libedit.so.0 (0x00007f4ce35c3000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f4ce33fa000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f4ce4724000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f4ce33d1000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4ce33af000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f4ce337d000)

@remicollet
Copy link
Member Author

During configure, -lrt is there (in $LIBS) thanks to PHP_CHECK_FUNC_LIB(nanosleep, rt) in configure.ac.

For robustness, I also add PHP_CHECK_FUNC_LIB(shm_open, rt)
which is used when build alone (phpize... in ext/opcache directory)

@@ -248,6 +252,9 @@ int main() {
Optimizer/zend_dump.c,
shared,,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1,,yes)

PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add -lrt in previous chunk?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-lrt is necessary only with HAVE_SHM_MMAP_POSIX.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, fixeed

@@ -13742,7 +13742,7 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
sljit_free_compiler(compiler);
SLJIT_FREE(common->optimized_cbracket, allocator_data);
SLJIT_FREE(common->private_data_ptrs, allocator_data);
PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data);
PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, this and following changes are unrelated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.... rebase issue.... ignore this

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any problems. If it works for you - merge.

@remicollet
Copy link
Member Author

Applied in 7.4+

@remicollet remicollet closed this Oct 8, 2019
@remicollet remicollet deleted the issue-librt branch October 8, 2019 08:50
kelnei pushed a commit to iusrepo/php74 that referenced this pull request Dec 11, 2019
  to ensure opcache is always linked with librt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants