[cmake-developers] [CMake 0014877]: TI toolchain should not call ranlib

Mantis Bug Tracker mantis at public.kitware.com
Tue Apr 15 09:48:33 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14877 
====================================================================== 
Reported By:                raspy
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14877
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-04-15 09:48 EDT
Last Modified:              2014-04-15 09:48 EDT
====================================================================== 
Summary:                    TI toolchain should not call ranlib
Description: 
Currently building static libraries with TI toolchain ends with ranlib call
which apparently does something with the libraries because the linker complains:

...
Linking C static library libfoo.a
/path/to/CMake/2.8.12.2/linux/i386/bin/cmake -P
CMakeFiles/foo.dir/cmake_clean_target.cmake
/path/to/CMake/2.8.12.2/linux/i386/bin/cmake -E cmake_link_script
CMakeFiles/foo.dir/link.txt --verbose=1
/path/to/ar6x -r libfoo.a CMakeFiles/foo.dir/src/foo.c.obj
  ==>  new archive 'libfoo.a'
  ==>  building archive 'libfoo.a'
/usr/bin/ranlib libfoo.a
...
Linking C executable hello
/path/to/CMake/2.8.12.2/linux/i386/bin/cmake -E cmake_link_script
CMakeFiles/hello.dir/link.txt --verbose=1
/path/to/cl6x  --run_linker --output_file=hello --map_file=hello.map   libfoo.a 
  CMakeFiles/hello.dir/src/hello.c.obj
<Linking>
warning: archive symbol directory is missing from archive "libfoo.a"

I suggest to set up in TI-C.cmake the following:

set(CMAKE_C_ARCHIVE_FINISH)

to clean up call to ranlib on finishing archive.

I would also suggest to either set CMAKE_C_ARCHIVE_APPEND to
${CMAKE_C_ARCHIVE_CREATE}. Currently, since CMAKE_C_ARCHIVE_CREATE is declared
explicitly in TI toolchain support, but CMAKE_C_ARCHIVE_APPEND is inherited from
CMakeCInformation, it looks inconsistent:

/vob/tetra/tools/CMake/2.8.12.2/linux/i386/share/cmake-2.8/Modules/Compiler/TI-C.cmake(9):
 set(CMAKE_C_ARCHIVE_CREATE <CMAKE_AR> -r <TARGET> <OBJECTS> )
/vob/tetra/tools/CMake/2.8.12.2/linux/i386/share/cmake-2.8/Modules/CMakeCInformation.cmake(181):
 set(CMAKE_C_ARCHIVE_APPEND <CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS> )

Similar update should also be performed in TI-CXX.cmake.

Steps to Reproduce: 
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
project(hello C)
# Enable/disable following to observe the issue
set(CMAKE_C_ARCHIVE_FINISH)
add_library(foo src/foo.c)
add_executable(hello src/hello.c)
target_link_libraries(hello foo)
set_target_properties(hello PROPERTIES LINKER_LANGUAGE C)

$ cat src/foo.c
void foo(void)
{
}

$ cat src/hello.c
void foo(void);

int main(int argc, char *argv[])
{
    foo();
    return 0;
}

$ /path/to/cmake -DCMAKE_C_COMPILER=/path/to/cl6x -DCMAKE_SYSTEM_NAME=Generic .

$ make

Observe that in case that CMAKE_C_ARCHIVE_FINISH is not redefined, ranlib is run
and then linker complains:
warning: archive symbol directory is missing from archive "libfoo.a"

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-04-15 09:48 raspy          New Issue                                    
======================================================================



More information about the cmake-developers mailing list