Skip to content

Commit

Permalink
Fix github CI
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
  • Loading branch information
PetrShumilov committed Jan 29, 2025
1 parent 42032b9 commit 5261ad3
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ jobs:
- name: Add git safe directory
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"git config --global --add safe.directory ${{env.kphp_root_dir}}"
"git config --global --add safe.directory '*'"

- 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}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=OFF -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
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/Dockerfile.jammy
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ RUN apt update && \
add-apt-repository ppa:deadsnakes/ppa && \
apt update && \
apt install -y --no-install-recommends \
git cmake make g++ lld gperf netcat \
python3.7 python3-pip python3.7-distutils python3.7-dev libpython3.7-dev python3-jsonschema python3-setuptools mysql-server libmysqlclient-dev && \
python3.7 -m pip install pip && python3.7 -m pip install -r /tmp/requirements.txt && \
build-essential devscripts fakeroot git cmake make g++ lld gperf netcat \
python3.7 python3-pip python3.7-distutils python3.7-dev libpython3.7-dev python3-jsonschema python3-setuptools && \
apt install -y --no-install-recommends 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 libnuma-dev unzip \
libldap-dev libkrb5-dev libpq5=14.* postgresql-14 postgresql-server-dev-14 libpq-dev=14.* && \
libzstd-dev libyaml-cpp-dev libnghttp2-dev zlib1g-dev php7.4-dev libnuma-dev unzip && \
# Install MySQL-related and PostgreSQL-related libraries from the Ubuntu 20.04 (Focal Fossa) repository.
# Ubuntu 22.04 has moved to OpenSSL 3.0; however, KPHP relies on OpenSSL 1.1.1.
# Therefore, we use downgraded libraries that are compatible with OpenSSL 1.1.1.
echo "deb https://archive.ubuntu.com/ubuntu focal main universe" >> /etc/apt/sources.list && \
apt update && \
apt install -t focal -y --no-install-recommends --allow-downgrades mysql-server libmysqlclient-dev \
libldap-dev libtinfo6=6.2* ncurses-bin=6.2* libncurses6=6.2* libncursesw6=6.2* libncurses-dev=6.2* libtinfo-dev=6.2* libcom-err2=1.45* comerr-dev=2.1-1.45* libkrb5support0=1.17* libkrb5-3=1.17* libk5crypto3=1.17* libgssapi-krb5-2=1.17* libkrb5-dev=1.17* libpq5=12.* ssl-cert=1.1.* postgresql-common locales=2.35* postgresql-12 libpq-dev=12.* && \
python3.7 -m pip install pip && python3.7 -m pip install -r /tmp/requirements.txt && \
rm -rf /var/lib/apt/lists/*

# set php7.4 as default
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ include(cmake/external-libraries.cmake)
include(cmake/init-compilation-flags.cmake)
include(cmake/popular-common.cmake)

update_git_submodules()
# OpenSSL building
include(${THIRD_PARTY_DIR}/openssl-cmake/openssl.cmake)
include(${THIRD_PARTY_DIR}/curl-cmake/curl.cmake)

# TODO: use FetchContent_Declare instead of include_directories
include_directories(.)
Expand Down
21 changes: 20 additions & 1 deletion cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function(update_git_submodules)

# Update submodules
execute_process(
COMMAND git submodule update --init --recursive
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE update_result
ERROR_QUIET
Expand All @@ -72,3 +72,22 @@ function(update_git_submodules)
message(FATAL_ERROR "Failed to update Git submodules.")
endif()
endfunction()


# Function to initialize and update specific Git submodule
function(update_git_submodule submodule_path)
message(STATUS "Updating Git submodule ${submodule_path} ...")

# Update submodules
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --remote ${submodule_path}
WORKING_DIRECTORY ${BASE_DIR}
RESULT_VARIABLE update_return_code
OUTPUT_VARIABLE update_stdout
ERROR_VARIABLE update_stderr
)

if(NOT update_return_code EQUAL 0)
message(FATAL_ERROR "Failed to update Git submodule ${submodule_path}: ${update_stdout} ${update_stderr}")
endif()
endfunction()
43 changes: 22 additions & 21 deletions compiler/compiler-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void append_3dparty_lib(std::string &ld_flags, const std::string &path_to_3dpart
ld_flags += " " + path_to_3dparty + "lib/lib" + libname + ".a";
}

void append_curl([[maybe_unused]] std::string &cxx_flags, std::string &ld_flags, const std::string &path_to_3dparty) noexcept {
void append_curl([[maybe_unused]] std::string &cxx_flags, std::string &ld_flags, [[maybe_unused]] const std::string &path_to_3dparty) noexcept {
if (!contains_lib(ld_flags, "curl")) {
#if defined(__APPLE__)
ld_flags += " -lcurl";
Expand Down Expand Up @@ -367,7 +367,7 @@ void CompilerSettings::init() {
ld_flags.value_ = extra_ld_flags.get();
append_curl(cxx_default_flags, ld_flags.value_, third_party_path);
append_apple_options(cxx_default_flags, ld_flags.value_);
std::vector<vk::string_view> os_installed_libs{"pcre", "re2", "yaml-cpp", "h3", "z", "zstd", "nghttp2", "kphp-timelib"};
std::vector<vk::string_view> system_installed_static_libs{"pcre", "re2", "yaml-cpp", "h3", "z", "zstd", "nghttp2", "kphp-timelib"};

#ifdef KPHP_TIMELIB_LIB_DIR
ld_flags.value_ += " -L" KPHP_TIMELIB_LIB_DIR;
Expand All @@ -387,46 +387,47 @@ void CompilerSettings::init() {
ld_flags.value_ += " -L /usr/local/lib";
#endif

std::vector<vk::string_view> external_libs{"pthread", "m", "dl"};
std::vector<vk::string_view> system_installed_dynamic_libs{"pthread", "m", "dl"};

#ifdef PDO_DRIVER_MYSQL
#ifdef PDO_LIBS_STATIC_LINKING
os_installed_libs.emplace_back("mysqlclient");
system_installed_static_libs.emplace_back("mysqlclient");
#else
external_libs.emplace_back("mysqlclient");
system_installed_dynamic_libs.emplace_back("mysqlclient");
#endif
#endif

#ifdef PDO_DRIVER_PGSQL
#ifdef PDO_LIBS_STATIC_LINKING
ld_flags.value_ += fmt_format(" -L /usr/lib/postgresql/{}/lib/ ", PDO_DRIVER_PGSQL_VERSION);
os_installed_libs.emplace_back("pq");
os_installed_libs.emplace_back("pgcommon");
os_installed_libs.emplace_back("pgport");
system_installed_static_libs.emplace_back("pq");
system_installed_static_libs.emplace_back("pgcommon");
system_installed_static_libs.emplace_back("pgport");
// following common libraries are required for libpq.a
external_libs.emplace_back("ldap");
external_libs.emplace_back("gssapi_krb5");
system_installed_dynamic_libs.emplace_back("ldap");
system_installed_dynamic_libs.emplace_back("gssapi_krb5");
#else
external_libs.emplace_back("pq");
system_installed_dynamic_libs.emplace_back("pq");
#endif
#endif

append_3dparty_headers(cxx_default_flags, third_party_path, "openssl");
append_3dparty_lib(ld_flags.value_, third_party_path, "ssl");
append_3dparty_lib(ld_flags.value_, third_party_path, "crypto");

#if defined(__APPLE__)
append_if_doesnt_contain(ld_flags.value_, os_installed_libs, "-l");
append_if_doesnt_contain(ld_flags.value_, system_installed_static_libs, "-l");
auto flex_prefix = kphp_src_path.value_ + "objs/flex/lib";
append_if_doesnt_contain(ld_flags.value_, vk::to_array({"vk-flex-data"}), flex_prefix, ".a");
external_libs.emplace_back("iconv");
system_installed_dynamic_libs.emplace_back("iconv");
#else
append_3dparty_lib(ld_flags.value_, third_party_path, "vk-flex-data");
os_installed_libs.emplace_back("numa");
append_if_doesnt_contain(ld_flags.value_, os_installed_libs, "-l:lib", ".a");
external_libs.emplace_back("rt");
system_installed_static_libs.emplace_back("numa");
append_if_doesnt_contain(ld_flags.value_, system_installed_static_libs, "-l:lib", ".a");
system_installed_dynamic_libs.emplace_back("rt");
#endif
append_if_doesnt_contain(ld_flags.value_, external_libs, "-l");

append_3dparty_headers(cxx_default_flags, third_party_path, "openssl");
append_3dparty_lib(ld_flags.value_, third_party_path, "ssl");
append_3dparty_lib(ld_flags.value_, third_party_path, "crypto");

append_if_doesnt_contain(ld_flags.value_, system_installed_dynamic_libs, "-l");
ld_flags.value_ += " -rdynamic";

runtime_headers.value_ = "runtime-headers.h";
Expand Down
5 changes: 4 additions & 1 deletion runtime/runtime.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# CURL Building
include(${THIRD_PARTY_DIR}/curl-cmake/curl.cmake)

prepend(KPHP_RUNTIME_DATETIME_SOURCES datetime/
date_interval.cpp
datetime.cpp
Expand Down Expand Up @@ -158,7 +161,7 @@ target_link_libraries(kphp-full-runtime PUBLIC ${RUNTIME_LIBS})
set_target_properties(kphp-full-runtime PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${OBJS_DIR})

prepare_cross_platform_libs(RUNTIME_LINK_TEST_LIBS pcre nghttp2 kphp-timelib)
set(RUNTIME_LINK_TEST_LIBS vk::flex_data_static CURL::curl OpenSSL::SSL ${NUMA_LIB} ${RUNTIME_LINK_TEST_LIBS} ${EPOLL_SHIM_LIB} ${ICONV_LIB} ${RT_LIB})
set(RUNTIME_LINK_TEST_LIBS vk::flex_data_static CURL::curl OpenSSL::SSL ${NUMA_LIB} ${RUNTIME_LINK_TEST_LIBS} ${EPOLL_SHIM_LIB} ${ICONV_LIB} ${RT_LIB} dl)

if (PDO_DRIVER_MYSQL)
list(APPEND RUNTIME_LINK_TEST_LIBS mysqlclient)
Expand Down
12 changes: 8 additions & 4 deletions third-party/curl-cmake/curl.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
update_git_submodule(third-party/curl)

set(CURL_INSTALL_DIR ${CMAKE_BINARY_DIR}/third-party/curl)
file(MAKE_DIRECTORY ${CURL_INSTALL_DIR})

set(CURL_COMPILE_FLAGS "-Wno-deprecated-declarations")
if(COMPILER_CLANG)
set(CURL_COMPILE_FLAGS "${CURL_COMPILE_FLAGS} -Wno-string-plus-int")
endif()

ExternalProject_Add(
curl
SOURCE_DIR ${THIRD_PARTY_DIR}/curl
Expand All @@ -19,10 +26,7 @@ ExternalProject_Add(
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
-DCMAKE_INSTALL_PREFIX=${CURL_INSTALL_DIR}
-DCMAKE_INSTALL_LIBDIR=${CURL_INSTALL_DIR}/lib/
-DCMAKE_INSTALL_INCLUDEDIR=${CURL_INSTALL_DIR}/include
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
-DCMAKE_C_FLAGS="-Wno-deprecated-declarations"
-DCMAKE_C_FLAGS=${CURL_COMPILE_FLAGS}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
INSTALL_COMMAND
${CMAKE_COMMAND} --install . --config $<CONFIG> &&
Expand Down
2 changes: 2 additions & 0 deletions third-party/openssl-cmake/openssl.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
update_git_submodule(third-party/openssl)

set(OPENSSL_INSTALL_DIR ${CMAKE_BINARY_DIR}/third-party/openssl)
file(MAKE_DIRECTORY ${OPENSSL_INSTALL_DIR})

Expand Down

0 comments on commit 5261ad3

Please sign in to comment.