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

Error "'asm goto' constructs are not supported yet" on macOS with Xcode 9.4.1

Details

    Description

      I get the following error while trying to build current MariaDB Server 10.6 or 10.7 from GitHub on macOS High Sierra:

      [ 43%] Building C object storage/heap/CMakeFiles/heap.dir/hp_update.c.o
      [ 43%] Building C object storage/heap/CMakeFiles/heap.dir/hp_write.c.o
      [ 43%] Linking CXX static library libheap.a
      [ 43%] Built target heap
      [ 43%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/btr/btr0btr.cc.o
      In file included from /Users/Valerii/git/server/storage/innobase/btr/btr0btr.cc:28:
      In file included from /Users/Valerii/git/server/storage/innobase/include/btr0btr.h:31:
      In file included from /Users/Valerii/git/server/storage/innobase/include/dict0dict.h:32:
      In file included from /Users/Valerii/git/server/storage/innobase/include/dict0mem.h:45:
      In file included from /Users/Valerii/git/server/storage/innobase/include/buf0buf.h:33:
      /Users/Valerii/git/server/storage/innobase/include/fil0fil.h:1497:11: error:
            'asm goto' constructs are not supported yet
        __asm__ goto("lock btsl $31, %0\t\njnc %l1" : : "m" (n_pending)
                ^
      1 error generated.
      make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/btr/btr0btr.cc.o] Error 1
      make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
      make: *** [all] Error 2
      Yuliyas-Air:buildtmp Valerii$
      

      Server was built like this (similar 10.3-105 builds go without such a problem):

      Yuliyas-Air:buildtmp Valerii$ pwd
      /Users/Valerii/git/server/buildtmp
      Yuliyas-Air:buildtmp Valerii$ cmake .. -DCMAKE_INSTALL_PREFIX=/Users/Valerii/dbs/maria10.7 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF -DPLUGIN_TOKUDB=NO -DWITH_SSL=system -DENABLE_DTRACE=1
      

      Some more details about the environment:

      Yuliyas-Air:server Valerii$ git branch
        10.2
        10.3
        10.4
        10.5
        10.6
      * 10.7
        10.8
      Yuliyas-Air:server Valerii$ git log -1
      commit 9f2a6bbe6ba03ca5297cd37b75301d05eb44e044 (HEAD -> 10.7, origin/bb-10.7-MDEV-27316, origin/10.7)
      Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
      Date:   Thu Dec 23 12:50:00 2021 +0530
       
          MDEV-27316 Assertion `!(index)->is_spatial()' failed
       
            This issue is caused by MDEV-24621
          (commit 045757af4c301757ba449269351cc27b1691a7d6).
          InnoDB tries to insert the number of rows into an empty spatial
          index table, but it fails to apply the buffered insert.
          InnoDB should insert into the spatial index directly instead of
          buffering the insert operation.
      Yuliyas-Air:server Valerii$ gcc --version
      Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
      Apple LLVM version 10.0.0 (clang-1000.10.44.4)
      Target: x86_64-apple-darwin17.7.0
      Thread model: posix
      InstalledDir: /Library/Developer/CommandLineTools/usr/bin
      Yuliyas-Air:server Valerii$
      

      Quick check of the source code:

       
      1487 /** Note that operations on the tablespace must stop.
      1488 @return whether the operations were already stopped */
      1489 inline bool fil_space_t::set_stopping_check()
      1490 {
      1491   mysql_mutex_assert_owner(&fil_system.mutex);
      1492 #if defined __clang_major__ && __clang_major__ < 10
      1493   /* Only clang-10 introduced support for asm goto */
      1494   return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING     ;
      1495 #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
      1496   static_assert(STOPPING == 1U << 31, "compatibility");
      1497   __asm__ goto("lock btsl $31, %0\t\njnc %l1" : : "m" (n_pending)
      1498                : "cc", "memory" : not_stopped);
      1499   return true;
      1500 not_stopped:
      1501   return false;
      1502 #elif defined _MSC_VER && (defined _M_IX86 || defined _M_IX64)
      1503   static_assert(STOPPING == 1U << 31, "compatibility");
      1504   return _interlockedbittestandset(reinterpret_cast<volatile long*>
      1505                                    (&n_pending), 31);
      1506 #else
      ...
      

      seems to hint that the check for clang 10+ version is NOT enough for macOS 10.1.3.x and Xcode 9.4.1 case.

      Attachments

        Issue Links

          Activity

            Using lock bts is a mere performance optimization. The std::atomic::fetch_or() does translate into correct but suboptimal code (loop around lock cmpxchg). Is there a more recent version of Apple’s fork of Clang? How could the "Apple clang 10" be distinguished from plain clang?

            marko Marko Mäkelä added a comment - Using lock bts is a mere performance optimization. The std::atomic::fetch_or() does translate into correct but suboptimal code (loop around lock cmpxchg ). Is there a more recent version of Apple’s fork of Clang? How could the "Apple clang 10" be distinguished from plain clang?

            The following primitive patch allows build of today's 10.6 to proceed:

            Yuliyas-Air:server Valerii$ git diff
            diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
            index 8ab28e4d84f..3af40d2b418 100644
            --- a/storage/innobase/include/fil0fil.h
            +++ b/storage/innobase/include/fil0fil.h
            @@ -1545,7 +1545,7 @@ inline void fil_space_t::reacquire()
             inline bool fil_space_t::set_stopping_check()
             {
               mysql_mutex_assert_owner(&fil_system.mutex);
            -#if defined __clang_major__ && __clang_major__ < 10
            +#if (defined __clang_major__ && __clang_major__ < 10) || defined __APPLE_CC__
               /* Only clang-10 introduced support for asm goto */
               return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING;
             #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
            Yuliyas-Air:server Valerii$ git log -1
            commit 21778b8aa88280458f2196aab93044149cf0a18c (HEAD -> 10.6, origin/10.6)
            Merge: 764ca7e6e75 66465914c1a
            Author: Marko M<C3><A4>kel<C3><A4> <marko.makela@mariadb.com>
            Date:   Thu Jan 20 07:39:11 2022 +0200
             
                Merge 10.5 into 10.6
            
            

            valerii Valerii Kravchuk added a comment - The following primitive patch allows build of today's 10.6 to proceed: Yuliyas-Air:server Valerii$ git diff diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 8ab28e4d84f..3af40d2b418 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1545,7 +1545,7 @@ inline void fil_space_t::reacquire() inline bool fil_space_t::set_stopping_check() { mysql_mutex_assert_owner(&fil_system.mutex); -#if defined __clang_major__ && __clang_major__ < 10 +#if (defined __clang_major__ && __clang_major__ < 10) || defined __APPLE_CC__ /* Only clang-10 introduced support for asm goto */ return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING; #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) Yuliyas-Air:server Valerii$ git log -1 commit 21778b8aa88280458f2196aab93044149cf0a18c (HEAD -> 10.6, origin/10.6) Merge: 764ca7e6e75 66465914c1a Author: Marko M<C3><A4>kel<C3><A4> <marko.makela@mariadb.com> Date: Thu Jan 20 07:39:11 2022 +0200   Merge 10.5 into 10.6

            People

              marko Marko Mäkelä
              valerii Valerii Kravchuk
              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.