[cmake-developers] [CMake 0015650]: Linking large files on OS X can result in linker failing with "command line too long" error
Mantis Bug Tracker
mantis at public.kitware.com
Tue Jul 14 07:07:22 EDT 2015
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=15650
======================================================================
Reported By: Abigail
Assigned To:
======================================================================
Project: CMake
Issue ID: 15650
Category: CMake
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-07-14 07:07 EDT
Last Modified: 2015-07-14 07:07 EDT
======================================================================
Summary: Linking large files on OS X can result in linker
failing with "command line too long" error
Description:
When a project contains sufficiently many source files - the one I'm compiling
has 1689 .cpp files - the linker will fail, with the message "Error running link
command: Argument list too long".
When using response lists (via set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)),
the issue still occurs. This is because the response file is specified as a
linker flag with @ResponseFile.rsp syntax, which is expanded by the compiler
driver rather than being passed through and then expanded internally by the
linker.
OS X's linker, ld64, doesn't support the @ResponseFile.rsp syntax, so it's not
possible to work around this with set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG
"-Wl,@"). However, it does support -filelist, but this requires the file to be
newline-separated rather than space-separated.
Steps to Reproduce:
In an empty directory:
for i in {0000..9999}; echo "void f$i() {}" >> $i.c
find . > files.txt
cat << EOF > CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(long_file_test)
file(STRINGS "files.txt" files)
add_executable(long_file_test ${files})
EOF
cmake . && cmake --build . -- -j 24
...This will compile everything correctly, and then at the end emit:
[100%] Linking C executable long_file_test
Error running link command: Argument list too long
make[2]: *** [long_file_test] Error 2
make[1]: *** [CMakeFiles/long_file_test.dir/all] Error 2
make: *** [all] Error 2
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-07-14 07:07 Abigail New Issue
======================================================================
More information about the cmake-developers
mailing list