-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Build fails on musl 1.2.4 - lfs64 #11678
Comments
Using following patch to build diff --git a/main/streams/cast.c b/main/streams/cast.c
index 3bad65fbac..05cab34658 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -102,8 +102,7 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz
return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
}
-# ifdef COOKIE_SEEKER_USES_OFF64_T
-static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
+static int stream_cookie_seeker(void *cookie, off_t *position, int whence)
{
*position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence);
@@ -113,13 +112,6 @@ static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
}
return 0;
}
-# else
-static int stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
-{
-
- return php_stream_seek((php_stream *)cookie, position, whence);
-}
-# endif
static int stream_cookie_closer(void *cookie)
{ |
From https://musl.libc.org/releases.html
|
The detection code needs to account Probably the place to fix is Lines 1427 to 1512 in 0b0cec5
|
…tion of php >=7.4 (#639) WordPress/playground-tools#110 depends on this PR: **Allow PHP instances to stop & restart without leaking memory.** * Expose PHP's exit() function to javascript to allow instances to be shutdown and garbage collected. * Tweaks load-php-runtime.ts to delete local references to instances upon shutdown. **Allow calling code to access cookies inside PHPBrowser** * `PHPBrowser`'s `setCookies` & `serializeCookies` are no longer private methods, allowing multiple instances to share the same login. **Allow PHP >= 7.4 to compile without failure.** * ~~Patches were updated for PHP >=7.4 to account for deprecated macros: php/php-src#11678 * All versions of PHP >= 8.0 have been updated to the latest minor versions, necessitating some tweaks to the existing patch lines. **EMSDK Version Locked** * Emsdk is now locked to use version `3.1.43` rather than `latest`. This makes the dockerfile deterministic, as minor version updates to emscripten are not always 100% 1:1 compatible. * Recommend not updating that value without running tests first. A dockerfile is a lot like a lockfile. Versions should be committed. **Dockerfile Re-ordering** * Moved steps that use PHP_VERSION as far down as possible. All previous steps are identical, so a build of all PHP versions can re-use all these layers from cache. Conversely, if a previous layer uses PHP_VERSION, they will not be considered the same and the cache will not apply. Ordering the build in this way should speed things up a bit as now it can skip to step 54 after running those for the first build. * OpenSSL no longer copies `man` page documentation as part of the build process, as this is relatively pointless inside a build container. **Sourcemaps & Debugging** * The directory structure where the final WASM files live has been shuffled a bit to account for sourcemaps. Sourcemaps may be now be built with `npm run recompile:php:node -- --WITH_SOURCEMAPS=yes`. PHP sources will be copied to each version directory, and sourcemaps can be loaded into chrome devtools via a right click on WASM disassembled code > add source map > `file://[ABSOLUTE LOCAL PATH TO .wasm.map FILE]` --------- Co-authored-by: Adam Zieliński <[email protected]>
I've only quickly checked this issue. From what I understand is that Musl has quite an attitude - https://wiki.musl-libc.org/faq#Q:-Do-I-need-to-define-%3Ccode%3E_LARGEFILE64_SOURCE%3C/code%3E-to-get-64bit-%3Ccode%3Eoff_t%3C/code%3E?
I'm always in for following latest standards but having proper portability and I guess we should consider using the We probably could do the "temporary" fix with defining Or maybe we define the Glibc's feature I'm not sure yet how this would work everywhere and how it would affect php-src on some possible 32-bit architectures 🤔 I'll check more later about this. |
FYI Alpine require following patch to build with musl >= 1.2.4 and Alpine edge just upgraded to 1.2.5 |
We have a report of this on Gentoo now: https://bugs.gentoo.org/928072 Do I understand correctly that appending |
FYI Alpinelinux using following patch as workaround https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/php83/fix-lfs64.patch |
This would need to be tested a bit, but from the php-src point of view, another solution would be to integrate the AC_SYS_LARGEFILE and investigate further how it affects existing code base on 32-bit machines. Otherwise, yes. Appending it to CPPFLAGS can be a workaround for specific systems in some cases. On Alpine though this wouldn't be sufficient, because also the fopencookie check should be adjusted accordingly to use the off_t. For example, this would be the more proper way to fix this. Because, for example, on 32-bit AIX systems (although this may be very outdated already and not relevant anymore), a different symbol needs to be defined (the So, something like this:diff --git a/build/php.m4 b/build/php.m4
index be5763c520..7bbee67e00 100644
--- a/build/php.m4
+++ b/build/php.m4
@@ -1183,7 +1183,7 @@ AC_DEFUN([PHP_PWRITE_TEST],[
AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
PHP_DOES_PWRITE_WORK
if test "$ac_cv_pwrite" = "no"; then
- PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
+ PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off_t);])
if test "$ac_cv_pwrite" = "yes"; then
ac_cv_pwrite=64
fi
@@ -1205,7 +1205,7 @@ AC_DEFUN([PHP_PREAD_TEST],[
AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
PHP_DOES_PREAD_WORK
if test "$ac_cv_pread" = "no"; then
- PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
+ PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off_t);])
if test "$ac_cv_pread" = "yes"; then
ac_cv_pread=64
fi
@@ -1353,7 +1353,7 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
struct cookiedata {
- off64_t pos;
+ off_t pos;
};
ssize_t reader(void *cookie, char *buffer, size_t size)
@@ -1362,7 +1362,7 @@ ssize_t writer(void *cookie, const char *buffer, size_t size)
{ return size; }
int closer(void *cookie)
{ return 0; }
-int seeker(void *cookie, off64_t *position, int whence)
+int seeker(void *cookie, off_t *position, int whence)
{ ((struct cookiedata*)cookie)->pos = *position; return 0; }
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
diff --git a/configure.ac b/configure.ac
index 2bf60c434d..837484aaa1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,6 +270,8 @@ if test "$ac_cv_safe_to_define___extensions__" = yes ; then
AC_MSG_RESULT(yes)
fi
+AC_SYS_LARGEFILE
+
dnl Include Zend configurations.
dnl ----------------------------------------------------------------------------
diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c
index 464a465fd3..a77924e970 100644
--- a/ext/zend_test/test.c
+++ b/ext/zend_test/test.c
@@ -1368,12 +1368,9 @@ PHP_ZEND_TEST_API int gh11934b_ffi_var_test_cdata;
/**
* This function allows us to simulate early return of copy_file_range by setting the limit_copy_file_range ini setting.
*/
-#ifdef __MUSL__
-typedef off_t off64_t;
-#endif
-PHP_ZEND_TEST_API ssize_t copy_file_range(int fd_in, off64_t *off_in, int fd_out, off64_t *off_out, size_t len, unsigned int flags)
+PHP_ZEND_TEST_API ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned int flags)
{
- ssize_t (*original_copy_file_range)(int, off64_t *, int, off64_t *, size_t, unsigned int) = dlsym(RTLD_NEXT, "copy_file_range");
+ ssize_t (*original_copy_file_range)(int, off_t *, int, off_t *, size_t, unsigned int) = dlsym(RTLD_NEXT, "copy_file_range");
if (ZT_G(limit_copy_file_range) >= Z_L(0)) {
len = ZT_G(limit_copy_file_range);
}
diff --git a/main/php.h b/main/php.h
index b10ded010d..a07c08c675 100644
--- a/main/php.h
+++ b/main/php.h
@@ -287,11 +287,11 @@ extern char **environ;
#endif /* ifndef PHP_WIN32 */
#ifdef PHP_PWRITE_64
-ssize_t pwrite(int, void *, size_t, off64_t);
+ssize_t pwrite(int, void *, size_t, off_t);
#endif
#ifdef PHP_PREAD_64
-ssize_t pread(int, void *, size_t, off64_t);
+ssize_t pread(int, void *, size_t, off_t);
#endif
BEGIN_EXTERN_C()
diff --git a/main/streams/cast.c b/main/streams/cast.c
index dbeeff7b09..c7ab366e63 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -103,7 +103,7 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz
}
# ifdef COOKIE_SEEKER_USES_OFF64_T
-static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
+static int stream_cookie_seeker(void *cookie, off_t *position, int whence)
{
*position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence); |
Thank you! queued for Alpine&8.3 |
For 8.2/8.3 we may be able to fix the issue without _LARGEFILE64_SOURCE / _FILE_OFFSET_BITS / _LARGE_FILES. In glibc the position parameter is always The On FreeBSD the parameter is also On musl it has always been So it should be safe to use diff --git a/main/streams/cast.c b/main/streams/cast.c
index 3bad65fbac1..8d9f4a9d2d5 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -104,6 +104,9 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz
# ifdef COOKIE_SEEKER_USES_OFF64_T
static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
+# else
+static int stream_cookie_seeker(void *cookie, off_t *position, int whence)
+# endif
{
*position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence);
@@ -113,13 +116,6 @@ static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
}
return 0;
}
-# else
-static int stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
-{
-
- return php_stream_seek((php_stream *)cookie, position, whence);
-}
-# endif
static int stream_cookie_closer(void *cookie)
{ WDYT? |
@arnaud-lb this sounds great to me. I'd rather leave it to you to apply this patch because I don't have such overview nor understanding of the entire php-src C code base yet. Otherwise, this else removed condition was intended for Windows I think. Would it work ok there also? P.S.: It would be even better to not use the Autoconf's AC_SYS_LARGEFILE because it does too many things in some cases. It applies compiler flags, and also affects time types. It's almost a bit overengineered :D |
Full |
@petk are you sure about Windows? I believe this was for old glibcs before this change
|
Thank you! changed patches for Alpinelinux |
I guess it works on Windows then. Nice. About the AC_SYS_LARGEFILE there is another issue with these macros. They define symbols in main/php_config.h file which is not included correctly yet. These symbols should be the first definition before any system header inclusing. So these _LARGEFILE64_SOURCE / _FILE_OFFSET_BITS / _LARGE_FILES wouldn't even be used in php-src on some places. Unless they would be passed to compiler via -D flags. It's better for the time being to not use it yet. |
Thanks, it means that official docker images should remove this flags on next release
|
@andypost thanks for this info. It won't cause issues if they even stay there in this particular case. Because it is specific for the Alpine build. But, I'll recheck it out. |
@petk thank you! yes, I mean only alpine-based images |
Description
After removal of patches alpinelinux/aports@cab9b78 Alpinelinux now fails to compile with following output:
Discussion https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/48728#note_321723
Build fixed by removing check
php-src/main/streams/cast.c
Lines 105 to 122 in 62a9408
PHP Version
PHP 8.1.21
Operating System
Alpinelinux
The text was updated successfully, but these errors were encountered: