Build fails if dtrace support found

Bug #747152 reported by Laurynas Biveinis
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Triaged
High
Unassigned
5.1
Invalid
Undecided
Unassigned
5.5
Triaged
High
Unassigned
5.6
New
Undecided
Unassigned

Bug Description

Steps to reproduce:
make all cmake_debug
cd Percona-Server-debug
make
...
Linking CXX executable bug25714
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x30): undefined reference to `mysql_net__write__start_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x90): undefined reference to `mysql_net__write__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0xf0): undefined reference to `mysql_net__write__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x150): undefined reference to `mysql_net__write__start_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x1b0): undefined reference to `mysql_net__write__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x210): undefined reference to `mysql_net__write__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x270): undefined reference to `mysql_net__write__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x2d0): undefined reference to `mysql_net__read__start_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x330): undefined reference to `mysql_net__read__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x390): undefined reference to `mysql_net__read__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x3f0): undefined reference to `mysql_net__read__done_semaphore'
../libmysql/libmysqlclient.a(net_serv.cc.o):(.probes+0x450): undefined reference to `mysql_net__read__done_semaphore'
collect2: ld returned 1 exit status
make[2]: *** [tests/bug25714] Error 1
make[1]: *** [tests/CMakeFiles/bug25714.dir/all] Error 2
make: *** [all] Error 2

Workaround: add -DENABLE_DTRACE=OFF to cmake options.

Stewart Smith (stewart)
Changed in percona-server:
status: New → Confirmed
Stewart Smith (stewart)
Changed in percona-server:
importance: Undecided → High
importance: High → Medium
status: Confirmed → Triaged
Revision history for this message
Stewart Smith (stewart) wrote :

this happens on current Ubuntu (my desktop) and is in upstream MySQL, not just Percona Server.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Did not find anything related in the upstream bug tracker, adding a TODO note to report it there.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Disappears with systemtap 1.6 (e.g. Ubuntu 12.04). Probably not worth fixing.

Revision history for this message
David Smid (datasmid) wrote :

Observed in Fedora 17 too

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

My comment #3 was wrong and, at some point between 5.5.25 and 5.5.27 the -DENABLE_DTRACE=OFF workaround stopped working:

cmake ../Percona-Server -DENABLE_DTRACE=OFF
...
make
...
[ 16%] Building C object mysys/CMakeFiles/mysys.dir/mf_keycache.c.o
In file included from /home/laurynas/percona/src/percona-server-5.5/Percona-Server/mysys/mf_keycache.c:115:0:
/home/laurynas/percona/src/percona-server-5.5/Percona-Server/include/probes_mysql.h:26:35: fatal error: probes_mysql_nodtrace.h: No such file or directory
compilation terminated.
make[2]: *** [mysys/CMakeFiles/mysys.dir/mf_keycache.c.o] Error 1
make[1]: *** [mysys/CMakeFiles/mysys.dir/all] Error 2
make: *** [all] Error 2

Resetting the triage because it is more severe now.

Revision history for this message
Roel Van de Paar (roel11) wrote :
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Yes, CMakeLists.txt is missing the line for that.

bzr diff
=== modified file 'Percona-Server/CMakeLists.txt'
--- Percona-Server/CMakeLists.txt 2013-02-06 06:10:43 +0000
+++ Percona-Server/CMakeLists.txt 2013-02-18 08:25:32 +0000
@@ -170,6 +170,7 @@
   SET(WITHOUT_DYNAMIC_PLUGINS 1)
 ENDIF()
 OPTION(ENABLED_PROFILING "Enable profiling" ON)
+OPTION(ENABLE_DTRACE "Enable Dtrace profiling" OFF)
 OPTION(CYBOZU "" OFF)
 OPTION(BACKUP_TEST "" OFF)
 OPTION(WITHOUT_SERVER OFF)

should fix it.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

However, if -DENABLE_DTRACE=ON is passed and dtrace is not
present on the system (not systemtap but dtrace itself) then it
fails at much later stage than at cmake stage.

