How to add linker option to CMake bootstrap?

落爺英雄遲暮 提交于 2019-12-13 05:50:04

问题


I'm building CMake 3.12.4 from the release tarball on AIX. CMake is failing to link on the machine:

ld: 0711-781 ERROR: TOC overflow. TOC size: 65632  Maximum size: 65536

The error is detailed in the IBM technotes at ld: 0711-781 ERROR: TOC overflow. I want to add -bbigtoc linker option for the cmake recipe.

CMake's bootstrap does not appear to accept linker options for LDFLAGS as shown below.

How do I add a linker flag to the bootstrap process?


Here are the options CMake bootstrap accepts:

$ ./bootstrap --help

Usage: ./bootstrap [<options>...] [-- <cmake-options>...]
Options: [defaults in brackets after descriptions]
Configuration:
  --help                  print this message
  --version               only print version information
  --verbose               display more information
  --parallel=n            bootstrap cmake in parallel, where n is
                          number of nodes [1]
  --enable-ccache         Enable ccache when building cmake
  --init=FILE             load FILE as script to populate cache
  --system-libs           use all system-installed third-party libraries
                          (for use only by package maintainers)
  --no-system-libs        use all cmake-provided third-party libraries
                          (default)
  --system-curl           use system-installed curl library
  --no-system-curl        use cmake-provided curl library (default)
  --system-expat          use system-installed expat library
  --no-system-expat       use cmake-provided expat library (default)
  --system-jsoncpp        use system-installed jsoncpp library
  --no-system-jsoncpp     use cmake-provided jsoncpp library (default)
  --system-zlib           use system-installed zlib library
  --no-system-zlib        use cmake-provided zlib library (default)
  --system-bzip2          use system-installed bzip2 library
  --no-system-bzip2       use cmake-provided bzip2 library (default)
  --system-liblzma        use system-installed liblzma library
  --no-system-liblzma     use cmake-provided liblzma library (default)
  --system-libarchive     use system-installed libarchive library
  --no-system-libarchive  use cmake-provided libarchive library (default)
  --system-librhash       use system-installed librhash library
  --no-system-librhash    use cmake-provided librhash library (default)
  --system-libuv          use system-installed libuv library
  --no-system-libuv       use cmake-provided libuv library (default)

  --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
  --no-qt-gui             do not build the Qt-based GUI (default)
  --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt

  --sphinx-info           build Info manual with Sphinx
  --sphinx-man            build man pages with Sphinx
  --sphinx-html           build html help with Sphinx
  --sphinx-qthelp         build qch help with Sphinx
  --sphinx-build=<sb>     use <sb> as the sphinx-build executable
  --sphinx-flags=<flags>  pass <flags> to sphinx-build executable

Directory and file names:
  --prefix=PREFIX         install files in tree rooted at PREFIX
                          [/usr/local]
  --bindir=DIR            install binaries in PREFIX/DIR
                          [bin]
  --datadir=DIR           install data files in PREFIX/DIR
                          [share/cmake-3.12]
  --docdir=DIR            install documentation files in PREFIX/DIR
                          [doc/cmake-3.12]
  --mandir=DIR            install man pages files in PREFIX/DIR/manN
                          [man]
  --xdgdatadir=DIR        install XDG specific files in PREFIX/DIR
                          [share]

Here is the CMake link error:

cmake_build$ make VERBOSE=1
...
[ 91%] Linking CXX executable ../bin/cmake
        cd /home/noloader/cmake_build/Source && /home/noloader/cmake_build/Boots
trap.cmk/cmake -E cmake_link_script CMakeFiles/cmake.dir/link.txt --verbose=1
/usr/bin/g++  -pthread -Wl,-bnoipath -Wl,-brtl -Wl,-bexpall CMakeFiles/cmake.dir
/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o  -o ../bin/cmake -Wl,-blibpath
:/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.1/pthread:/opt/freeware/lib/pt
hread:/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.1:/opt/freeware/lib:/usr/
lib:/lib libCMakeLib.a libCMakeServerLib.a libCMakeLib.a kwsys/libcmsys.a ../Uti
lities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive
.a ../Utilities/cmliblzma/libcmliblzma.a ../Utilities/cmbzip2/libcmbzip2.a ../Ut
ilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/lib/libcmcurl.a ../Utilit
ies/cmzlib/libcmzlib.a -lld ../Utilities/cmjsoncpp/libcmjsoncpp.a ../Utilities/c
mlibuv/libcmlibuv.a -lperfstat ../Utilities/cmlibrhash/libcmlibrhash.a
ld: 0711-781 ERROR: TOC overflow. TOC size: 65632       Maximum size: 65536
collect2: error: ld returned 12 exit status
make: 1254-004 The error code from the last command is 1.

回答1:


Something like this:

export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS='... -Wl,-bbigtoc'

./bootstrap ... --verbose

make VERBOSE=1 all

Also you might want to read this: http://lzsiga.users.sourceforge.net/aix-linking.html#Q0025



来源:https://stackoverflow.com/questions/53472781/how-to-add-linker-option-to-cmake-bootstrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!