[cmake-developers] [CMake 0013282]: No way to explicitly specify shared library exported symbols with xlc on AIX

Mantis Bug Tracker mantis at public.kitware.com
Fri Jun 8 10:41:09 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13282 
====================================================================== 
Reported By:                brett.dellegrazie
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13282
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-06-08 10:41 EDT
Last Modified:              2012-06-08 10:41 EDT
====================================================================== 
Summary:                    No way to explicitly specify shared library exported
symbols with xlc on AIX
Description: 
Hi,

The definition for the XLC compiler (modules/Compiler/XL.cmake) on AIX includes
the explicit call to the CMAKE_XL_CreateExportList (IBM's CreateExportList tool)
as follows:

    set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
      "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
      "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS>
<LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS>
<CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp
<CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS>
<LINK_LIBRARIES>"
      )

Note the first line of the script:
${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>

This generates an export file in the objects dir which:
(a) Fails to build if there are no objects, because the file will not exist if
there are no objects. Linking several static libraries together to make a shared
library will cause this. In our case the static libraries are externally
supplied and no source code is available (just headers). There's no way of
creating a shared library version without manually generating an empty
objects.exp file in the OBJECTS_DIR directory.

(b) Prevents the use of any explicit exports file in the general case

Is there any possibility of making this an optional per-target task (such as a
PRE_LINK step) that can be disabled?

Its certainly easy enough to add an explicit exports file to the LINK_FLAGS on a
per-target basis but there's no way of disabling the default export creation
without resorting to replicating the XL.cmake file and modifying the CMake
policy 0017 so cmake picks up the modified version (not maintainable long-term)


Steps to Reproduce: 
1. requires IBM xlc compiler on AIX.

case A: Fails due to missing objects.exp:

PROJECT(test_case_a)
cmake_minimum_required(VERSION 2.8)

# Libraries myA and myB are static, externally supplied with header files
# Doesn't matter if these are C or C++, the same problem occurs with both
# In this case though, assume C libraries for linking purposes
set( myA_SRCS myA.h )
set( myB_SRCS myB.h )

# Static libraries
add_library( myA STATIC IMPORTED )
set_target_properties( myA PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/myA.a )

add_library( myB STATIC IMPORTED )
set_target_properties( myB PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/myB.a )

# Create shared library variant of both
add_library( myC SHARED ${A_SRCS} ${B_SRCS} )
set_target_properties( myC PROPERTIES
    LINKER_LANGUAGE C
    PUBLIC_HEADER "${A_SRCS}" "${B_SRCS}"
    )
target_link_libraries( myC myA myB )


Additional Information: 
A workaround would be to:
1) disable policy CMP0017 
2) Supply our own copy of modules/Compiler/XL.cmake
Removing the entire "if (CMAKE_XL_CreateExportList)" section
This leaves the CMAKE_${lang}_SHARED_LIBRARY_CREATE rule at the default.
3) Supply the explicit export list as a compile / link flag per-target as
appropriate
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-06-08 10:41 brett.dellegrazieNew Issue                                    
======================================================================




More information about the cmake-developers mailing list