MantisBT - CMake
View Issue Details
0012605CMakeCMakepublic2011-12-02 09:272012-05-09 15:26
Mathieu Malaterre 
Brad King 
normalfeaturealways
closedfixed 
CMake 2.8.7 
CMake 2.8.7CMake 2.8.7 
0012605: Please add support for tcc/shared libs
tcc and cmake do not work together. It currently fails with:

$ /usr/bin/tcc -shared -Wl,-soname,libopenjpeg.so.1 -o ../bin/libopenjpeg.so.1.99.0 ...

tcc: unsupported linker option '-soname,libopenjpeg.so.1'
make[2]: *** [bin/libopenjpeg.so.1.99.0] Error 1
$ tcc
[...]
Linker options:
  -Ldir add library path 'dir'
  -llib link with dynamic or static library 'lib'
  -shared generate a shared library
  -soname set name for shared library to be used at runtime
  -static static linking
  -rdynamic export all global symbols to dynamic linker
  -r generate (relocatable) object file
No tags attached.
patch 1f49d725+0001-TinyCC-Add-compiler-info-for-shared-libs-on-Linux-12.patch (1,399) 2011-12-02 10:29
https://public.kitware.com/Bug/file/4129/1f49d725%2B0001-TinyCC-Add-compiler-info-for-shared-libs-on-Linux-12.patch
patch 0251-Add-default-compilation-flags-for-TinyCC.patch (1,004) 2011-12-02 11:40
https://public.kitware.com/Bug/file/4130/0251-Add-default-compilation-flags-for-TinyCC.patch
patch 0001-Add-default-compilation-flags-for-TinyCC.patch (822) 2011-12-03 06:24
https://public.kitware.com/Bug/file/4133/0001-Add-default-compilation-flags-for-TinyCC.patch
Issue History
2011-12-02 09:27Mathieu MalaterreNew Issue
2011-12-02 10:02Brad KingNote Added: 0027887
2011-12-02 10:03Mathieu MalaterreNote Added: 0027888
2011-12-02 10:15Brad KingNote Added: 0027889
2011-12-02 10:29Brad KingFile Added: 1f49d725+0001-TinyCC-Add-compiler-info-for-shared-libs-on-Linux-12.patch
2011-12-02 10:31Brad KingNote Added: 0027890
2011-12-02 10:31Brad KingAssigned To => Brad King
2011-12-02 10:31Brad KingStatusnew => assigned
2011-12-02 11:08Mathieu MalaterreNote Added: 0027893
2011-12-02 11:13Mathieu MalaterreNote Added: 0027894
2011-12-02 11:17Mathieu MalaterreNote Added: 0027895
2011-12-02 11:28Brad KingNote Added: 0027896
2011-12-02 11:40Mathieu MalaterreFile Added: 0251-Add-default-compilation-flags-for-TinyCC.patch
2011-12-02 11:40Mathieu MalaterreNote Added: 0027897
2011-12-02 13:07Brad KingNote Added: 0027898
2011-12-03 06:24Mathieu MalaterreNote Added: 0027902
2011-12-03 06:24Mathieu MalaterreFile Added: 0001-Add-default-compilation-flags-for-TinyCC.patch
2011-12-05 09:02Brad KingNote Added: 0027910
2011-12-05 09:02Brad KingStatusassigned => resolved
2011-12-05 09:02Brad KingResolutionopen => fixed
2011-12-16 17:26David ColeFixed in Version => CMake 2.8.7
2011-12-16 17:26David ColeTarget Version => CMake 2.8.7
2012-05-09 15:26David ColeNote Added: 0029450
2012-05-09 15:26David ColeStatusresolved => closed

Notes
(0027887)
Brad King   
2011-12-02 10:02   
Are you referring to the "Tiny C Compiler":

 http://bellard.org/tcc/ [^]

?
(0027888)
Mathieu Malaterre   
2011-12-02 10:03   
Yes, sorry if this was not clear. On debian, simply do:

