Skip to content

PGO build fails with xxhash #14551

Closed
Closed

Description

@nisbet-hubbard

Description

The following code:

make prof-gen
…
make prof-clean
make prof-use

Resulted in this output:

/bin/sh /tmp/php-8.3.8/libtool --silent --preserve-dup-deps --tag=CC --mode=compile cc -Iext/hash/ -I/tmp/php-8.3.8/ext/hash/ -I/tmp/ph
p-8.3.8/include -I/tmp/php-8.3.8/main -I/tmp/php-8.3.8 -I/tmp/php-8.3.8/ext/date/lib -I/usr/include/libxml2 -I/usr/include/libpng16 -I/
tmp/php-8.3.8/ext/mbstring/libmbfl -I/tmp/php-8.3.8/ext/mbstring/libmbfl/mbfl -I/tmp/php-8.3.8/TSRM -I/tmp/php-8.3.8/Zend  -D_GNU_SOURC
E  -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-paramete
r -Wno-sign-compare -O2 -march=native -ffp-contract=off -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS -fprofile-use  -Wno
-implicit-fallthrough -I/tmp/php-8.3.8/ext/hash/sha3/generic64lc -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZE
ND_ENABLE_STATIC_TSRMLS_CACHE=1 -I/tmp/php-8.3.8/ext/hash/xxhash -c /tmp/php-8.3.8/ext/hash/hash_xxhash.c -o ext/hash/hash_xxhash.lo  -
MMD -MF ext/hash/hash_xxhash.dep -MT ext/hash/hash_xxhash.lo                                                                           
/tmp/php-8.3.8/ext/hash/hash_xxhash.c: In function ‘PHP_XXH3_128_Copy’:                                                                
/tmp/php-8.3.8/ext/hash/hash_xxhash.c:267:1: warning: ‘/tmp/php-8.3.8/ext/hash/.libs/hash_xxhash.gcda’ profile count data file not foun
d [-Wmissing-profile]                                                                                                                  
  267 | }                                                                                                                              
      | ^                                                                                                                              
make[1]: *** [Makefile:1396: ext/hash/hash_xxhash.lo] Error 1                                                                          
make[1]: Leaving directory '/tmp/php-8.3.8'                                                                                            
make: *** [Makefile:288: prof-use] Error 2

The error doesn’t appear with GCC11.

PHP Version

PHP 8.3.8

Operating System

RHEL 9

Activity

  1. ndossche commented on Jul 5, 2024

    @ndossche
    Member

    I don't really get what the bug/issue is. You're cleaning the profile data with prof-clean, so of course it doesn't find the necessary file?

  2. nisbet-hubbard commented on Jul 6, 2024

    @nisbet-hubbard
    Author

    Oh, the abort wasn't caused by that warning. There's quite a number of these, but they don't affect make. There's a bugzilla ticket that explains why these warnings are there.

    The issue is about compiler incompatibility. I was able to compile just fine with GCC11 (with all those warnings present), but not with GCC13.

  3. ndossche commented on Jul 6, 2024

    @ndossche
    Member

    Can you please post the error that causes the abort?

  4. nisbet-hubbard commented on Jul 6, 2024

    @nisbet-hubbard
    Author

    This is all that the compiler emitted:

    make[1]: *** [Makefile:1396: ext/hash/hash_xxhash.lo] Error 1                                                                          
    make[1]: Leaving directory '/tmp/php-8.3.8'                                                                                            
    make: *** [Makefile:288: prof-use] Error 2

    Although it follows on the heels of the warning, the error apparently has nothing to do with the warning since GCC11 compiled fine despite the warning. And other similar warnings didn't lead to failure in 13.

  5. 14 remaining items

  6. ndossche commented on Jun 9, 2025

    @ndossche
    Member

    Okay, it seems that the issue with PHP_XXH3_128_Init can be fixed by dropping zend_always_inline from _PHP_XXH3_Init as the compiler apparently decides to do different things there, and looking at the code using zend_always_inline there also doesn't make sense in the first place. So that's easy.
    Now on to PHP_XXH3_128_Final...

  7. ndossche commented on Jun 9, 2025

    @ndossche
    Member

    @nisbet-hubbard Please try the following patch (save it as a file and then apply with git apply filename).
    Make sure you first run make clean && make prof-clean.

    diff --git a/ext/hash/hash_xxhash.c b/ext/hash/hash_xxhash.c
    index 203f3c7d2d9..1c1315afd4b 100644
    --- a/ext/hash/hash_xxhash.c
    +++ b/ext/hash/hash_xxhash.c
    @@ -158,7 +158,7 @@ const php_hash_ops php_hash_xxh3_64_ops = {
     typedef XXH_errorcode (*xxh3_reset_with_secret_func_t)(XXH3_state_t*, const void*, size_t);
     typedef XXH_errorcode (*xxh3_reset_with_seed_func_t)(XXH3_state_t*, XXH64_hash_t);
     
    -zend_always_inline static void _PHP_XXH3_Init(PHP_XXH3_64_CTX *ctx, HashTable *args,
    +static void _PHP_XXH3_Init(PHP_XXH3_64_CTX *ctx, HashTable *args,
     		xxh3_reset_with_seed_func_t func_init_seed, xxh3_reset_with_secret_func_t func_init_secret, const char* algo_name)
     {
     	memset(&ctx->s, 0, sizeof ctx->s);
    diff --git a/ext/hash/xxhash/xxhash.h b/ext/hash/xxhash/xxhash.h
    index 097f887be9e..1ab6930a4e1 100644
    --- a/ext/hash/xxhash/xxhash.h
    +++ b/ext/hash/xxhash/xxhash.h
    @@ -931,7 +931,7 @@ XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2);
     
     /*******   Canonical representation   *******/
     typedef struct { unsigned char digest[sizeof(XXH128_hash_t)]; } XXH128_canonical_t;
    -XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash);
    +XXH_PUBLIC_API zend_always_inline void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash);
     XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t* src);
     
     
    @@ -5503,7 +5503,7 @@ XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2)
     
     /*======   Canonical representation   ======*/
     /*! @ingroup xxh3_family */
    -XXH_PUBLIC_API void
    +XXH_PUBLIC_API zend_always_inline void
     XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash)
     {
         XXH_STATIC_ASSERT(sizeof(XXH128_canonical_t) == sizeof(XXH128_hash_t));
    
  8. nisbet-hubbard commented on Jun 9, 2025

    @nisbet-hubbard
    Author

    Works for me. Thank you!

  9. changed the title [-][Makefile:1396: ext/hash/hash_xxhash.lo] Error 1 using GCC13[/-] [+]PGO build fails with xxhash[/+] on Jun 9, 2025
  10. added a commit that references this issue on Jun 9, 2025
    c53c078
  11. linked a pull request that will close this issueFix GH-14551: PGO build fails with xxhash #18814on Jun 9, 2025
  12. added 2 commits that reference this issue on Jun 12, 2025
    afb1c57
    f8e2adf
  13. added a commit that references this issue on Jun 12, 2025
    5740038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions