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

    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

      Attachments

        Activity

          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

          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
          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?

          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?

          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.

          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.
          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.

          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.
          serg Sergei Golubchik added a comment - http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/4360

          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.

          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.

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

          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

            serg Sergei Golubchik
            mikhail Mikhail Gavrilov
            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.