Problem with relinking

I’ve noticed that whenever I rebuild, say after updating tree or switching branches, I can run ninja and everything seems to build fine. However, if I rerun ninja again, without touching anything, it relinks everything, but only does this once. I’ve investigated a little, but don’t see anything obvious.

Is anyone else seeing this?

I’m using the monorepo on a fully up to date Macbook Pro.

thanks…
don

I've noticed that whenever I rebuild, say after updating tree or switching branches, I can run ninja and everything seems to build fine. However, if I rerun ninja again, without touching anything, it relinks everything, but only does this once. I've investigated a little, but don't see anything obvious.

Is anyone else seeing this?

What CMake flags are you using?

-Tom

$ cat ~/projects/misc/cmake/llvm-debug.cmake
set(CMAKE_BUILD_TYPE Debug CACHE STRING “”)
set(LLVM_OPTIMIZED_TABLEGEN ON CACHE BOOL “”)
set(LLVM_APPEND_VC_REV OFF CACHE BOOL “”)
set(LLVM_ENABLE_PROJECTS clang clang-tools-extra libcxx libcxxabi CACHE STRING “”)

set(LLVM_TARGETS_TO_BUILD “X86” CACHE STRING “”)

set(LLVM_LIT_ARGS ‘-v’ CACHE STRING “”)
find_program(GOLD NAMES gold ld.gold)
if(GOLD)
set(LLVM_USE_LINKER “gold” CACHE STRING “”)
endif()
set(CMAKE_C_FLAGS “-I/opt/local/include ${CMAKE_C_FLAGS}” CACHE STRING “”)

set(CMAKE_CXX_FLAGS “-I/opt/local/include ${CMAKE_CXX_FLAGS}” CACHE STRING “”)

$ cmake -C /llvm-debug.cmake -GNinja

Hi Tom:

I’ve got a smaller test case which only involves part of clang-tools-extra. At least it’s only a few files that get relinked, but when I make a change to an llvm file, it relinks 90+ binaries.

I only need to touch a file in my new checker to get this behavior. If I run ninja after touching a file, it’ll recompile that file, then relink everything in clang-tidy. And if I run ninja again, without doing anything else, it will relink all the same binaries:

local:/Users/dhinton/projects/llvm_project/monorepo/build/Debug $ ninja
[11/11] Linking CXX executable bin/c-index-test
local:/Users/dhinton/projects/llvm_project/monorepo/build/Debug $ ninja
[10/10] Linking CXX executable bin/c-index-test

Still now sure what’s going on…

hi,

try to use 'ninja -j1 -d explain' and check 'older than recent most
input' logs.

Thanks. That showed that the lib was older than the cpp that got compiled and linked into it. Perhaps it’s just clock skew – the power here goes out all the time, so my wifi is pretty iffy right now.

thanks for the tip…
don

FYI, I finally got tired of this and dug a little deeper. Seems that ninja 1.9 implemented high resolutions timestamps, however, libtool on OSX seems to stamp static libs with low resolution timestamps, so ninja thinks the lib is older than the file it linked in. Guess this is a first world problem, i.e., my system is too fast…

Corrections or workarounds welcome.

thanks…
don