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

Compiling KPHP from source always fails #1057

Open
henrywood opened this issue Aug 5, 2024 · 8 comments
Open

Compiling KPHP from source always fails #1057

henrywood opened this issue Aug 5, 2024 · 8 comments

Comments

@henrywood
Copy link

Trying to install KPHP from source on a Ubuntu 20.04 where PHP 8.2 is installed is not possible:

# sudo su -
# echo 'deb [arch=amd64] https://artifactory-external.vkpartner.ru/artifactory/kphp focal main' | tee /etc/apt/sources.list.d/vkpartner.list
# apt-get update
# apt install git cmake make g++ gperf python3-minimal python3-jsonschema             curl-kphp-vk libuber-h3-dev kphp-timelib libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev             libzstd-dev libyaml-cpp-dev libnghttp2-dev zlib1g-dev php8.2-dev libmysqlclient-dev libnuma-dev             postgresql postgresql-server-dev-all libpq-dev libldap-dev libkrb5-dev
# git clone https://github.com/VKCOM/kphp.git
# cd kphp
# mkdir build
# cd build
# cmake .. -DDOWNLOAD_MISSING_LIBRARIES=On -DKPHP_TESTS=Off

... (left out for brevity) ...

# make -j$(nproc)

... (left out for brevity) ...

