[llvm-dev] Cmake-gen'd parallel make breaks on native tablegen

Alex Wang via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 28 12:07:56 PDT 2015


Hello backend devs,

Been working on a parallelization bug in the cmake configs, where parallel makefile builds of llvm with clang and native tablegen would usually break during linking in either either the clang_tblgen or llvm_tblgen targets. Looking at the cmake command that generates the tablegen makefile commands (I think) (cmake/modules/TableGen.cmake:113-117):

      add_custom_command(OUTPUT ${${project}_TABLEGEN_EXE}
        COMMAND ${CMAKE_COMMAND} --build ../.. --target ${target} --config Release
        DEPENDS CONFIGURE_LLVM_NATIVE ${target}
        WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
        COMMENT "Building native TableGen...")

My guess is that the clang and llvm tablegen builds are trying to place their output into the same folder, so depending on when the resulting library gets linked/moved one of the threads could be left dangling with a partially-completed library or no library. The error was either "Couldn't stat output file: ../LLVMSupport.a No such file or directory" or something about an archive member extending past the end of the file, and the cmake progress messages before linking were printed twice. Once for each thread, I'd guess? Sort of surprised that they seem to share so much code (or at least filenames)

First thing I could think of to fix this is adding another layer or two of CMakeLists, so the tablegen creation command would be invoked in different folders. I'm not convinced that that is the best fix, and I couldn't figure out how to move the builds into different folders with only minor changes to the existing cmake files.

Thoughts?

-Alex

(CrossCompile.cmake also has a typo in the first line: "toochain" --> "toolchain", if that is something to worry about)


More information about the llvm-dev mailing list