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

mysql_config produces invalid cflags (was: udf_example.c couldn't compile)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0, 5.5
    • Fix Version/s: 10.0.15, 5.5.41
    • Component/s: Scripts & Clients
    • Labels:
      None
    • Environment:
      Fedora 21

      Description

      [mikhail@localhost udf]$ ls -la
      total 36
      drwxrwxr-x. 1 mikhail mikhail    26 ноя  5 23:02 .
      drwxrwxr-x. 1 mikhail mikhail  5816 ноя  5 22:42 ..
      -rw-r--r--. 1 mikhail mikhail 33593 сен 25 04:29 udf_example.c
      
      [mikhail@localhost udf]$ mysql_config --cflags
      -I/usr/include/mysql -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -fno-delete-null-pointer-checks  -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing
      
      [mikhail@localhost udf]$ gcc $(mysql_config --cflags) -shared -fPIC -o udf_example.so udf_example.c
      cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
      In file included from /usr/include/pthread.h:21:0,
                       from /usr/include/mysql/my_global.h:294,
                       from udf_example.c:128:
      /usr/include/features.h:328:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
       #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
          ^
      cc1: some warnings being treated as errors
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            mikhail Mikhail Gavrilov added a comment -

            If I am manually remove -Werror=format-security parameter compile would be successful

            $ gcc -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -fno-delete-null-pointer-checks -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -shared -fPIC -o udf_example.so udf_example.c

            Show
            mikhail Mikhail Gavrilov added a comment - If I am manually remove -Werror=format-security parameter compile would be successful $ gcc -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -fno-delete-null-pointer-checks -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -shared -fPIC -o udf_example.so udf_example.c
            Hide
            jstanek Jan Stanek added a comment - - edited

            The problem seems to originate in the way the mysql_config script is created during mariadb configuration and how it actually produces the --cflags output.

            When building the mariadb on Fedora, the CFLAGS used in building include '-Wall' and '-Werror=format-security' flags, and the script picks them up and records them correctly. However, when eventually asked for them (by executing it with --cflags option or similar), it does some preprocessing on the recorded values - including removing warning-related flags. The regexp ('-W[-A-Za-z]*') catches (and thus removes) the -Wall options (which "include" -Wformat), but not the -Werror=format-security (which needs -Wformat specified in one way or another).

            Should the mysql_config script also remove the '-Werror=...' and similar options, or should a way be found to leave this flag in place in order to report the build flags as accurately as posible?

            Show
            jstanek Jan Stanek added a comment - - edited The problem seems to originate in the way the mysql_config script is created during mariadb configuration and how it actually produces the --cflags output. When building the mariadb on Fedora, the CFLAGS used in building include '-Wall' and '-Werror=format-security' flags, and the script picks them up and records them correctly. However, when eventually asked for them (by executing it with --cflags option or similar), it does some preprocessing on the recorded values - including removing warning-related flags. The regexp ('-W[-A-Za-z]*') catches (and thus removes) the -Wall options (which "include" -Wformat), but not the -Werror=format-security (which needs -Wformat specified in one way or another). Should the mysql_config script also remove the '-Werror=...' and similar options, or should a way be found to leave this flag in place in order to report the build flags as accurately as posible?
            Hide
            serg Sergei Golubchik added a comment -

            As it already removes all -W... flags, I think it should remove -Werror=... too.

            The purpose of mysql_config is to produce flags that are required for building with libmysqlclient. Consequently, it should not include flags that make the application better, safer, faster, less buggy, more secure or anything.

            Show
            serg Sergei Golubchik added a comment - As it already removes all -W... flags, I think it should remove -Werror=... too. The purpose of mysql_config is to produce flags that are required for building with libmysqlclient. Consequently, it should not include flags that make the application better, safer, faster, less buggy, more secure or anything.
            Hide
            jstanek Jan Stanek added a comment - - edited

            Thanks for clarification. Since you marked this issue as fixed, can I ask for link to the fix on launchpad? Thanks in advance.

            Show
            jstanek Jan Stanek added a comment - - edited Thanks for clarification. Since you marked this issue as fixed, can I ask for link to the fix on launchpad? Thanks in advance.
            Show
            serg Sergei Golubchik added a comment - http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/4360
            Hide
            tntnet Tommi Mäkitalo added a comment -

            Hi,

            I have a problem with another flag in mysql_config --cflags: "-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1". The file can't be found on my system (fedora 21) and hence compiling my mysql client software fails to build. I get:

            g++: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory

            It may well be, that the file can be found in some package but there should be a dependency then.

            Show
            tntnet Tommi Mäkitalo added a comment - Hi, I have a problem with another flag in mysql_config --cflags: "-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1". The file can't be found on my system (fedora 21) and hence compiling my mysql client software fails to build. I get: g++: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory It may well be, that the file can be found in some package but there should be a dependency then.
            Hide
            serg Sergei Golubchik added a comment -

            perhaps you have fedora-built packages? We don't have this flag in our rpm packages, as far as I know.

            Show
            serg Sergei Golubchik added a comment - perhaps you have fedora-built packages? We don't have this flag in our rpm packages, as far as I know.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                mikhail Mikhail Gavrilov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 15 minutes
                  15m