Merge branch 'gh-132/static-libs' into v1.x
authorMichael Wallner <mike@php.net>
Tue, 21 Feb 2023 16:52:49 +0000 (17:52 +0100)
committerMichael Wallner <mike@php.net>
Tue, 21 Feb 2023 16:52:49 +0000 (17:52 +0100)
.github/workflows/cmake-build-ci.gen
.github/workflows/cmake-build-ci.yml
CMake/CheckDebug.cmake
CMake/_Include.cmake
src/libmemcached/sasl.cc

index 9bc92a43e0bf74dc590020b9e72602fa7ffb84e8..f04e5205c9139cee5376a6f54f4d159864da6579 100755 (executable)
@@ -47,7 +47,6 @@ const MAP = [
           'env.CC_VER' => [
             "new"  => "-14",
             "cur"  => "-13",
-            "old"  => "-12"
           ]
         ]
       ]
@@ -82,10 +81,6 @@ const ENV = [
         "CXXFLAGS" => "-stdlib=libc++",
         "INSTALL_CXX" => "libc++-13-dev libc++abi-13-dev"
       ],
-      "old" => [
-        "CXXFLAGS" => "-stdlib=libc++",
-        "INSTALL_CXX" => "libc++-12-dev libc++abi-12-dev"
-      ],
     ]
   ],
   "ubuntu-20.04" => [
@@ -202,7 +197,8 @@ function steps_getdeps($os_vnd) {
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
@@ -329,9 +325,9 @@ env:
 
 jobs:
 
-  # new memcached
-  dbg-new:
-    name: dbg-new (<?=defaults()?>)
+  # coverage
+  dbg-cov:
+    name: dbg-cov (<?=defaults()?>)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
       CMAKE_BUILD_TYPE:   "Debug"
@@ -343,8 +339,8 @@ jobs:
       MEMCACHED_PREFIX:   "/tmp"
       ENABLE_SASL:        "ON"
     steps:
-      - uses: actions/checkout@v2
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+      - uses: actions/checkout@v3
         with:
           repository: memcached/memcached
           path: memcached
@@ -352,7 +348,7 @@ jobs:
 <?php steps("Linux"); ?>
       - uses: codecov/codecov-action@v1.0.13
 
-  # sanitizer build
+  # sanitizer
   sanitizer:
     runs-on: <?=DEF[DEF["os"]]?> #
     strategy:
@@ -364,7 +360,30 @@ jobs:
       VERBOSE:            "ON"
       ENABLE_SANITIZERS:  ${{ matrix.sanitizer }}
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+<?php steps("Linux"); ?>
+
+# memcached
+  memcached:
+    runs-on: <?=DEF[DEF["os"]]?> #
+    continue-on-error: true
+    strategy:
+      matrix:
+        memcached: ['master', '1.6.17', '1.6.9', '1.5.22', '1.5.6']
+    env:
+      CMAKE_BUILD_TYPE:   "Debug"
+      BUILD_TESTING:      "ON"
+      VERBOSE:            "ON"
+      INSTALL_MEMCACHED:  ""
+      MEMCACHED_PREFIX:   "/tmp"
+      ENABLE_SASL:        "ON"
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/checkout@v3
+        with:
+          repository: memcached/memcached
+          path: memcached
+          ref: ${{ matrix.memcached }}
 <?php steps("Linux"); ?>
 
   # mac debug
@@ -394,7 +413,7 @@ jobs:
 <?php env_override("macOS")?>
     continue-on-error: true
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
           fetch-depth: 0
 <?php steps("macOS", false); ?>
@@ -439,7 +458,7 @@ jobs:
       CC_VND: ${{ matrix.cc_vnd }}
       CC_VER: ${{ matrix.cc_ver }}
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
           fetch-depth: 0
 <?php steps("Linux", true); ?>
index e9d411229cfa20e6ce8c7f4014f8055891e9a61b..9abe6a73d48cf2e89696a192883782db3a1acd3a 100644 (file)
@@ -32,9 +32,9 @@ env:
 
 jobs:
 
-  # new memcached
-  dbg-new:
-    name: dbg-new (ubuntu-22.04, gnu, cur)
+  # coverage
+  dbg-cov:
+    name: dbg-cov (ubuntu-22.04, gnu, cur)
     runs-on: ubuntu-22.04 #
     env:
       CMAKE_BUILD_TYPE:   "Debug"
@@ -46,8 +46,8 @@ jobs:
       MEMCACHED_PREFIX:   "/tmp"
       ENABLE_SASL:        "ON"
     steps:
-      - uses: actions/checkout@v2
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+      - uses: actions/checkout@v3
         with:
           repository: memcached/memcached
           path: memcached
@@ -76,7 +76,8 @@ jobs:
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
@@ -121,7 +122,7 @@ jobs:
         run: bash .github/notify-gitter.sh ${{ job.status }}
       - uses: codecov/codecov-action@v1.0.13
 
-  # sanitizer build
+  # sanitizer
   sanitizer:
     runs-on: ubuntu-22.04 #
     strategy:
@@ -133,7 +134,97 @@ jobs:
       VERBOSE:            "ON"
       ENABLE_SANITIZERS:  ${{ matrix.sanitizer }}
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
+      - name: Prepare environment (for cur gnu on ubuntu-22.04)
+        if: (env.OS_VER=='ubuntu-22.04') && (env.CC_VND=='gnu') && (env.CC_VER=='cur')
+        run: |
+          echo CC="gcc-11" >> ${GITHUB_ENV}
+          echo CXX="g++-11" >> ${GITHUB_ENV}
+      - name: Install dependencies (Linux)
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get update -y
+          sudo apt-get install -my \
+            libevent-dev \
+            libsasl2-dev \
+            libtbb-dev \
+            python3-sphinx \
+            ${INSTALL_MEMCACHED} \
+            ${INSTALL_CC} ${INSTALL_CXX}
+          sudo systemctl stop memcached || true
+      - name: Build memcached
+        if: runner.os != 'Windows'
+        run: |
+          if test -d memcached
+          then
+            cd memcached
+            ./autogen.sh
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
+              --prefix=${MEMCACHED_PREFIX} \
+              --enable-sasl \
+              --enable-sasl-pwdb \
+              --disable-coverage \
+              --disable-dependency-tracking \
+              --disable-docs \
+              --disable-extstore \
+              --disable-option-checking \
+              ;
+            make -j2
+            make install
+            cd ..
+            echo MEMCACHED_BINARY="${MEMCACHED_PREFIX}/bin/memcached" >> ${GITHUB_ENV}
+          fi
+      - name: Generate build tree (${{ env.CMAKE_BUILD_TYPE }})
+        run: cmake -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -S . -B build
+      - name: Build all with ${{ env.CXX }} ${{ env.CXXFLAGS }}
+        run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2
+      - name: Test
+        if: env.BUILD_TESTING == 'ON'
+        run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target test
+      - name: Install
+        if: env.BUILD_TESTING == 'ON'
+        run: cmake --install build --config ${{ env.CMAKE_BUILD_TYPE }} --prefix /tmp
+      - name: Failed tests log
+        if: ${{ env.BUILD_TESTING == 'ON' && failure() }}
+        run: cat build/Testing/Temporary/LastTest.log || true
+      - name: Package
+        env:
+          PUSH_ARTIFACTS_ID: ${{ secrets.PUSH_ARTIFACTS_ID }}
+        if: env.PUSH_ARTIFACTS_ID != '' && env.CMAKE_BUILD_TYPE == 'Release' && !(env.OS_VER == 'ubuntu-18.04' && env.CC_VND == 'gnu' && env.CC_VER == 'new  ')
+        run: |
+          cmake -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -S . -B build
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target package
+          cmake -DCPACK_COMPONENT_INSTALL=ON build
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target package
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target push-artifacts
+      - name: Notify Gitter
+        env:
+          GITTER: ${{ secrets.GITTER }}
+        if: (success() || failure()) && env.GITTER != ''
+        run: bash .github/notify-gitter.sh ${{ job.status }}
+
+# memcached
+  memcached:
+    runs-on: ubuntu-22.04 #
+    continue-on-error: true
+    strategy:
+      matrix:
+        memcached: ['master', '1.6.17', '1.6.9', '1.5.22', '1.5.6']
+    env:
+      CMAKE_BUILD_TYPE:   "Debug"
+      BUILD_TESTING:      "ON"
+      VERBOSE:            "ON"
+      INSTALL_MEMCACHED:  ""
+      MEMCACHED_PREFIX:   "/tmp"
+      ENABLE_SASL:        "ON"
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/checkout@v3
+        with:
+          repository: memcached/memcached
+          path: memcached
+          ref: ${{ matrix.memcached }}
       - name: Prepare environment (for cur gnu on ubuntu-22.04)
         if: (env.OS_VER=='ubuntu-22.04') && (env.CC_VND=='gnu') && (env.CC_VER=='cur')
         run: |
@@ -158,7 +249,8 @@ jobs:
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
@@ -232,7 +324,8 @@ jobs:
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
@@ -290,7 +383,7 @@ jobs:
       CC_VER:   cur #
     continue-on-error: true
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
           fetch-depth: 0
       - name: Install dependencies (macOS)
@@ -306,7 +399,8 @@ jobs:
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
@@ -435,7 +529,7 @@ jobs:
       CC_VND: ${{ matrix.cc_vnd }}
       CC_VER: ${{ matrix.cc_ver }}
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
           fetch-depth: 0
       - name: Prepare environment (for new gnu on ubuntu-22.04)
@@ -467,13 +561,6 @@ jobs:
           echo CXX="clang++-13" >> ${GITHUB_ENV}
           echo CXXFLAGS="-stdlib=libc++" >> ${GITHUB_ENV}
           echo INSTALL_CXX="libc++-13-dev libc++abi-13-dev" >> ${GITHUB_ENV}
-      - name: Prepare environment (for old clang on ubuntu-22.04)
-        if: (env.OS_VER=='ubuntu-22.04') && (env.CC_VND=='clang') && (env.CC_VER=='old')
-        run: |
-          echo CC="clang-12" >> ${GITHUB_ENV}
-          echo CXX="clang++-12" >> ${GITHUB_ENV}
-          echo CXXFLAGS="-stdlib=libc++" >> ${GITHUB_ENV}
-          echo INSTALL_CXX="libc++-12-dev libc++abi-12-dev" >> ${GITHUB_ENV}
       - name: Prepare environment (for new gnu on ubuntu-20.04)
         if: (env.OS_VER=='ubuntu-20.04') && (env.CC_VND=='gnu') && (env.CC_VER=='new')
         run: |
@@ -524,7 +611,8 @@ jobs:
           then
             cd memcached
             ./autogen.sh
-            ./configure CFLAGS="-O2 -pipe" \
+            cp configure{,.old} && sed -e 's/-Werror//g' <configure.old >configure
+            ./configure CFLAGS="-O2 -pipe -fcommon" \
               --prefix=${MEMCACHED_PREFIX} \
               --enable-sasl \
               --enable-sasl-pwdb \
index fb188529afed4551c3daa189a65159e1b81405e4..a280d16a0d4edc0591b235a5ffa96e35ce41df41 100644 (file)
@@ -15,7 +15,7 @@ macro(check_sanitizer VAR NAME LIB)
     if(${NAME} IN_LIST ${VAR} OR ${LIB} IN_LIST ${VAR})
         make_have_identifier(${LIB} HAVE)
         cmake_push_check_state(RESET)
-        set(CMAKE_REQUIRED_LIBRARIES ${LIB})
+        set(CMAKE_REQUIRED_LIBRARIES -fsanitize=${NAME})
         check_cxx_compiler_flag(-fsanitize=${NAME} ${HAVE})
         cmake_pop_check_state()
         if(${HAVE})
index 901375d70e7fddd431aa0ccadec5d82c1405bfa6..7466b4cab006a29244b316b50c24ab5d7d642016 100644 (file)
@@ -131,6 +131,11 @@ if(ENABLE_SASL)
     if(HAVE_LIBSASL)
         set(LIBMEMCACHED_WITH_SASL_SUPPORT 1)
         pkgconfig_export(REQUIRES libsasl2)
+        cmake_push_check_state()
+        set(CMAKE_REQUIRED_INCLUDES "${LIBSASL_INCLUDEDIR}")
+        set(CMAKE_REQUIRED_LIBRARIES "${LIBSASL_LIBRARIES}")
+        check_symbol(sasl_client_done sasl/sasl.h)
+        cmake_pop_check_state()
     endif()
 endif()
 
index 21a53de4b10ad7050c91864091a56a71b7562c0b..90f663a1262453deb530dfa4a4637b2d9b900371 100644 (file)
@@ -92,7 +92,11 @@ static memcached_return_t resolve_names(memcached_instance_st &server, char *lad
 extern "C" {
 
 static void sasl_shutdown_function() {
+#if HAVE_SASL_CLIENT_DONE
+  (void) sasl_client_done();
+#else
   sasl_done();
+#endif
 }
 
 static std::atomic<int> sasl_startup_state(SASL_OK);