Bug #58158 LINK_LIBRARIES for MYSQL_ADD_PLUGIN is not added to libmysqld

Submitted: 12 Nov 2010 9:26 Modified: 20 Dec 2010 3:26
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.5.7-rc OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: SEAGULL

[12 Nov 2010 9:26] Magnus Blåudd
Description:
When building 5.5 with ndbcluster, the ndbcluster plugin consists of ha_ndb* source files (which need to be compiled differently for embedded) and libndbclient which contains the NDB API etc.

Defined like this:
 MYSQL_ADD_PLUGIN(ndbcluster ${NDBCLUSTER_SOURCES} STORAGE_ENGINE
    DEFAULT STATIC_ONLY RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ndbclient)

When compiling libmysqld/examples/ the linking stage fails because all of the symbols from ndbclient is missing from libmysqld.

How to repeat:
 MYSQL_ADD_PLUGIN(ndbcluster ${NDBCLUSTER_SOURCES} STORAGE_ENGINE
    DEFAULT STATIC_ONLY RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ndbclient)

Suggested fix:
Merge libndbclient into libmysqld.

Whether it's possible to figure this out automatically or not, I don't know. Maybe it would be possible to detect that libndbclient is part of current build and not a sysystem library and thus add it to libmysqld. Otherwise we might need a STATIC_LINK_LIBRARIES directive to MYSQL_ADD_PLUGIN.

Workaround in storage/ndb/CMakeLists.txt
IF(WITH_EMBEDDED_SERVER)
  # Kludge libndbclient into variable used when creating libmysqld
  SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
     ndbclient CACHE INTERNAL "" FORCE)
ENDIF()
[15 Nov 2010 14:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123910
[15 Nov 2010 16:13] Vladislav Vaintroub
Hi Magnus,
this looks good. However, after some thinking I think we should this still in place.

-  IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES)
-    TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES})
-  ENDIF()

If we remove that, it create a problem for plugins compiled as shared, in the environments where unresolved symbols are not permitted.

For example, I think (did not try yet) that 

cmake .. -DWITH_INNOBASE_STORAGE_ENGINE=0 -DWITH_ZLIB=system on OSX would fail to link OSX, since zlib symbols would be missing when linking ha_innobase.so

For plugins compiled as static, TARGET_LINK_LIBRARIES  is less of a problem but could still be useful for standalone test programs (we have some for myisam and heap).

The only downside of having TARGET_LINK_LIBRARIES is that they could appear couple if times in the linker command line for mysqld, but this is cosmetics.
[16 Nov 2010 9:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123996
[25 Nov 2010 0:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/124953

3141 Vladislav Vaintroub	2010-11-25
      Post-fix for Bug#58158 on Solaris
      
      Problem : The build might fail with 
      make[2]: *** No rule to make target `../sql/z',
      needed by `sql/mysqld_dtrace_all.o'.  Stop.
      if one of plugins would depends on system libz 
      library
      
      Fix: Filter out non-static dependent libraries
      when dtracing static libs
[5 Dec 2010 12:39] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[11 Dec 2010 17:13] Paul DuBois
Bug does not appear in any 5.6.x release.

Setting report to Need Merge pending push to 5.5.x.
[17 Dec 2010 12:51] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:georgi.kodinov@oracle.com-20101217124733-p1ivu6higouawv8l) (version source revid:azundris@sun.com-20101125051437-3pavhs14p7zhks0c) (merge vers: 5.5.8) (pib:24)
[20 Dec 2010 3:26] Paul DuBois
Noted in 5.5.9 changelog.

CMake did not add LINK_LIBRARIES for MYSQL_ADD_PLUGIN for libmysqld.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.064 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.