crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.34k stars 233 forks source link

Unable to compile using the latest libsodium version #384

Closed mpociot closed 8 months ago

mpociot commented 8 months ago

Command used: /bin/spc build intl,pdo_sqlite,sqlite3,curl,openssl,tokenizer,bcmath,bz2,calendar,dba,ftp,iconv,mysqli,mbstring,mbregex,xml,simplexml,ctype,dom,pdo,filter,session,zlib,fileinfo,pdo_mysql,posix,sockets,shmop,sodium,sysvmsg,sysvsem,sysvshm,gd,zip,gmp,redis,xmlwriter,phar,exif,xmlreader,readline,pcntl,soap,imagick,ffi,password-argon2,pgsql,pdo_pgsql,imap,ldap,xsl --debug --build-cli --build-fpm --with-libs=nghttp2 --no-strip

This issue seems to appear after using the latest libsodium version: https://github.com/crazywhalecc/static-php-cli/blob/main/config/source.json#L339-L347

The error does not occur when using version 1.0.18 of libsodium: https://github.com/crazywhalecc/static-php-cli/blame/3828ba7c7747014e8d45f89c5448d8a913e90bc0/config/source.json#L253-L260

024-03-15T07:06:25.2604120Z duplicate symbol '_argon2_validate_inputs' in:
2024-03-15T07:06:25.2604970Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-argon2-core.o)
2024-03-15T07:06:25.2606630Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(core.o)
2024-03-15T07:06:25.2607300Z duplicate symbol '_argon2_fill_memory_blocks' in:
2024-03-15T07:06:25.2608080Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-argon2-core.o)
2024-03-15T07:06:25.2609070Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(core.o)
2024-03-15T07:06:25.2609800Z duplicate symbol '_argon2_finalize' in:
2024-03-15T07:06:25.2610530Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-argon2-core.o)
2024-03-15T07:06:25.2611620Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(core.o)
2024-03-15T07:06:25.2612220Z duplicate symbol '_argon2_initialize' in:
2024-03-15T07:06:25.2612910Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-argon2-core.o)
2024-03-15T07:06:25.2613820Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(core.o)
2024-03-15T07:06:25.2614400Z duplicate symbol '_blake2b_init_key' in:
2024-03-15T07:06:25.2621310Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2622300Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
2024-03-15T07:06:25.2622930Z duplicate symbol '_blake2b_init' in:
2024-03-15T07:06:25.2623510Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2624410Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
2024-03-15T07:06:25.2625060Z duplicate symbol '_blake2b_init_param' in:
2024-03-15T07:06:25.2625670Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2626600Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
2024-03-15T07:06:25.2627240Z duplicate symbol '_blake2b_final' in:
2024-03-15T07:06:25.2627840Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2628750Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
2024-03-15T07:06:25.2629380Z duplicate symbol '_blake2b_update' in:
2024-03-15T07:06:25.2629960Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2630870Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
2024-03-15T07:06:25.2631480Z duplicate symbol '_blake2b' in:
2024-03-15T07:06:25.2632040Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libargon2.a(blake2b.o)
2024-03-15T07:06:25.2632940Z     /Users/runner/actions-runner/_work/static-php-builder/static-php-builder/buildroot/lib/libsodium.a(libsodium_la-blake2b-ref.o)
crazywhalecc commented 8 months ago

Seems related to patched libargon2 still have conflict on linking symbols. e.g. https://github.com/mpociot/phc-winner-argon2/blob/cde967ff411feb525285dc86efabe22ee7050371/src/core.c#L388

1.19 have renamed some functions: validate_inputs => argon2_validate_inputs, which happens to conflict with the version we have patched.

mpociot commented 8 months ago

Oh okay, well this sounds like we now no longer need a patched version, as we had to rename our functions in argon2 so we don't conflict with libsodium. Might be worth a try.

crazywhalecc commented 8 months ago

Still have conflicts (using P-H-C original branch):

duplicate symbol '_argon2_fill_memory_blocks' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[3](core.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[41](libsodium_la-argon2-core.o)
duplicate symbol '_blake2b_init_key' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
duplicate symbol '_blake2b' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
duplicate symbol '_blake2b_init_param' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
duplicate symbol '_argon2_initialize' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[3](core.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[41](libsodium_la-argon2-core.o)
duplicate symbol '_blake2b_final' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
duplicate symbol '_blake2b_init' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
duplicate symbol '_argon2_validate_inputs' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[3](core.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[41](libsodium_la-argon2-core.o)
duplicate symbol '_argon2_finalize' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[3](core.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[41](libsodium_la-argon2-core.o)
duplicate symbol '_blake2b_update' in:
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libargon2.a[4](blake2b.o)
    /Users/jerry/project/git-project/static-php-cli/buildroot/lib/libsodium.a[26](libsodium_la-blake2b-ref.o)
crazywhalecc commented 8 months ago

If possible, I will thoroughly check the debugging symbol issue in the near future. Linux is also currently incompatible.

crazywhalecc commented 8 months ago

I forked static-php/phc-winner-argon2 and resolved the conflict. CI shows it is working on both linux and macOS. đź‘Ť