diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 71ee5631b5..d00e901b23 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -18,28 +18,44 @@ jobs: strategy: matrix: include: - - os: buster - compiler: g++ - cpp: 17 - asan: off - ubsan: off + # - os: buster + # compiler: g++ + # cpp: 17 + # asan: off + # ubsan: off + # light_runtime: off - os: focal compiler: clang++ cpp: 17 asan: off ubsan: on + light_runtime: off - os: focal compiler: g++-10 cpp: 20 asan: on ubsan: off + light_runtime: off - os: jammy compiler: g++ cpp: 20 asan: on ubsan: off - - name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}/asan=${{matrix.asan}}/ubsan=${{matrix.ubsan}}" + light_runtime: off + - os: focal + compiler: g++-11 + cpp: 20 + asan: off + ubsan: off + light_runtime: on + - os: focal + compiler: clang++-18 + cpp: 20 + asan: off + ubsan: off + light_runtime: on + + name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}/asan=${{matrix.asan}}/ubsan=${{matrix.ubsan}}/light_runtime=${{matrix.light_runtime}}" steps: - uses: actions/checkout@v3 @@ -81,39 +97,46 @@ jobs: - name: Build all run: docker exec kphp-build-container-${{matrix.os}} bash -c - "cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=ON -S ${{env.kphp_root_dir}} -B ${{env.kphp_build_dir}} && make -C ${{env.kphp_build_dir}} -j$(nproc) all" + "cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCOMPILE_RUNTIME_LIGHT=${{matrix.light_runtime}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=ON -S ${{env.kphp_root_dir}} -B ${{env.kphp_build_dir}} && make -C ${{env.kphp_build_dir}} -j$(nproc) all" - name: Run unit tests run: docker exec kphp-build-container-${{matrix.os}} bash -c "make -C ${{env.kphp_build_dir}} -j$(nproc) test" - name: Compile dummy PHP script + if: matrix.light_runtime == 'off' run: docker exec kphp-build-container-${{matrix.os}} bash -c "cd ${{env.kphp_build_dir}} && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} demo.php && kphp_out/server -o --user kitten" + - name: Compile dummy PHP script + if: matrix.light_runtime == 'on' + run: docker exec kphp-build-container-${{matrix.os}} bash -c + "cd ${{env.kphp_build_dir}} && echo "${{matrix.light_runtime}}" && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --mode k2-component --cxx ${{matrix.compiler}} demo.php" + - name: Polyfills composer install run: docker exec kphp-build-container-${{matrix.os}} bash -c "composer install -d ${{env.kphp_polyfills_dir}}" - name: Run python tests + if: matrix.light_runtime == 'off' id: python_tests continue-on-error: true run: docker exec kphp-build-container-${{matrix.os}} bash -c "chown -R kitten /home && su kitten -c 'GITHUB_ACTIONS=1 KPHP_TESTS_POLYFILLS_REPO=${{env.kphp_polyfills_dir}} KPHP_CXX=${{matrix.compiler}} python3.7 -m pytest --tb=native -n$(nproc) ${{env.kphp_root_dir}}/tests/python/'" - name: Prepare python tests artifacts - if: steps.python_tests.outcome == 'failure' + if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }} run: docker cp kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}/tests/python/_tmp/ ${{runner.temp}} && rm -rf ${{runner.temp}}/_tmp/*/working_dir - name: Upload python tests artifacts uses: actions/upload-artifact@v3 - if: steps.python_tests.outcome == 'failure' + if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }} with: path: ${{runner.temp}}/_tmp/ - name: Fail pipeline if python tests failed - if: steps.python_tests.outcome == 'failure' + if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }} run: exit 1 - name: Remove docker container diff --git a/.github/workflows/Dockerfile.focal b/.github/workflows/Dockerfile.focal index 255e51a82d..c2c002ffe9 100644 --- a/.github/workflows/Dockerfile.focal +++ b/.github/workflows/Dockerfile.focal @@ -6,16 +6,19 @@ COPY tests/python/requirements.txt /tmp/ RUN apt-get update && \ apt-get install -y --no-install-recommends apt-utils ca-certificates gnupg wget pkg-config software-properties-common && \ wget -qO /etc/apt/trusted.gpg.d/vkpartner.asc https://artifactory-external.vkpartner.ru/artifactory/api/gpg/key/public && \ + wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ + add-apt-repository ppa:ubuntu-toolchain-r/test && \ + echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main" >> /etc/apt/sources.list && \ echo "deb https://artifactory-external.vkpartner.ru/artifactory/kphp focal main" >> /etc/apt/sources.list && \ echo "deb http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ add-apt-repository ppa:deadsnakes/ppa && \ apt-get update && \ apt-get install -y --no-install-recommends \ - git cmake make clang g++ g++-10 gperf netcat \ - python3.7 python3-pip python3.7-distutils python3.7-dev libpython3.7-dev python3-jsonschema python3-setuptools mysql-server libmysqlclient-dev && \ + git cmake make clang g++ g++-10 g++-11 clang-18 libclang-rt-18-dev gperf netcat \ + python3.7 python3-pip python3.7-distutils python3.7-dev libpython3.7-dev python3-jsonschema python3-setuptools python3-wheel mysql-server libmysqlclient-dev libc++-dev libc++abi-dev && \ python3.7 -m pip install pip && python3.7 -m pip install -r /tmp/requirements.txt && \ - apt-get install -y --no-install-recommends curl-kphp-vk kphp-timelib libuber-h3-dev libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev \ + apt-get install -y --no-install-recommends curl-kphp-vk=20240315.focal.63.build.50 kphp-timelib libuber-h3-dev libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev \ libzstd-dev libyaml-cpp-dev libnghttp2-dev zlib1g-dev php7.4-dev libldap-dev libkrb5-dev \ postgresql postgresql-server-dev-all libnuma-dev composer unzip && \ rm -rf /var/lib/apt/lists/* diff --git a/cmake/init-compilation-flags.cmake b/cmake/init-compilation-flags.cmake index d76ead6413..56ed20257d 100644 --- a/cmake/init-compilation-flags.cmake +++ b/cmake/init-compilation-flags.cmake @@ -10,7 +10,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang) set(COMPILER_CLANG True) elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU) if (COMPILE_RUNTIME_LIGHT) - check_compiler_version(gcc 10.1.0) + check_compiler_version(gcc 11.4.0) else() check_compiler_version(gcc 8.3.0) endif() @@ -126,6 +126,7 @@ add_compile_options(-fdebug-prefix-map="${CMAKE_BINARY_DIR}=${CMAKE_SOURCE_DIR}" if(COMPILE_RUNTIME_LIGHT) get_directory_property(TRY_COMPILE_COMPILE_OPTIONS COMPILE_OPTIONS) string (REPLACE ";" " " TRY_COMPILE_COMPILE_OPTIONS "${TRY_COMPILE_COMPILE_OPTIONS}") + cmake_print_variables(TRY_COMPILE_COMPILE_OPTIONS) file(WRITE "${PROJECT_BINARY_DIR}/check_coroutine_include.cpp" "#include\n" "int main() {}\n") @@ -134,6 +135,7 @@ if(COMPILE_RUNTIME_LIGHT) "${PROJECT_BINARY_DIR}/tmp" "${PROJECT_BINARY_DIR}/check_coroutine_include.cpp" COMPILE_DEFINITIONS "${TRY_COMPILE_COMPILE_OPTIONS}" + CXX_STANDARD 20 ) if(NOT HAS_COROUTINE) message(FATAL_ERROR "Compiler or libstdc++ does not support coroutines") diff --git a/cmake/popular-common.cmake b/cmake/popular-common.cmake index 41fe692d1e..d95f1bae9b 100644 --- a/cmake/popular-common.cmake +++ b/cmake/popular-common.cmake @@ -45,8 +45,10 @@ vk_add_library(light_common OBJECT ${LIGHT_COMMON_SOURCES}) set_property(TARGET light_common PROPERTY POSITION_INDEPENDENT_CODE ON) if (COMPILE_RUNTIME_LIGHT) - target_compile_options(light_common PUBLIC -stdlib=libc++) - target_link_options(light_common PUBLIC -stdlib=libc++ -static-libstdc++) + if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + target_compile_options(light_common PUBLIC -stdlib=libc++) + target_link_options(light_common PUBLIC -stdlib=libc++ -static-libstdc++) + endif() endif() vk_add_library(popular_common OBJECT ${POPULAR_COMMON_SOURCES} ${LIGHT_COMMON_SOURCES}) diff --git a/common/dl-utils-lite.cpp b/common/dl-utils-lite.cpp index 8648274d6c..8315eaa5b2 100644 --- a/common/dl-utils-lite.cpp +++ b/common/dl-utils-lite.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "common/server/crash-dump.h" #include "common/stats/provider.h" @@ -49,9 +50,9 @@ double dl_time() { } void dl_print_backtrace(void **trace, int trace_size) { - write (2, "\n------- Stack Backtrace -------\n", 33); + std::ignore = write (2, "\n------- Stack Backtrace -------\n", 33); backtrace_symbols_fd (trace, trace_size, 2); - write (2, "-------------------------------\n", 32); + std::ignore = write (2, "-------------------------------\n", 32); } void dl_print_backtrace() { @@ -71,7 +72,7 @@ void dl_print_backtrace_gdb() { name_buf[res] = 0; int child_pid = fork(); if (child_pid < 0) { - write (2, "Can't fork() to run gdb\n", 24); + std::ignore = write (2, "Can't fork() to run gdb\n", 24); _exit (0); } if (!child_pid) { @@ -83,7 +84,7 @@ void dl_print_backtrace_gdb() { waitpid (child_pid, nullptr, 0); } } else { - write (2, "can't get name of executable file to pass to gdb\n", 49); + std::ignore = write (2, "can't get name of executable file to pass to gdb\n", 49); } } diff --git a/runtime-core/runtime-core.cmake b/runtime-core/runtime-core.cmake index ed48cf6bf5..06e00db1bc 100644 --- a/runtime-core/runtime-core.cmake +++ b/runtime-core/runtime-core.cmake @@ -29,4 +29,5 @@ endif() prepend(KPHP_CORE_SRC ${RUNTIME_CORE_DIR}/ "${KPHP_CORE_SRC}") vk_add_library(runtime-core OBJECT ${KPHP_CORE_SRC}) -target_compile_options(runtime-core PUBLIC -fPIC) +set_property(TARGET runtime-core PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_options(runtime-core PUBLIC -fPIC) \ No newline at end of file