[CMake] linking OBJECT libraries : Argument list too long
Magnus Therning
magnus at therning.org
Wed May 25 16:03:24 EDT 2016
Biddiscombe, John A. <biddisco at cscs.ch> writes:
> When building OpenBLAS on OSX, the link line generated contains around
> 350K of text, and the max supported arg length is getconf ARG_MAX -
> returns 262144.
> This causes the link phase to abort with Error running link command:
> Argument list too long
>
> The reason for the problem is that many libraries of Type OBJECT are
> built and produce huge numbers of object files are then added to one
> very large list which is then passed to the linker.
>
> I implemented a simple(ish) fix, that doesn't quite work - for each
> subdirectory that generates object files, I set the
> CMAKE_FILES_DIRECTORY and specify the binary directory where the build
> should go using a single character counter 0,1,2,3,4 which is much
> shorter than the target name and it reduces the final arg size down
> almost enough
>
> set(COUNTER_ 0)
> foreach (SUBDIR ${SUBDIRS})
> set(CMAKE_FILES_DIRECTORY "/${COUNTER_}")
> add_subdirectory(${SUBDIR} ${CMAKE_BINARY_DIR}/${COUNTER_})
> .....
> MATH(EXPR COUNTER_ "${COUNTER_}+1")
> endforeach ()
>
> example : make driver_level2 target
> [ 0%] Building C object OpenBLAS/driver/level2/CMakeFiles/driver_level2.dir/CMakeFiles/ssbmv_U.c.o
> becomes
> [ 0%] Building C object 1/CMakeFiles/driver_level2.dir/1/ssbmv_U.c.o
>
> and the link line is correspondingly shorter as the driver_level2 has
> been replaced in 2 places. The problem is that there is still an extra
> "CMakeFiles/driver_level2.dir" in the path to the object file that I
> would like to shorten/remove.
>
> How can I do that?
>
> NB. I am aware that I can turn the OBJECT libraries into normal
> libraries and link them conventionally, but I'd like to make this path
> shortening method work.
Wouldn't a better solution be to use an options file, something like
ld's @file[1]?
/M
[1]: http://linux.die.net/man/1/ld
--
Magnus Therning OpenPGP: 0x927912051716CE39
email: magnus at therning.org jabber: magnus at therning.org
twitter: magthe http://therning.org/magnus
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
— R.P. Feynman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160525/3a64bd9b/attachment.sig>
More information about the CMake
mailing list