MantisBT - CMake
View Issue Details
0014803CMake(No Category)public2014-03-11 09:142016-06-10 14:31
Mathieu Malaterre 
Kitware Robot 
normalminorhave not tried
closedmoved 
 
 
0014803: support tcc + rpath
It would be nice to have tcc+rpath working in cmake.

Steps:
cd /tmp
$ cat l.c
int foo() { return 42; }
$ cat a.c
int main() { return foo(); }
$ tcc -shared -o libl.so l.c
$ tcc -o a a.c -Wl,-rpath=/tmp -L/tmp -ll
$ ldd a
    linux-vdso.so.1 => (0x00007fffe4087000)
    libl.so => /tmp/libl.so (0x00007f8ecce68000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8eccab8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8ecce6c000)
$ readelf -d a
Dynamic section at offset 0x484 contains 12 entries:
  Tag Type Name/Value
 0x0000000000000001 (NEEDED) Shared library: [libl.so]
 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
 0x000000000000000f (RPATH) Library rpath: [/tmp]
 0x0000000000000004 (HASH) 0x8048220
 0x0000000000000005 (STRTAB) 0x80481cc
 0x0000000000000006 (SYMTAB) 0x804813c
 0x000000000000000a (STRSZ) 82 (bytes)
 0x000000000000000b (SYMENT) 24 (bytes)
 0x0000000000000007 (RELA) 0x8048250
 0x0000000000000008 (RELASZ) 96 (bytes)
 0x0000000000000009 (RELAENT) 24 (bytes)
 0x0000000000000000 (NULL) 0x0

See:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=663945 [^]

Watch out that tcc requires "-Wl,-rpath=" (not -Wl,-rpath -Wl,<some_search_path>")
No tags attached.
Issue History
2014-03-11 09:14Mathieu MalaterreNew Issue
2014-03-11 09:29Brad KingRelationship addedrelated to 0014802
2014-03-11 09:30Brad KingNote Added: 0035384
2014-03-11 09:52Brad KingRelationship deletedrelated to 0014802
2014-03-11 10:07Mathieu MalaterreNote Added: 0035385
2014-03-11 10:13Brad KingNote Added: 0035386
2016-06-10 14:29Kitware RobotNote Added: 0042506
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035384)
Brad King   
2014-03-11 09:30   
Modules/Platform/Linux-TinyCC-C.cmake needs to be updated with the right flags.
(0035385)
Mathieu Malaterre   
2014-03-11 10:07   
Works for me now:

$ cat /usr/share/cmake-2.8/Modules/Platform/Linux-TinyCC-C.cmake
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ")

set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath=") # -rpath
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath=")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ")
set(CMAKE_EXE_EXPORTS_C_FLAG "-rdynamic")

include(Platform/UnixPaths)
(0035386)
Brad King   
2014-03-11 10:13   
Re 0014803:0035385: Great. Please revise it to be more minimal. Some of the settings at the top are only there to override settings from Linux.cmake, so perhaps they can be simply removed instead of set to empty and then set again.
(0042506)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.