This is because, DTRACE_INSTRUMENT (called by plugin.cmake and
others), calls this

  IF(ENABLE_DTRACE)
    ADD_DEPENDENCIES(${target} gen_dtrace_header)

    IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
      TARGET_LINK_LIBRARIES(${target} ${CMAKE_BINARY_DIR}/probes_mysql.o)
    ENDIF()

However, CHECK_DTRACE() doesn't set ENABLE_DTRACE to OFF if
dtrace is not found, so it fails at link time than at cmake time.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

 === modified file 'Percona-Server/cmake/dtrace.cmake'
 --- Percona-Server/cmake/dtrace.cmake 2012-06-15 01:35:09 +0000
 +++ Percona-Server/cmake/dtrace.cmake 2013-02-18 10:31:03 +0000
 @@ -38,6 +38,8 @@
   IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
       AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
     SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
 + ELSE
 + SET(ENABLE_DTRACE OFF CACHE BOOL "Enable dtrace")
   ENDIF()
   SET(HAVE_DTRACE ${ENABLE_DTRACE})
   IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")

should fix that I believe. (need someone with cmake know-how to check this)

However, this means, that headers for systemtap won't be generated with DTRACE_HEADERS function, though that can be fixed as well. (by moving it earlier) But it is best to have a feature macro for systemtap separately.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

This is patch is consolidation of ones above:

=== modified file 'Percona-Server/CMakeLists.txt'
 --- Percona-Server/CMakeLists.txt 2013-02-06 06:10:43 +0000
 +++ Percona-Server/CMakeLists.txt 2013-02-20 12:53:32 +0000
 @@ -150,6 +150,7 @@
    ENDIF()
  ENDIF()

 +OPTION(ENABLE_DTRACE "Enable Dtrace profiling" OFF)
  # Add macros
  INCLUDE(character_sets)
  INCLUDE(zlib)

 === modified file 'Percona-Server/cmake/dtrace.cmake'
 --- Percona-Server/cmake/dtrace.cmake 2012-06-15 01:35:09 +0000
 +++ Percona-Server/cmake/dtrace.cmake 2013-02-20 13:49:12 +0000
 @@ -38,6 +38,8 @@
   IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
       AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
     SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
 + ELSE()
 + SET(ENABLE_DTRACE OFF CACHE BOOL "Enable dtrace" FORCE)
   ENDIF()
   SET(HAVE_DTRACE ${ENABLE_DTRACE})
   IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")

Note: If systemtap is installed on system (with /usr/bin/dtrace)
present and -DENABLE_DTRACE=ON is passed, it will still fail.
So, atleast the workaround will work.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

With this patch:

 === modified file 'Percona-Server/CMakeLists.txt'
 --- Percona-Server/CMakeLists.txt 2013-02-06 06:10:43 +0000
 +++ Percona-Server/CMakeLists.txt 2013-02-20 12:53:32 +0000
 @@ -150,6 +150,7 @@
    ENDIF()
  ENDIF()

 +OPTION(ENABLE_DTRACE "Enable Dtrace profiling" OFF)
  # Add macros
  INCLUDE(character_sets)
  INCLUDE(zlib)

 === modified file 'Percona-Server/cmake/dtrace.cmake'
 --- Percona-Server/cmake/dtrace.cmake 2012-06-15 01:35:09 +0000
 +++ Percona-Server/cmake/dtrace.cmake 2013-02-20 13:49:12 +0000
 @@ -38,6 +38,8 @@
   IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
       AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
     SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
 + ELSE()
 + SET(ENABLE_DTRACE OFF CACHE BOOL "Enable dtrace" FORCE)
   ENDIF()
   SET(HAVE_DTRACE ${ENABLE_DTRACE})
   IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")

 === modified file 'Percona-Server/plugin/percona-pam-for-mysql/CMakeLists.txt'
 --- Percona-Server/plugin/percona-pam-for-mysql/CMakeLists.txt 2013-01-16 13:23:11 +0000
 +++ Percona-Server/plugin/percona-pam-for-mysql/CMakeLists.txt 2013-02-20 14:36:27 +0000
 @@ -29,6 +29,6 @@
    SET(AUTH_PAM_COMPAT_SOURCES ${AUTH_PAM_COMMON_SOURCES} src/auth_pam_compat.c)
    MYSQL_ADD_PLUGIN(auth_pam ${AUTH_PAM_SOURCES} LINK_LIBRARIES pam MODULE_ONLY)
    MYSQL_ADD_PLUGIN(auth_pam_compat ${AUTH_PAM_COMPAT_SOURCES} LINK_LIBRARIES pam MODULE_ONLY)
 - MYSQL_ADD_PLUGIN(dialog src/dialog.c LINK_LIBRARIES mysqlclient MODULE_ONLY)
 + MYSQL_ADD_PLUGIN(dialog src/dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c MODULE_ONLY)
  ENDIF(HAVE_PAM AND HAVE_GETPWNAM_R AND HAVE_GETGRGID_R)
  ENDIF(WITH_PAM)

