[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Is there a way to disable adding extra libraries at the end of a link line?
From:       Chuck Atkins <chuck.atkins () kitware ! com>
Date:       2015-12-30 16:22:18
Message-ID: CAOXZzG7a8CjBWuq1ZBHzEpBQMquRp7n6tSMMn5fr4x+5JC5UUA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


The error itself I believe is a side effect of CMake trying to operate
assuming it's using normal Linux, which makes some assumptions regarding
shared runtime libraries for libc, position independent code, etc.  The
default behaviour of the Cray compiler wrappers, however, is to create
fully static executables, which CMake has a bit of difficulty with using
the defaault Linux platform.  This behaviour of the wrappers can be changed
by setting the env var CRAYPE_LINK_TYPE=dynamic, but really the right way
is to use the CrayLinuxEnvironment platform file which puts CMake into
cross-compiling mode for the Cray-specific link environment instead of
generic Linux and tests for static, shared, implicit link and include dirs,
implicit libraries, etc.

- Chuck

On Fri, Dec 18, 2015 at 11:12 AM, JR Cary <cary@txcorp.com> wrote:

> Working on a just delivered Cray I am again challenged by the way that
> CMake adds libraries to the end of the link line that I did not specify.
>
> The Cray requires use of the compiler wrappers.  After adding the
> appropriate libraries (hdf5, z) to my target, the link line is
>
> /opt/cray/craype/2.4.2/bin/CC   -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3
> -DNDEBUG -msse2   CMakeFiles/io.dir/io.cxx.o  -o io
> -L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib  ../libtxio.a
> ../../txstreams/libtxstreams.a
> /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a -Wl,-Bstatic -lz
> -Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a
> -Wl,-Bstatic -lz -Wl,-Bdynamic
> -Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib
>
> and the link fails with
>
> ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
> `/usr/lib/../lib64/libc.a(strcmp.o)' can not be used when making an
> executable; recompile with -fPIE and relink with -pie
>
> Now I believe that Cray has the appropriate libraries in its compiler
> wrapper, because
> if I just link without all the additions:
>
> /opt/cray/craype/2.4.2/bin/CC   -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3
> -DNDEBUG -msse2   CMakeFiles/io.dir/io.cxx.o  -o io
> -L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib  ../libtxio.a
> ../../txstreams/libtxstreams.a
> /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a  -lz
>
> it all just works.
>
> Is there a way to tell cmake not to append
> "-Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a
> -Wl,-Bstatic -lz -Wl,-Bdynamic
> -Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib"
> to the link line and not to insert -Wl,-Bstatic in front of -lz
> ?
>
> Thx....John Cary
>
> --
>
> 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:
> http://public.kitware.com/mailman/listinfo/cmake
>

[Attachment #5 (text/html)]

<div dir="ltr">The error itself I believe is a side effect of CMake trying to operate \
assuming it&#39;s using normal Linux, which makes some assumptions regarding shared \
runtime libraries for libc, position independent code, etc.   The default behaviour \
of the Cray compiler wrappers, however, is to create fully static executables, which \
CMake has a bit of difficulty with using the defaault Linux platform.   This \
behaviour of the wrappers can be changed by setting the env var \
CRAYPE_LINK_TYPE=dynamic, but really the right way is to use the CrayLinuxEnvironment \
platform file which puts CMake into cross-compiling mode for the Cray-specific link \
environment instead of generic Linux and tests for static, shared, implicit link and \
include dirs, implicit libraries, etc.<br><div><div class="gmail_extra"><br \
clear="all"><div><div class="gmail_signature"><div dir="ltr">- \
Chuck<br></div></div></div> <br><div class="gmail_quote">On Fri, Dec 18, 2015 at \
11:12 AM, JR Cary <span dir="ltr">&lt;<a href="mailto:cary@txcorp.com" \
target="_blank">cary@txcorp.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Working on a just delivered Cray I am again challenged by the \
way that<br> CMake adds libraries to the end of the link line that I did not \
specify.<br> <br>
The Cray requires use of the compiler wrappers.   After adding the<br>
appropriate libraries (hdf5, z) to my target, the link line is<br>
<br>
/opt/cray/craype/2.4.2/bin/CC     -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3 -DNDEBUG \
-msse2     CMakeFiles/io.dir/io.cxx.o   -o io \
-L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib   ../libtxio.a \
../../txstreams/libtxstreams.a \
/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a -Wl,-Bstatic -lz \
-Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a -Wl,-Bstatic \
-lz -Wl,-Bdynamic -Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib<br> <br>
and the link fails with<br>
<br>
ld: dynamic STT_GNU_IFUNC symbol `strcmp&#39; with pointer equality in \
`/usr/lib/../lib64/libc.a(strcmp.o)&#39; can not be used when making an executable; \
recompile with -fPIE and relink with -pie<br> <br>
Now I believe that Cray has the appropriate libraries in its compiler wrapper, \
because<br> if I just link without all the additions:<br>
<br>
/opt/cray/craype/2.4.2/bin/CC     -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3 -DNDEBUG \
-msse2     CMakeFiles/io.dir/io.cxx.o   -o io \
-L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib   ../libtxio.a \
../../txstreams/libtxstreams.a \
/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a   -lz<br> <br>
it all just works.<br>
<br>
Is there a way to tell cmake not to append<br>
&quot;-Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a \
-Wl,-Bstatic -lz -Wl,-Bdynamic \
-Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib&quot;<br> to the link line \
and not to insert -Wl,-Bstatic in front of -lz<br> ?<br>
<br>
Thx....John Cary<br>
<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" \
target="_blank">www.kitware.com</a><br> <br>
Please keep messages on-topic and check the CMake FAQ at: <a \
href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" \
target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br> <br>
Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:<br> <br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" \
target="_blank">http://cmake.org/cmake/help/support.html</a><br> CMake Consulting: <a \
href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" \
target="_blank">http://cmake.org/cmake/help/consulting.html</a><br> CMake Training \
Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" \
target="_blank">http://cmake.org/cmake/help/training.html</a><br> <br>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" \
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br> <br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" \
target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br> \
</blockquote></div><br></div></div></div>



-- 

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:
http://public.kitware.com/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic