Skip to content

Random parallel-build failure: No rule to make target liblua51.a #6

Description

@kelvSYC

Building the vendored Lua (lua-5.1.5/toluapp-simple) sometimes fails under make -j, but not always — same source, nothing changed in between, and it can pass or fail from one run to the next:

make[5]: *** No rule to make target `liblua51.a', needed by `libtoluapp51.dylib'.  Stop.

Looks like it's this bit in toluapp-simple/CMakeLists.txt:

target_link_libraries(toluapp51 PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})
target_link_libraries(toluapp51_shared PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})
target_link_libraries(toluapp PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})

These link liblua51.a by its raw path instead of the lua51_static target that actually builds it. There's an add_dependencies(...) a few lines down that orders the targets correctly, but since the link step points at a plain file path rather than a CMake target, Make doesn't always know to wait for that specific file before linking against it — so under -j it sometimes wins the race and sometimes doesn't.

Swapping the raw path for the target name fixes it for me:

-    target_link_libraries(toluapp51 PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})
-    target_link_libraries(toluapp51_shared PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})
-    target_link_libraries(toluapp PUBLIC "${PROJECT_BINARY_DIR}/liblua51.a" ${CMAKE_DL_LIBS})
+    target_link_libraries(toluapp51 PUBLIC lua51_static ${CMAKE_DL_LIBS})
+    target_link_libraries(toluapp51_shared PUBLIC lua51_static ${CMAKE_DL_LIBS})
+    target_link_libraries(toluapp PUBLIC lua51_static ${CMAKE_DL_LIBS})

Hit this on macOS arm64 (CMake 3.31+, make -j3), but I don't think it's macOS-specific — seems like it'd depend on job scheduling on any platform using the Makefiles generator.

(Found while working on a from-source CI build; drafted with AI assistance.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions