Details

    Description

      Building MariaDB server of any version starting from 10.1 fails on MacOS.
      Building failure happens on attempt to link any executable file.
      Building process breaks due to the use of the unsupported -z flag in the linker options.
      In result cmake terminates building with the following output:
      ld: unknown option: -z
      clang: error: linker command failed with exit code 1 (use -v to see invocation)

      Unsupported linker option is added by the following cmake macros

        MY_CHECK_AND_SET_LINKER_FLAG("-Wl,-z,relro,-z,now")

      that was introduced by the commit

      commit 7473e1841c630d86f1873a2a7afacb53955b3f6f (HEAD)
      Author: Daniel Black <daniel@linux.ibm.com>
      Date:   Tue May 5 11:57:20 2020 +1000
       
      check_linker_flag: use for linker flags
       
      -Wl,-z,relro,-z,now are linker flags and should
      be checked as such.
      

      Attachments

        1. CMakeCache.txt
          100 kB
          Dmitry Shulga
        2. CMakeError.log
          258 kB
          Dmitry Shulga
        3. CMakeOutput.log
          659 kB
          Dmitry Shulga

        Issue Links

          Activity

            danblack Daniel Black added a comment -

            Can you attach CMakeCache.txt CMakeFiles/CMakeError.log CMakeFiles/CMakeOutput.log?

            What link options are used cmake --build . --verbose ?

            danblack Daniel Black added a comment - Can you attach CMakeCache.txt CMakeFiles/CMakeError.log CMakeFiles/CMakeOutput.log? What link options are used cmake --build . --verbose ?

            CMAKE_REQUIRED_LINK_OPTIONS was introduced only recently. The check has to be rewritten to work without it

            serg Sergei Golubchik added a comment - CMAKE_REQUIRED_LINK_OPTIONS was introduced only recently. The check has to be rewritten to work without it
            danblack Daniel Black added a comment -

            Yes, 3.14.0.

            Check has been reworked to support all versions.

            Thanks shulga for report, review and testing.

            danblack Daniel Black added a comment - Yes, 3.14.0. Check has been reworked to support all versions. Thanks shulga for report, review and testing.
            danblack Daniel Black added a comment -

            kevg, you where crazy enough to review my original 7473e1841c63 and suggested the CHECK_LINKER_FLAGS in 3.18.0.

            Can you review this fix please?

            danblack Daniel Black added a comment - kevg , you where crazy enough to review my original 7473e1841c63 and suggested the CHECK_LINKER_FLAGS in 3.18.0. Can you review this fix please?
            danblack Daniel Black added a comment -

            https://cmake.org/cmake/help/latest/release/3.14.html#commands is the minimum version based on 'The try_compile() and try_run() commands gained a new LINK_OPTIONS option.'

            cmake-3.11.4 output

             
            Performing C++ SOURCE FILE Test HAVE_LINK_FLAG__Wl__z_relro__z_now succeeded with the following output:
            Change Dir: /Users/shulga/projects/mariadb/server-10.1/build.dir/CMakeFiles/CMakeTmpRun Build Command:"/usr/bin/make" "cmTC_82b27/fast"
            /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_82b27.dir/build.make CMakeFiles/cmTC_
            82b27.dir/build
            Building CXX object CMakeFiles/cmTC_82b27.dir/src.cxx.o
            /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -DHAVE_LINK_FLAG__
            Wl__z_relro__z_now -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
            /MacOSX10.15.sdk   -o CMakeFiles/cmTC_82b27.dir/src.cxx.o -c /Users/shulga/projects/mariadb/server-10.1/build.di
            r/CMakeFiles/CMakeTmp/src.cxx
            Linking CXX executable cmTC_82b27
            /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_82b27.dir/link.txt --verbose=1
            /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -DHAVE_LINK_FLAG__W
            l__z_relro__z_now -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
            MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_82b27.dir/src.cxx.o
            -o cmTC_82b27Source file was:
            int main(void) { return 0; }
            

            So effectively the flag wasn't being tested

            danblack Daniel Black added a comment - https://cmake.org/cmake/help/latest/release/3.14.html#commands is the minimum version based on 'The try_compile() and try_run() commands gained a new LINK_OPTIONS option.' cmake-3.11.4 output   Performing C++ SOURCE FILE Test HAVE_LINK_FLAG__Wl__z_relro__z_now succeeded with the following output: Change Dir: /Users/shulga/projects/mariadb/server-10.1/build.dir/CMakeFiles/CMakeTmpRun Build Command:"/usr/bin/make" "cmTC_82b27/fast" /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_82b27.dir/build.make CMakeFiles/cmTC_ 82b27.dir/build Building CXX object CMakeFiles/cmTC_82b27.dir/src.cxx.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DHAVE_LINK_FLAG__ Wl__z_relro__z_now -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /MacOSX10.15.sdk -o CMakeFiles/cmTC_82b27.dir/src.cxx.o -c /Users/shulga/projects/mariadb/server-10.1/build.di r/CMakeFiles/CMakeTmp/src.cxx Linking CXX executable cmTC_82b27 /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_82b27.dir/link.txt --verbose=1 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DHAVE_LINK_FLAG__W l__z_relro__z_now -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_82b27.dir/src.cxx.o -o cmTC_82b27Source file was: int main(void) { return 0; } So effectively the flag wasn't being tested

            that's way too complex.

            Just add put the flag into CMAKE_REQUIRED_LIBRARIES instead of CMAKE_REQUIRED_LINK_OPTIONS.

            This worked for me both on 2.8.8 and on 3.16.5

            serg Sergei Golubchik added a comment - that's way too complex. Just add put the flag into CMAKE_REQUIRED_LIBRARIES instead of CMAKE_REQUIRED_LINK_OPTIONS . This worked for me both on 2.8.8 and on 3.16.5
            danblack Daniel Black added a comment -

            ok done - bb-10.1-danielblack-MDEV-23887-check_linker_flags-oldcmakesupport repushed

            Works for me on 3.11.4 and 3.17.4

            danblack Daniel Black added a comment - ok done - bb-10.1-danielblack- MDEV-23887 -check_linker_flags-oldcmakesupport repushed Works for me on 3.11.4 and 3.17.4

            People

              danblack Daniel Black
              shulga Dmitry Shulga
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.