$ sudo apt-get install tcc
(0027889)
Brad King   
2011-12-02 10:15   
Minimal initial change to recognize the compiler id:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f49d725 [^]
(0027890)
Brad King   
2011-12-02 10:31   
Try the patch 1f49d725+0001-TinyCC-Add-compiler-info-for-shared-libs-on-Linux-12.patch on top of commit 1f49d725. It seems sufficient for the CMake COnly test to build (static lib, shared lib, and exec). However the resulting executable does not run:

COnly$ export LD_LIBRARY_PATH=.
COnly$ ldd ./COnly 
        linux-vdso.so.1 =>  (0x00007ffff9562000)
        libtestc2.so => ./libtestc2.so (0x00007f09f9023000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f09f8c79000)
        /lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f09f9027000)
COnly$ ./COnly 
bash: ./COnly: No such file or directory
(0027893)
Mathieu Malaterre   
2011-12-02 11:08   
Works for me (debian/squeeze),

$ tcc -version
tcc version 0.9.25

$ LD_LIBRARY_PATH=. ./COnly
Foo: Foo 0


$ ldd ./COnly
linux-vdso.so.1 => (0x00007fff60efe000)
    libtestc2.so => not found
    libc.so.6 => /lib/libc.so.6 (0x00007fc04f426000)
    /lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007fc04f7b0000)

$ readelf -d libtestc2.so

Dynamic section at offset 0x464 contains 12 entries:
  Tag Type Name/Value
 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
 0x000000000000000e (SONAME) Library soname: [libtestc2.so]
 0x0000000000000016 (TEXTREL) 0x0
 0x0000000000000004 (HASH) 0x350
 0x0000000000000005 (STRTAB) 0x268
 0x0000000000000006 (SYMTAB) 0xe8
 0x000000000000000a (STRSZ) 231 (bytes)
 0x000000000000000b (SYMENT) 24 (bytes)
 0x0000000000000007 (RELA) 0x3b8
 0x0000000000000008 (RELASZ) 48 (bytes)
 0x0000000000000009 (RELAENT) 24 (bytes)
 0x0000000000000000 (NULL) 0x0

Marking as closed ?
(0027894)
Mathieu Malaterre   
2011-12-02 11:13   
I can build openjpeg fine (in absolutely no time). Thanks !
(0027895)
Mathieu Malaterre   
2011-12-02 11:17   
tcc does support debug info with -g switch:


Debugger options:
  -g generate runtime debug info
  -bt N show N callers in stack traces
(0027896)
Brad King   
2011-12-02 11:28   
Okay, second patch applied:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec636e29 [^]

Please take it from there to add all the other platform information as you need and send a patch with the results.
(0027897)
Mathieu Malaterre   
2011-12-02 11:40   
Uploaded as 0251-Add-default-compilation-flags-for-TinyCC.patch

Thanks
(0027898)
Brad King   
2011-12-02 13:07   
I think this hunk:

+# no optimisation in tcc:
+SET (CMAKE_C_FLAGS_INIT "")
+SET (CMAKE_C_FLAGS_DEBUG_INIT "-g")
+SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG")
+SET (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG")
+SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g")

can go in Modules/Compiler/TinyCC-C.cmake instead because they are not platform-specific flags for the compiler. Please test that and update the patch.
(0027902)
Mathieu Malaterre   
2011-12-03 06:24   
Uploaded as 0001-Add-default-compilation-flags-for-TinyCC.patch
I can still build openjpeg fine.

Thanks
(0027910)
Brad King   
2011-12-05 09:02   
Thanks. I've applied the latest patch from 0012605:0027902:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0efe602c [^]

I'm marking this issue as fixed because basic support has been added. Please post further patches to the developer's list.
(0029450)
David Cole   
2012-05-09 15:26   
Closing resolved issues that have not been updated in more than 4 months.