[ 99%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/termformat/termformat.cpp.o
[ 99%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/tl2php/combinator-to-php.cpp.o
[ 99%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/tl2php/constructor-to-php.cpp.o
[100%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/tl2php/function-to-php.cpp.o
[100%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/tl2php/php-classes.cpp.o
[100%] Building CXX object CMakeFiles/kphp2cpp_src.dir/common/tl2php/tl-to-php-classes-converter.cpp.o
[100%] Building CXX object CMakeFiles/kphp2cpp_src.dir/objs/generated/auto/compiler/rewrite-rules/early_opt.cpp.o
[100%] Built target kphp2cpp_src
Scanning dependencies of target kphp2cpp
[100%] Building CXX object CMakeFiles/kphp2cpp.dir/compiler/kphp2cpp.cpp.o
[100%] Linking CXX executable ../objs/bin/kphp2cpp
/usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section.
/usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<wchar_t, 500ul, std::allocator<wchar_t> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm[_ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<unsigned int, 32ul, std::allocator<unsigned int> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm[_ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/kphp2cpp.dir/build.make:508: ../objs/bin/kphp2cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:787: CMakeFiles/kphp2cpp.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

I also tried with same build with php7.4-dev installed and that gives the same result ???

Please help !

@astrophysik
Copy link
Contributor

astrophysik commented Aug 7, 2024

Hello, If you want to build kphp from source, use the steps from here

@henrywood
Copy link
Author

Unfortunately that does not work.

'make' command yields this:

[ 93%] Built target kphp2cpp_src
Scanning dependencies of target unittests-compiler
[ 93%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/_compiler-tests-env.cpp.o
[ 93%] Built target kphp-full-runtime
Scanning dependencies of target kphp2cpp
[ 93%] Building CXX object CMakeFiles/kphp2cpp.dir/compiler/kphp2cpp.cpp.o
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `servercert':
openssl.c:(.text+0x1fa8): undefined reference to `SSL_get1_peer_certificate'
/usr/bin/ld: openssl.c:(.text+0x2a12): undefined reference to `EVP_PKEY_get_id'
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step1':
openssl.c:(.text+0x4aef): undefined reference to `EVP_PKEY_get_id'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-server.dir/build.make:635: unittests-server] Error 1
make[1]: *** [CMakeFiles/Makefile2:147: CMakeFiles/unittests-server.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 94%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/data/performance-inspections-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/confdata-functions-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/confdata-key-maker-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/confdata-predefined-wildcards-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/phpdoc-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/flex-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/typedata-test.cpp.o
[ 95%] Linking CXX executable ../objs/bin/kphp2cpp
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/inter-process-mutex-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/lexer-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/ffi-parser-test.cpp.o
[ 95%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/inter-process-resource-test.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/json-writer-test.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/number-string-comparison.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/kphp-type-traits-test.cpp.o
/usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section.
/usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<wchar_t, 500ul, std::allocator<wchar_t> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm[_ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<unsigned int, 32ul, std::allocator<unsigned int> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm[_ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/kphp2cpp.dir/build.make:508: ../objs/bin/kphp2cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:1038: CMakeFiles/kphp2cpp.dir/all] Error 2
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/msgpack-test.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/memory_resource/details/memory_chunk_list-test.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/memory_resource/details/memory_chunk_tree-test.cpp.o
[ 96%] Building CXX object CMakeFiles/unittests-compiler.dir/tests/cpp/compiler/utils/string-utils-test.cpp.o
[ 97%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/memory_resource/details/memory_ordered_chunk_list-test.cpp.o
[ 97%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/memory_resource/extra-memory-pool-test.cpp.o
[ 97%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/memory_resource/unsynchronized_pool_resource-test.cpp.o
[ 97%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/string-list-test.cpp.o
[ 97%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/string-test.cpp.o
[ 98%] Linking CXX executable unittests-compiler
[ 99%] Building CXX object CMakeFiles/unittests-runtime.dir/tests/cpp/runtime/zstd-test.cpp.o
[ 99%] Linking CXX executable unittests-runtime
/usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section.
/usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<wchar_t, 500ul, std::allocator<wchar_t> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm[_ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<unsigned int, 32ul, std::allocator<unsigned int> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm[_ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-compiler.dir/build.make:600: unittests-compiler] Error 1
make[1]: *** [CMakeFiles/Makefile2:176: CMakeFiles/unittests-compiler.dir/all] Error 2
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `servercert':
openssl.c:(.text+0x1fa8): undefined reference to `SSL_get1_peer_certificate'
/usr/bin/ld: openssl.c:(.text+0x2a12): undefined reference to `EVP_PKEY_get_id'
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step1':
openssl.c:(.text+0x4aef): undefined reference to `EVP_PKEY_get_id'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-runtime.dir/build.make:875: unittests-runtime] Error 1
make[1]: *** [CMakeFiles/Makefile2:211: CMakeFiles/unittests-runtime.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
root@HSLAPTOP-ASUS:/tmp/kphp/build#

(I did
cmake .. -DDOWNLOAD_MISSING_LIBRARIES=On
)
before the make

Please help.

@astrophysik
Copy link
Contributor

Hm, I have never tried DDOWNLOAD_MISSING_LIBRARIES on Ubuntu. Can you turn in off and install libfmt-dev?

@henrywood
Copy link
Author

Now do did:

root@HSLAPTOP-ASUS:/tmp/kphp/build# cmake .. -DDOWNLOAD_MISSING_LIBRARIES=Off
-- GIT_BRANCH="master" ; GIT_COMMIT="08e4a29839860e4283efce775c52fca2360b98d2" ; BUILD_TIMESTAMP="1723019602"
-- CMAKE_INSTALL_PREFIX="/." ; CPACK_PACKAGING_INSTALL_PREFIX="/."
-- PDO_LIBS_STATIC_LINKING="OFF"
-- PDO_DRIVER_MYSQL="OFF"
-- PDO_DRIVER_PGSQL="OFF"
-- KPHP_TESTS="ON"
-- KPHP_CUSTOM_CMAKE="OFF"
-- COMPILE_RUNTIME_LIGHT="OFF"
-- DOWNLOAD_MISSING_LIBRARIES="Off"
-- CMAKE_CXX_STANDARD="17"
-- ADDRESS_SANITIZER="OFF" ; UNDEFINED_SANITIZER="OFF"
-- CMAKE_BUILD_TYPE="ReleaseWithAsserts"
-- /usr/bin/php-config found
-- /usr/bin/php-config7.4 found
-- /usr/bin/php-config8.2 found
-- phpize8.0 not found. You need at least 8.0 version to generate vkext_arginfo.h from stubs
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/kphp/build

Apparently libfmt-dev is already the newest version:

root@HSLAPTOP-ASUS:/tmp/kphp/build# apt-get install libfmt-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libfmt-dev is already the newest version (7.1.3.jammy.2.build.4671).
The following packages were automatically installed and are no longer required:
  apache2 apache2-bin apache2-data javascript-common libaprutil1-dbd-sqlite3 libaprutil1-ldap libc-ares2 libc-client2007e libfwupdplugin1 libjansson4 libjs-bootstrap4 libjs-d3 libjs-jquery libjs-popper.js
  libxmlb1 libxmlrpc-epi0 mlock node-jquery php-deepcopy php-doctrine-instantiator php-file-iterator php-phar-io-version php-phpdocumentor-reflection-common php-phpdocumentor-reflection-docblock
  php-phpdocumentor-type-resolver php-phpspec-prophecy php-text-template php-timer php-token-stream php-webmozart-assert phpunit-code-unit-reverse-lookup phpunit-comparator phpunit-diff phpunit-environment
  phpunit-exporter phpunit-global-state phpunit-object-enumerator phpunit-object-reflector phpunit-recursion-context phpunit-resource-operations phpunit-type phpunit-version python3-cliapp python3-markdown
  python3-packaging python3-pyparsing python3-ttystatus
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 88 not upgraded.
root@HSLAPTOP-ASUS:/tmp/kphp/build# make -j$(nproc)
[  1%] Built target flex_data_static
[  5%] Built target net_src
[  5%] Building CXX object CMakeFiles/popular_common.dir/common/resolver.cpp.o
[  6%] Built target binlog_src
[ 11%] Built target common_src
[ 11%] Built target generate_unicode_utils
[ 18%] Built target kphp_server
[ 18%] Built target prepare_unicode_data
[ 19%] Built target tlo_parsing_src
[ 20%] Built target runtime-core
[ 20%] Built target flex_data_shared
[ 20%] Built target auto_vertices_generation_target
[ 37%] Built target kphp_runtime
[ 38%] Building CXX object CMakeFiles/popular_common.dir/common/precise-time.cpp.o
[ 38%] Built target light_common
[ 38%] Building CXX object CMakeFiles/popular_common.dir/common/cpuid.cpp.o
[ 39%] Built target unicode
[ 39%] Built target tlo_parsing_shared
[ 39%] Built target tlo_parsing_static
[ 39%] Building CXX object CMakeFiles/popular_common.dir/common/crc32.cpp.o
[ 39%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext.cpp.o
[ 39%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext.cpp.o
[ 39%] Building CXX object CMakeFiles/popular_common.dir/common/crc32c.cpp.o
[ 39%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext.cpp.o
[ 70%] Built target kphp2cpp_src
[ 70%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-iconv.cpp.o
[ 71%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-flex.cpp.o
[ 71%] Building CXX object CMakeFiles/popular_common.dir/common/options.cpp.o
[ 71%] Building CXX object CMakeFiles/popular_common.dir/common/secure-bzero.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/crc32_x86_64.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/crc32c_x86_64.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/version-string.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/kernel-version.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/kprintf.cpp.o
[ 72%] Building CXX object CMakeFiles/popular_common.dir/common/rpc-headers.cpp.o
[ 72%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-json.cpp.o
[ 72%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-iconv.cpp.o
[ 72%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-flex.cpp.o
[ 72%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-rpc.cpp.o
[ 72%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-iconv.cpp.o
[ 73%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-flex.cpp.o
[ 73%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-tl-parse.cpp.o
[ 73%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-tl-memcache.cpp.o
[ 74%] Building CXX object CMakeFiles/popular_common.dir/common/parallel/counter.cpp.o
[ 74%] Building CXX object CMakeFiles/popular_common.dir/common/parallel/maximum.cpp.o
[ 74%] Building CXX object CMakeFiles/popular_common.dir/common/parallel/thread-id.cpp.o
[ 74%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-rpc-req-error.cpp.o
[ 74%] Building CXX object CMakeFiles/popular_common.dir/common/parallel/limit-counter.cpp.o
[ 74%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-json.cpp.o
[ 74%] Building CXX object CMakeFiles/popular_common.dir/common/server/limits.cpp.o
[ 75%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-rpc-tl-serialization.cpp.o
[ 75%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-rpc.cpp.o
[ 75%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-json.cpp.o
[ 76%] Building CXX object CMakeFiles/popular_common.dir/common/server/signals.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-errors.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-stats.cpp.o
[ 76%] Building CXX object CMakeFiles/popular_common.dir/common/server/relogin.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext.dir/vkext/vkext-sp.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-rpc.cpp.o
[ 76%] Building CXX object CMakeFiles/popular_common.dir/common/server/crash-dump.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-tl-parse.cpp.o
[ 76%] Building CXX object CMakeFiles/popular_common.dir/common/server/engine-settings.cpp.o
[ 76%] Building CXX object CMakeFiles/vkext.dir/common/crc32.cpp.o
[ 77%] Building CXX object CMakeFiles/vkext.dir/common/crc32_x86_64.cpp.o
[ 77%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-tl-memcache.cpp.o
[ 77%] Building CXX object CMakeFiles/vkext.dir/common/string-processing.cpp.o
[ 77%] Building CXX object CMakeFiles/popular_common.dir/common/stats/buffer.cpp.o
[ 77%] Building CXX object CMakeFiles/popular_common.dir/common/stats/provider.cpp.o
[ 77%] Building CXX object CMakeFiles/vkext.dir/common/unicode/utf8-utils.cpp.o
[ 78%] Building CXX object CMakeFiles/popular_common.dir/common/algorithms/simd-int-to-string.cpp.o
[ 78%] Building CXX object CMakeFiles/vkext.dir/common/cpuid.cpp.o
[ 78%] Building CXX object CMakeFiles/vkext.dir/common/version-string.cpp.o
[ 78%] Building CXX object CMakeFiles/vkext.dir/common/rpc-headers.cpp.o
[ 78%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-rpc-req-error.cpp.o
[ 79%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-rpc-tl-serialization.cpp.o
[ 79%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-errors.cpp.o
[ 79%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-stats.cpp.o
[ 79%] Built target popular_common
[ 80%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-tl-parse.cpp.o
[ 80%] Linking CXX executable unittests-server
[ 80%] Building CXX object CMakeFiles/vkext8.2.dir/vkext/vkext-sp.cpp.o
[ 80%] Building CXX object CMakeFiles/vkext8.2.dir/common/crc32.cpp.o
[ 81%] Linking CXX shared library ../objs/vkext/modules/vkext.so
[ 81%] Building CXX object CMakeFiles/vkext8.2.dir/common/crc32_x86_64.cpp.o
[ 82%] Building CXX object CMakeFiles/vkext8.2.dir/common/string-processing.cpp.o
[ 82%] Built target vkext
[ 83%] Linking CXX executable unittests-compiler
[ 83%] Building CXX object CMakeFiles/vkext8.2.dir/common/unicode/utf8-utils.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-tl-memcache.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext8.2.dir/common/cpuid.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext8.2.dir/common/version-string.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext8.2.dir/common/rpc-headers.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-rpc-req-error.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-rpc-tl-serialization.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-errors.cpp.o
[ 83%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-stats.cpp.o
[ 84%] Building CXX object CMakeFiles/vkext7.4.dir/vkext/vkext-sp.cpp.o
[ 84%] Building CXX object CMakeFiles/vkext7.4.dir/common/crc32.cpp.o
[ 84%] Building CXX object CMakeFiles/vkext7.4.dir/common/crc32_x86_64.cpp.o
[ 84%] Building CXX object CMakeFiles/vkext7.4.dir/common/string-processing.cpp.o
[ 84%] Building CXX object CMakeFiles/vkext7.4.dir/common/unicode/utf8-utils.cpp.o
[ 85%] Building CXX object CMakeFiles/vkext7.4.dir/common/cpuid.cpp.o
[ 85%] Building CXX object CMakeFiles/vkext7.4.dir/common/version-string.cpp.o
[ 85%] Building CXX object CMakeFiles/vkext7.4.dir/common/rpc-headers.cpp.o
[ 85%] Linking CXX executable unittests-runtime
[ 86%] Linking CXX static library ../objs/libkphp-full-runtime.a
[ 86%] Linking CXX executable ../objs/bin/tl2php
[ 86%] Linking CXX executable ../objs/bin/kphp2cpp
[ 86%] Built target kphp-full-runtime
[ 87%] Linking CXX executable unittests-net
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `servercert':
openssl.c:(.text+0x1fa8): undefined reference to `SSL_get1_peer_certificate'
/usr/bin/ld: openssl.c:(.text+0x2a12): undefined reference to `EVP_PKEY_get_id'
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step1':
openssl.c:(.text+0x4aef): undefined reference to `EVP_PKEY_get_id'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-server.dir/build.make:635: unittests-server] Error 1
make[1]: *** [CMakeFiles/Makefile2:147: CMakeFiles/unittests-server.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 89%] Built target tl2php
[ 90%] Linking CXX shared library ../objs/vkext/modules8.2/vkext.so
[ 90%] Built target vkext8.2
[ 90%] Built target unittests-net
[ 90%] Linking CXX shared library ../objs/vkext/modules7.4/vkext.so
[ 90%] Built target vkext7.4
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `servercert':
openssl.c:(.text+0x1fa8): undefined reference to `SSL_get1_peer_certificate'
/usr/bin/ld: openssl.c:(.text+0x2a12): undefined reference to `EVP_PKEY_get_id'
/usr/bin/ld: /opt/curl7600/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step1':
openssl.c:(.text+0x4aef): undefined reference to `EVP_PKEY_get_id'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-runtime.dir/build.make:875: unittests-runtime] Error 1
make[1]: *** [CMakeFiles/Makefile2:211: CMakeFiles/unittests-runtime.dir/all] Error 2
/usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section.
/usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<wchar_t, 500ul, std::allocator<wchar_t> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm[_ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<unsigned int, 32ul, std::allocator<unsigned int> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm[_ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/unittests-compiler.dir/build.make:600: unittests-compiler] Error 1
make[1]: *** [CMakeFiles/Makefile2:176: CMakeFiles/unittests-compiler.dir/all] Error 2
/usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section.
/usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<wchar_t, 500ul, std::allocator<wchar_t> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm[_ZN3fmt2v719basic_memory_bufferIwLm500ESaIwEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /usr/lib/libfmt.a(format.cc.o): in function `fmt::v7::basic_memory_buffer<unsigned int, 32ul, std::allocator<unsigned int> >::grow(unsigned long)':
format.cc:(.text._ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm[_ZN3fmt2v719basic_memory_bufferIjLm32ESaIjEE4growEm]+0x87): undefined reference to `std::__throw_bad_array_new_length()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/kphp2cpp.dir/build.make:508: ../objs/bin/kphp2cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:1038: CMakeFiles/kphp2cpp.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
root@HSLAPTOP-ASUS:/tmp/kphp/build# 

@henrywood
Copy link
Author

I am guessing the troubles have something to do with OpenSSL version ?

@henrywood
Copy link
Author

henrywood commented Aug 7, 2024

By upgrading the Ubuntu 20.04 machine to Ubuntu 22.04, I was able to get KPHP to compile.

root@HSLAPTOP-ASUS:/home/henrik# kphp --version
kphp2cpp compiled at Aug  7 2024 20:49:36 CEST by gcc 11.4.0 64-bit after commit 08e4a29839860e4283efce775c52fca2360b98d2

Also I was successful in compiling this PHP code:

<?php

echo "HELLO".PHP_EOL;

By doing

kphp test.php --mode cli -o ./foo

However, I noticed some differences to the version from VK's repository:

  • When not running the 'foo' program as root I get
henrik@HSLAPTOP-ASUS:~$ ./foo
[55462][2024-08-07 23:03:25.821006 limits.cpp  124] failed to set rlimit for core dump size.	(sent to STDERR)
HELLO
  • If I run the 'foo' program as root like this
henrik@HSLAPTOP-ASUS:~$ sudo ./foo --Xkphp-options -u root
[sudo] password for henrik:
[56037][2024-08-08 01:41:59.779793 relogin.cpp  117] You are running as rootHELLO

You are running as root is sent to STDERR

The version from VK repository did not exhibit this behavior.
(when using --Xkphp-options -u root) nothing would be printed on STDERR ? (if I remember correctly)

Anyway, I felt lucky so I tried to build DEB packages like this:

cpack -D CPACK_COMPONENTS_ALL="KPHP;FLEX;TL_TOOLS" .

Next, I went to a new Ubuntu 22.04 machine wanting to install my debs, so I did:

wget -qO /etc/apt/trusted.gpg.d/vkpartner.asc https://artifactory-external.vkpartner.ru/artifactory/api/gpg/key/public
echo "deb https://artifactory-external.vkpartner.ru/artifactory/kphp jammy main" >> /etc/apt/sources.list

apt-get install -y curl-kphp-vk libuber-h3-dev kphp-timelib libfmt-dev libre2-dev libpcre3-dev libnuma-dev
apt-get install -y libpq-dev
apt-get install -y libmysqlclient-dev
wget   http://archive.ubuntu.com/ubuntu/pool/universe/f/fmtlib/libfmt8_8.1.1+ds1-2_amd64.deb -O /tmp/libfmt8_8.1.1+ds1-2_amd64.deb
dpkg -i /tmp/libfmt8_8.1.1+ds1-2_amd64.deb

dpkg -i vk-flex-data_1.0.1_amd64.deb
dpkg -i kphp_1.0.1_amd64.deb
dpkg -i vk-tl-tools_1.0.1_amd64.deb

Next I made sure PHP 8.2 was installed:

sudo add-apt-repository ppa:ondrej/php
apt-get install php8.2-cli
cp /mnt/c/Users/henry/OneDrive/Skrivebord/vkext.so /usr/lib/php/20220829/
echo "extension=vkext.so" >> /etc/php/8.2/cli/php.ini
update-alternatives --config php 			(Selected PHP 8.2)

root@HSLAPTOP-ASUS:/home/henrik# kphp --version
kphp2cpp compiled at Aug  7 2024 20:49:36 CEST by gcc 11.4.0 64-bit after commit 08e4a29839860e4283efce775c52fca2360b98d2

Next I wanted to check that vkext was there:

php -m | grep vk_extension
vk_extension

As everything looked good I wanted to compile a little program, so I did:

vim test.php

Entered this into the file:

<?php

echo "HELLO".PHP_EOL;

and save the file and exited VIM.

Now trying to compile:

kphp test.php --mode cli -o ./test

Unfortunately, it failed with:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: , gen by compiler-settings.cpp:436
  unknown file:-1

Can't open runtime sha256 file ''


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: , gen by compiler-settings.cpp:442
  unknown file:-1

Can't read runtime sha256 from file ''

I wonder what is wrong ?

I then tried the exact same steps (using my DEBs) on an Ubuntu 24.04 machine
The result, however, was exactly the same.

This means that so far it is absolutely needed to compile KPHP from source on the target machine where KPHP is to be used for it to be able to actually compile some PHP code ???

How can I fix the above error and thus install from my CPACK'ed DEB files ?

Please help !

@henrywood
Copy link
Author

I think the solution is this after installing the DEBs

grep -q "KPHP_PATH=" /etc/environment || echo 'KPHP_PATH="/usr/share/vkontakte/kphp_source/"' | sudo tee -a /etc/environment > /dev/null
export KPHP_PATH="/usr/share/vkontakte/kphp_source/"

@henrywood
Copy link
Author

henrywood commented Aug 8, 2024

So now we just need for

  • [50608][2024-08-08 06:46:37.434451 limits.cpp 124] failed to set rlimit for core dump size to NOT be sent to STDERR when running the compiled binary as non-root

  • You are running as root not to be output to STDERR when using:

<path_to_binary> --Xkphp-options -u root

(Like the KPHP version from the VK repository did.)

However, as previously mentioned, the version after commit 08e4a29 seems to ignore '--Xkphp-options -u root' and outputs the message about rlimit to STDERR ??

So how can we get the "original" behavior back ??

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

No branches or pull requests

2 participants