[cmake-developers] HP-UX and static link flags for C shared libs

Chuck Atkins chuck.atkins at kitware.com
Mon Aug 10 11:30:04 EDT 2015


Regarding branch stage/add-link-search-static-properties-defaults

When working on a recent branch to allow default initialization of the
target properties LINK_SEARCH_(START|END)_STATIC with a corresponding
CMAKE_* variable, I encountered what I believe to be a bug in how the HP-UX
toolchains are getting used.  When merging for testing, the HP-UX
dashboards bombed out:
https://open.cdash.org/viewTest.php?onlyfailed&buildid=3947999 .  The
repeated error is:

[ 17%] Linking C shared library impl/libtestExe2libImp.sl
cc: warning 901: unknown option: `-a': use +help for online documentation.
cc: warning 1913: `default' does not exist or cannot be read
ld: I/O error, file "default": No such file or directory

>From looking in the Platform/HP-UX.cmake file, the cause of this looks to
be:

# Initialize C and CXX link type selection flags.  These flags are# used
when building a shared library, shared module, or executable# that links to
other libraries to select whether to use the static or# shared versions of
the libraries.  *Note that C modules and shared# libs are built using ld
directly so we leave off the "-Wl," portion.*



*foreach(type SHARED_LIBRARY SHARED_MODULE)
set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-a archive")
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-a default")endforeach()*
foreach(type EXE)
  set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-a,archive")
  set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-a,default")
endforeach()
foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
  set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-a,archive")
  set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-a,default")
endforeach()

The comment explains that the linker is used directly for C shared
libraries but for C executables and C++ executables, shared libraries, and
modules, the compiler is used to invoke the linker.  Hence for C shared
libs, -a archive, instead of -Wl,-a archive.  Based of the error message
though, it looks like the C compiler is getting
used as the linker for shared libs and not the linker directly.  So, I ask
you HP-UX devs, which one of the following would be the appropriate fix:

   1. Assume that using the C compiler as the linker is correct so fix the
   documentation and just set the C link flags to use -Wl,-a instead of -a
   2. Assume that the docs in the HP-UX platform file are correct and make
   CMake start using the linker directly for C shared libs
   3. Something else not described by 1 or 2

Thanks for the input

- Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150810/733ad49c/attachment-0001.html>


More information about the cmake-developers mailing list