Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35040

A std::unique_ptr declaration is incompatible with clang++-20 -stdlib=libc++

Details

    Description

      Clang20 is stricter and fails to compile extra/mariabackup/backup_copy.cc when using libc++ for C++ runtime. Error looks like below

      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/page0page.h:424:23: warning: variable 'page_zip
        424 |   if (page_zip_des_t *page_zip= compressed
            |                       ^
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/extra/mariabackup/backup_copy.cc:47:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/os0file.h:39:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/fsp0types.h:28:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/ut0byte.h:30:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/univ.i:450:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/ut0ut.h:32:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/ostream:179:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__ostream/basic_ostream.h:17:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/shared_ptr.h:32:
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/unique_ptr.h:153:3: error: invalid applicatio
        153 |   _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
            |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/compressed_pair.h:63:58: note: expanded from
         63 |     _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1;                       \
            |                                                          ^~~~~~~~~~~~~~~~~~~
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__config:293:34: note: expanded from macro '_LIBCPP_AL
        293 | #    define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
            |                                  ^~~~~~~~~~~~
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/extra/mariabackup/backup_copy.cc:1645:5: note: in instantiation of templ
       1645 |     ds_ctxt_aria_log_dir_path(nullptr, ds_destroy);
            |     ^
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/extra/mariabackup/backup_copy.cc:47:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/os0file.h:39:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/fsp0types.h:28:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/ut0byte.h:30:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/univ.i:450:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/storage/innobase/include/ut0ut.h:32:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/ostream:179:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__ostream/basic_ostream.h:17:
      In file included from /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/shared_ptr.h:28:
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/compressed_pair.h:59:25: error: invalid appli
         59 |                       : sizeof(_ToPad) - __datasizeof_v<_ToPad>];
            |                         ^~~~~~~~~~~~~~
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/unique_ptr.h:153:3: note: in instantiation of
        153 |   _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
            |   ^
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__memory/compressed_pair.h:66:68: note: expanded from
         66 |     _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _)
            |                                                                    ^
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__config:34:36: note: expanded from macro '_LIBCPP_CON
         34 | #  define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z))
            |                                    ^
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__config:33:34: note: expanded from macro '_LIBCPP_CON
         33 | #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
            |                                  ^
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/recipe-sysroot/usr/include/c++/v1/__config:32:39: note: expanded from macro '_LIBCPP_CON
         32 | #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
            |                                       ^
      <scratch space>:116:1: note: expanded from here
        116 | __padding2_153_
            | ^
      /mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/mariadb/10.11.9/mariadb-10.11.9/extra/mariabackup/backup_copy.cc:1645:5: note: in instantiation of templ
       1645 |     ds_ctxt_aria_log_dir_path(nullptr, ds_destroy);
            |     ^
      1 warning and 2 errors generated.
      make[2]: *** [extra/mariabackup/CMakeFiles/mariadb-backup.dir/build.make:300: extra/mariabackup/CMakeFiles/mariadb-backup.dir/backup_copy.cc.o] Error 1
      make[1]: *** [CMakeFiles/Makefile2:5496: extra/mariabackup/CMakeFiles/mariadb-backup.dir/all] Error 2
      make: *** [Makefile:166: all] Error 2
      

      Attachments

        Activity

          khem KHEM RAJ added a comment -

          this is a potential fix attached above

          khem KHEM RAJ added a comment - this is a potential fix attached above

          Thank you for the report. The lines in the Description appear to be truncated.

          I just tried compiling the current 10.5 development snapshot with a freshly installed compiler from https://apt.llvm.org

          Debian clang version 20.0.0 (++20240929101122+cf30e8e153b5-1~exp1~20240929221253.2370)
          

          and without -stdlib=libc++ the only errors are in another compilation unit, something which I suppose could be fixed in MDEV-34348:

          10.5 95d285fb752dcf0f80045e7a24d9c417d6ffbb1b

          sql/sql_plugin.cc:124:6: error: cannot initialize an array element of type 'plugin_type_init' (aka 'int (*)(void *)') with an lvalue of type 'int (st_plugin_int *)': type mismatch at 1st parameter ('void *' vs 'st_plugin_int *')
            124 |   0, ha_initialize_handlerton, 0, 0,initialize_schema_table,
                |      ^~~~~~~~~~~~~~~~~~~~~~~~
          …
          

          I went on and rebuilt with -stdlib=libc++ as of the following version:

          Source: llvm-toolchain-snapshot
          Version: 1:20~++20240929101122+cf30e8e153b5-1~exp1~20240929221253.2370
          

          That would result in additional errors:

          10.5 95d285fb752dcf0f80045e7a24d9c417d6ffbb1b

          In file included from /mariadb/10.5/extra/mariabackup/backup_copy.cc:44:
          In file included from /mariadb/10.5/storage/innobase/include/os0file.h:39:
          In file included from /mariadb/10.5/storage/innobase/include/fsp0types.h:36:
          In file included from /mariadb/10.5/storage/innobase/include/ut0byte.h:30:
          In file included from /mariadb/10.5/storage/innobase/include/univ.i:569:
          In file included from /mariadb/10.5/storage/innobase/include/ut0ut.h:32:
          In file included from /usr/lib/llvm-20/bin/../include/c++/v1/ostream:179:
          In file included from /usr/lib/llvm-20/bin/../include/c++/v1/__ostream/basic_ostream.h:17:
          In file included from /usr/lib/llvm-20/bin/../include/c++/v1/__memory/shared_ptr.h:32:
          /usr/lib/llvm-20/bin/../include/c++/v1/__memory/unique_ptr.h:147:3: error: invalid application of 'alignof' to a function type
            147 |   _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
                |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          /usr/lib/llvm-20/bin/../include/c++/v1/__memory/compressed_pair.h:63:58: note: expanded from macro '_LIBCPP_COMPRESSED_PAIR'
             63 |     _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1;                       \
                |                                                          ^~~~~~~~~~~~~~~~~~~
          /usr/lib/llvm-20/bin/../include/c++/v1/__config:293:34: note: expanded from macro '_LIBCPP_ALIGNOF'
            293 | #    define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
                |                                  ^~~~~~~~~~~~
          /mariadb/10.5/extra/mariabackup/backup_copy.cc:1855:5: note: in instantiation of template class 'std::unique_ptr<ds_ctxt, void (&)(ds_ctxt *)>' requested here
           1855 |     ds_ctxt_aria_log_dir_path(ds_create(dstdir, DS_TYPE_LOCAL), ds_destroy);
                |     ^
          

          The attachment 0001-Use-a-lambda-function-as-deleter-prototype-in-unique.patch would indeed seem to fix that error. Can you please follow https://mariadb.org/contribute/#contribute-code and file a pull request for this, targeting the 10.5 branch?

          marko Marko Mäkelä added a comment - Thank you for the report. The lines in the Description appear to be truncated. I just tried compiling the current 10.5 development snapshot with a freshly installed compiler from https://apt.llvm.org Debian clang version 20.0.0 (++20240929101122+cf30e8e153b5-1~exp1~20240929221253.2370) and without -stdlib=libc++ the only errors are in another compilation unit, something which I suppose could be fixed in MDEV-34348 : 10.5 95d285fb752dcf0f80045e7a24d9c417d6ffbb1b sql/sql_plugin.cc:124:6: error: cannot initialize an array element of type 'plugin_type_init' (aka 'int (*)(void *)') with an lvalue of type 'int (st_plugin_int *)': type mismatch at 1st parameter ('void *' vs 'st_plugin_int *') 124 | 0, ha_initialize_handlerton, 0, 0,initialize_schema_table, | ^~~~~~~~~~~~~~~~~~~~~~~~ … I went on and rebuilt with -stdlib=libc++ as of the following version: Source: llvm-toolchain-snapshot Version: 1:20~++20240929101122+cf30e8e153b5-1~exp1~20240929221253.2370 That would result in additional errors: 10.5 95d285fb752dcf0f80045e7a24d9c417d6ffbb1b In file included from /mariadb/10.5/extra/mariabackup/backup_copy.cc:44: In file included from /mariadb/10.5/storage/innobase/include/os0file.h:39: In file included from /mariadb/10.5/storage/innobase/include/fsp0types.h:36: In file included from /mariadb/10.5/storage/innobase/include/ut0byte.h:30: In file included from /mariadb/10.5/storage/innobase/include/univ.i:569: In file included from /mariadb/10.5/storage/innobase/include/ut0ut.h:32: In file included from /usr/lib/llvm-20/bin/../include/c++/v1/ostream:179: In file included from /usr/lib/llvm-20/bin/../include/c++/v1/__ostream/basic_ostream.h:17: In file included from /usr/lib/llvm-20/bin/../include/c++/v1/__memory/shared_ptr.h:32: /usr/lib/llvm-20/bin/../include/c++/v1/__memory/unique_ptr.h:147:3: error: invalid application of 'alignof' to a function type 147 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib/llvm-20/bin/../include/c++/v1/__memory/compressed_pair.h:63:58: note: expanded from macro '_LIBCPP_COMPRESSED_PAIR' 63 | _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1; \ | ^~~~~~~~~~~~~~~~~~~ /usr/lib/llvm-20/bin/../include/c++/v1/__config:293:34: note: expanded from macro '_LIBCPP_ALIGNOF' 293 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) | ^~~~~~~~~~~~ /mariadb/10.5/extra/mariabackup/backup_copy.cc:1855:5: note: in instantiation of template class 'std::unique_ptr<ds_ctxt, void (&)(ds_ctxt *)>' requested here 1855 | ds_ctxt_aria_log_dir_path(ds_create(dstdir, DS_TYPE_LOCAL), ds_destroy); | ^ The attachment 0001-Use-a-lambda-function-as-deleter-prototype-in-unique.patch would indeed seem to fix that error. Can you please follow https://mariadb.org/contribute/#contribute-code and file a pull request for this, targeting the 10.5 branch?

          Sorry, the other error that I got was due to an uncommitted change that is related to fixing MDEV-34348.

          marko Marko Mäkelä added a comment - Sorry, the other error that I got was due to an uncommitted change that is related to fixing MDEV-34348 .

          Compilation with GCC 14 would seem to require an additional header:

          #include <functional>
          

          As far as I understand, std::function was introduced in C++11, so it definitely should be usable in our code base.

          marko Marko Mäkelä added a comment - Compilation with GCC 14 would seem to require an additional header: #include <functional> As far as I understand, std::function was introduced in C++11, so it definitely should be usable in our code base.

          People

            marko Marko Mäkelä
            khem KHEM RAJ
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.