AIX shared libraries

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

AIX shared libraries

Rob Boehne

AIX supports two types of shared libraries, AIX-style, and System 5 (SYSV) compatibility libraries.  CMake is currently set up to exclusively work with SYSV-style (read the ld man pages for -brtl).

To do this I’m attempting to set the commands to override linking shared libraries.  The default setup forces generating an exports list, which also gives me problems because I explicitly provide one (that is then overridden by the generated list, which comes out empty in my case).  The set commands below almost work, one of the problems is that I can’t see any way to pass flags to commands like “/bin/ar”.  Under AIX, tools like ar, nm, etc. have a strict “object file mode” that can be altered with the -X command line argument.  I couldn’t find any place to pass -X64 or -X32 to /bin/ar, and setting CMAKE_AR with a space in it results in CMAKE_AR==”/bin/ar;-X64” which is not what I want.  Adding double quotes fails because they aren’t escaped, so the command ends up being  sent with argv[0]==”/bin/ar -X64” which fails.  Escaping the space like you see below results in the same behavior.   I don’t have any static archives in the project, but I’m pretty sure there would be problems with them.   I want to create the output of the first command to look like the target filename but with a file extension of “so” rather than “a” but I don’t see any way to do that.

 

    elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "AIX")

        if(${CMAKE_CXX_COMPILER_ID} STREQUAL "XL")

            if(CMAKE_SIZEOF_VOID_P MATCHES "8")

                set(CMAKE_AR /bin/ar\ -X64)

            else()

                set(CMAKE_AR /bin/ar\ -X32)

            endif()

            # override the broken commands cmake uses to build shared libs on AIX with XLC

            set(CMAKE_SHARED_LIBRARY_SUFFIX ".a")

            set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

            set(CMAKE_SHARED_LINKER_FLAGS_INIT "")

            set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".so")

            set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-bM:SRE -bnoentry")

            set(CMAKE_CXX_CREATE_SHARED_LIBRARY

                "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>  <SONAME_FLAG><TARGET_SONAME> -o <OBJECT_DIR>/shr.so <OBJECTS> <LINK_LIBRARIES>;<CMAKE_AR> -cru <TARGET> <OBJECT_DIR>/shr.so"

                 )

 

 

 

cid:image002.png@01D3D0E3.DCFE6710

Rob Boehne

Senior Software Architect | Datalogics, Inc.

<a href="tel:(312)%20853-8351">+1.312.853.8351 | [hidden email]

datalogics.com | blogs.datalogics.com

Connect with us: Facebook | Twitter | LinkedIn | YouTube

 

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: AIX shared libraries

Marc CHEVRIER
Hi,

To manage specific flags for ar command, you can rely on rules override (see variable CMAKE_USER_MAKE_RULES_OVERRIDE and CMAKE_USER_MAKE_RULES_OVERRIDE_<LANG>).

I have attached some example I used in the past to manage cleanly 32 and 64 bits builds on AIX.
And to use these files, set variable CMAKE_USER_MAKE_RULES_OVERRIDE_CXX before the project command:
...
set (CMAKE_USER_MAKE_RULES_OVERRIDE_CXX /to/path/${CMAKE_CXX_COMPILER_ID}-CXX-Override.cmake)
project (…)


To create an archive holding the shared object may be the most efficient is to create a script (bash or Make script is OK) to do both actions and override variable CMAKE_CXX_CREATE_SHARED_LIBRARY:
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
                « /to/my/link/script <TARGET> <CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>  <SONAME_FLAG><TARGET_SONAME> -o <OBJECT_DIR>/shr.so <OBJECTS> <LINK_LIBRARIES>)


Le 17 déc. 2018 à 23:07 +0100, Rob Boehne <[hidden email]>, a écrit :

AIX supports two types of shared libraries, AIX-style, and System 5 (SYSV) compatibility libraries.  CMake is currently set up to exclusively work with SYSV-style (read the ld man pages for -brtl).

To do this I’m attempting to set the commands to override linking shared libraries.  The default setup forces generating an exports list, which also gives me problems because I explicitly provide one (that is then overridden by the generated list, which comes out empty in my case).  The set commands below almost work, one of the problems is that I can’t see any way to pass flags to commands like “/bin/ar”.  Under AIX, tools like ar, nm, etc. have a strict “object file mode” that can be altered with the -X command line argument.  I couldn’t find any place to pass -X64 or -X32 to /bin/ar, and setting CMAKE_AR with a space in it results in CMAKE_AR==”/bin/ar;-X64” which is not what I want.  Adding double quotes fails because they aren’t escaped, so the command ends up being  sent with argv[0]==”/bin/ar -X64” which fails.  Escaping the space like you see below results in the same behavior.   I don’t have any static archives in the project, but I’m pretty sure there would be problems with them.   I want to create the output of the first command to look like the target filename but with a file extension of “so” rather than “a” but I don’t see any way to do that.

 

    elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "AIX")

        if(${CMAKE_CXX_COMPILER_ID} STREQUAL "XL")

            if(CMAKE_SIZEOF_VOID_P MATCHES "8")

                set(CMAKE_AR /bin/ar\ -X64)

            else()

                set(CMAKE_AR /bin/ar\ -X32)

            endif()

            # override the broken commands cmake uses to build shared libs on AIX with XLC

            set(CMAKE_SHARED_LIBRARY_SUFFIX ".a")

            set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

            set(CMAKE_SHARED_LINKER_FLAGS_INIT "")

            set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".so")

            set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-bM:SRE -bnoentry")

            set(CMAKE_CXX_CREATE_SHARED_LIBRARY

                "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>  <SONAME_FLAG><TARGET_SONAME> -o <OBJECT_DIR>/shr.so <OBJECTS> <LINK_LIBRARIES>;<CMAKE_AR> -cru <TARGET> <OBJECT_DIR>/shr.so"

                 )

 

 

 

cid:image002.png@01D3D0E3.DCFE6710

Rob Boehne

Senior Software Architect | Datalogics, Inc.

<a href="tel:(312)%20853-8351">+1.312.853.8351 | [hidden email]

datalogics.com | blogs.datalogics.com

Connect with us: Facebook | Twitter | LinkedIn | YouTube

 

 

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

XL-CXX-RulesOverride.cmake (560 bytes) Download Attachment
XL-RulesOverride.cmake (2K) Download Attachment