it builds even after -DENABLE_DTRACE=ON, it needs to be verified
for correctness later.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Background for previous comment:

The reason it was failing was, (without patching CMakeLists.txt
for percona-pam-for-mysql)

 CMakeFiles/dialog.dir/link.txt:

/usr/bin/cc -fPIC -march=native -Ofast -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -Wall -O3 -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DMY_PTHREAD_FASTMUTEX=1 -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -shared -Wl,-soname,dialog.so -o dialog.so CMakeFiles/dialog.dir/src/dialog.c.o -lpthread ../../probes_mysql.o ../../libservices/libmysqlservices.a ../../libmysql/libmysqlclient.a -lpthread ../../probes_mysql.o -lm -ldl

Note, probes_mysql being present twice.

Also, from CMakeFiles/dialog.dir/build.make:

plugin/percona-pam-for-mysql/dialog.so: plugin/percona-pam-for-mysql/CMakeFiles/dialog.dir/src/dialog.c.o
plugin/percona-pam-for-mysql/dialog.so: plugin/percona-pam-for-mysql/CMakeFiles/dialog.dir/build.make
plugin/percona-pam-for-mysql/dialog.so: probes_mysql.o
plugin/percona-pam-for-mysql/dialog.so: libservices/libmysqlservices.a
plugin/percona-pam-for-mysql/dialog.so: libmysql/libmysqlclient.a
plugin/percona-pam-for-mysql/dialog.so: probes_mysql.o
plugin/percona-pam-for-mysql/dialog.so: plugin/percona-pam-for-mysql/CMakeFiles/dialog.dir/link.txt

Revision history for this message
Roel Van de Paar (roel11) wrote :

I tested Raghu's #11 patch with all (8) possible options/combinations (I checked whether it build or not, but not the resulting build functionality):

-DENABLE_DTRACE=ON/OFF
-DWITH_PAM=ON/OFF
/usr/bin/dtrace present or not

And all build fine, so this patch looks good.

Revision history for this message
Roel Van de Paar (roel11) wrote :

Are 5.1 and 5.6 affected?

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Raghu,

Should this also be fixed upstream (i.e. percona-pam-for-mysql)?

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Yes, I think so, but I will also take a look at upstream tree.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

In the upstream tree, I see

  MYSQL_ADD_PLUGIN(dialog src/dialog.c LINK_LIBRARIES mysqlclient)

compared to

 MYSQL_ADD_PLUGIN(dialog src/dialog.c LINK_LIBRARIES mysqlclient MODULE_ONLY)

Is it because it is a module or something like that in PS?

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Marked invalid for 5.1 since there is no dtrace support in 5.1

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

The previous patch doesn't work because it breaks dialog.so

The problem is similar to described here:

http://www.cmake.org/pipermail/cmake/2011-February/042504.html
https://lists.gnu.org/archive/html/qemu-devel/2011-08/msg02987.html

probes_mysql.so gets introduced twice in the build command line for dialog.so
and needs to be trimmed to once. This is because when it is linked against mysqlclient, the dependencies of mysqlclient also get linked in TARGET_LINK_LIBRARIES which causes duplicate and hence the link failure.

In MariaDB code, they build dialog plugin separately and it is
a bit different (and built differently: there is no COMPONENT
SharedLibraries in plugin.cmake of PS) from dialog plugin in PS.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-472

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.