LLVM 3.9.1 build race?

Hi Folks,

I am building LLVM 3.9.1 using the Yocto build system for a cross build. The compiled bins/libs work totally fine on the target machine however there seems to be an intermittent race condition during the build which causes a build failure. On the failed builds I usually see things being linking/compiling twice e.g.

Linking CXX static library …/libLLVMSupport.a
cd build/NATIVE/lib/Support && /usr/bin/cmake -P CMakeFiles/LLVMSupport.dir/cmake_clean_target.cmake
cd build/NATIVE/lib/Support && /usr/bin/cmake -E cmake_link_script CMakeFiles/LLVMSupport.dir/link.txt --verbose=1
/usr/bin/ar qc …/libLLVMSupport.a CMakeFiles/LLVMSupport.dir/APFloat.cpp.o CMakeFiles/LLVMSupport.dir/APInt.cpp.o CMakeFiles/LLVMSupport.dir/APSInt.cpp.o CMakeFiles/LLVMSupport.dir/ARMBuildAttrs.cpp.o CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o CMakeFiles/LLVMSupport.dir/Allocator.cpp.o CMakeFiles/LLVMSupport.dir/BlockFrequency.cpp.o CMakeFiles/LLVMSupport.dir/BranchProbability.cpp.o CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o CMakeFiles/LLVMSupport.dir/circular_raw_ostream.cpp.o CMakeFiles/LLVMSupport.dir/COM.cpp.o CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o CMakeFiles/LLVMSupport.dir/Compression.cpp.o CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o CMakeFiles/LLVMSupport.dir/ConvertUTFWrapper.cpp.o CMakeFiles/LLVMSupport.dir/CrashRecoveryContext.cpp.o CMakeFiles/LLVMSupport.dir/DataExtractor.cpp.o CMakeFiles/LLVMSupport.dir/DataStream.cpp.o CMakeFiles/LLVMSupport.dir/Debug.cpp.o CMakeFiles/LLVMSupport.dir/DeltaAlgorithm.cpp.o CMakeFiles/LLVMSupport.dir/DAGDeltaAlgorithm.cpp.o CMakeFiles/LLVMSupport.dir/Dwarf.cpp.o CMakeFiles/LLVMSupport.dir/Error.cpp.o CMakeFiles/LLVMSupport.dir/ErrorHandling.cpp.o CMakeFiles/LLVMSupport.dir/FileUtilities.cpp.o CMakeFiles/LLVMSupport.dir/FileOutputBuffer.cpp.o CMakeFiles/LLVMSupport.dir/FoldingSet.cpp.o CMakeFiles/LLVMSupport.dir/FormattedStream.cpp.o CMakeFiles/LLVMSupport.dir/GraphWriter.cpp.o CMakeFiles/LLVMSupport.dir/Hashing.cpp.o CMakeFiles/LLVMSupport.dir/IntEqClasses.cpp.o CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.o CMakeFiles/LLVMSupport.dir/IntrusiveRefCntPtr.cpp.o CMakeFiles/LLVMSupport.dir/JamCRC.cpp.o CMakeFiles/LLVMSupport.dir/LEB128.cpp.o CMakeFiles/LLVMSupport.dir/LineIterator.cpp.o CMakeFiles/LLVMSupport.dir/Locale.cpp.o CMakeFiles/LLVMSupport.dir/LockFileManager.cpp.o CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o CMakeFiles/LLVMSupport.dir/MathExtras.cpp.o CMakeFiles/LLVMSupport.dir/MemoryBuffer.cpp.o CMakeFiles/LLVMSupport.dir/MemoryObject.cpp.o CMakeFiles/LLVMSupport.dir/MD5.cpp.o CMakeFiles/LLVMSupport.dir/Options.cpp.o CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o CMakeFiles/LLVMSupport.dir/PrettyStackTrace.cpp.o CMakeFiles/LLVMSupport.dir/RandomNumberGenerator.cpp.o CMakeFiles/LLVMSupport.dir/Regex.cpp.o CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o CMakeFiles/LLVMSupport.dir/ScopedPrinter.cpp.o CMakeFiles/LLVMSupport.dir/SHA1.cpp.o CMakeFiles/LLVMSupport.dir/SmallPtrSet.cpp.o CMakeFiles/LLVMSupport.dir/SmallVector.cpp.o CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o CMakeFiles/LLVMSupport.dir/SpecialCaseList.cpp.o CMakeFiles/LLVMSupport.dir/Statistic.cpp.o CMakeFiles/LLVMSupport.dir/StreamingMemoryObject.cpp.o CMakeFiles/LLVMSupport.dir/StringExtras.cpp.o CMakeFiles/LLVMSupport.dir/StringMap.cpp.o CMakeFiles/LLVMSupport.dir/StringPool.cpp.o CMakeFiles/LLVMSupport.dir/StringSaver.cpp.o CMakeFiles/LLVMSupport.dir/StringRef.cpp.o CMakeFiles/LLVMSupport.dir/SystemUtils.cpp.o CMakeFiles/LLVMSupport.dir/TargetParser.cpp.o CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o CMakeFiles/LLVMSupport.dir/Timer.cpp.o CMakeFiles/LLVMSupport.dir/ToolOutputFile.cpp.o CMakeFiles/LLVMSupport.dir/Triple.cpp.o CMakeFiles/LLVMSupport.dir/Twine.cpp.o CMakeFiles/LLVMSupport.dir/Unicode.cpp.o CMakeFiles/LLVMSupport.dir/YAMLParser.cpp.o CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o CMakeFiles/LLVMSupport.dir/raw_os_ostream.cpp.o CMakeFiles/LLVMSupport.dir/raw_ostream.cpp.o CMakeFiles/LLVMSupport.dir/regcomp.c.o CMakeFiles/LLVMSupport.dir/regerror.c.o CMakeFiles/LLVMSupport.dir/regexec.c.o CMakeFiles/LLVMSupport.dir/regfree.c.o CMakeFiles/LLVMSupport.dir/regstrlcpy.c.o CMakeFiles/LLVMSupport.dir/Atomic.cpp.o CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o CMakeFiles/LLVMSupport.dir/Errno.cpp.o CMakeFiles/LLVMSupport.dir/Host.cpp.o CMakeFiles/LLVMSupport.dir/Memory.cpp.o CMakeFiles/LLVMSupport.dir/Mutex.cpp.o CMakeFiles/LLVMSupport.dir/Path.cpp.o CMakeFiles/LLVMSupport.dir/Process.cpp.o CMakeFiles/LLVMSupport.dir/Program.cpp.o CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o CMakeFiles/LLVMSupport.dir/SearchForAddressOfSpecialSymbol.cpp.o CMakeFiles/LLVMSupport.dir/Signals.cpp.o CMakeFiles/LLVMSupport.dir/TargetRegistry.cpp.o CMakeFiles/LLVMSupport.dir/ThreadLocal.cpp.o CMakeFiles/LLVMSupport.dir/Threading.cpp.o CMakeFiles/LLVMSupport.dir/TimeValue.cpp.o CMakeFiles/LLVMSupport.dir/Valgrind.cpp.o CMakeFiles/LLVMSupport.dir/Watchdog.cpp.o
Linking CXX static library …/libLLVMSupport.a
cd build/NATIVE/lib/Support && /usr/bin/cmake -P CMakeFiles/LLVMSupport.dir/cmake_clean_target.cmake
cd build/NATIVE/lib/Support && /usr/bin/cmake -E cmake_link_script CMakeFiles/LLVMSupport.dir/link.txt --verbose=1
/usr/bin/ar qc …/libLLVMSupport.a CMakeFiles/LLVMSupport.dir/APFloat.cpp.o CMakeFiles/LLVMSupport.dir/APInt.cpp.o CMakeFiles/LLVMSupport.dir/APSInt.cpp.o CMakeFiles/LLVMSupport.dir/ARMBuildAttrs.cpp.o CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o CMakeFiles/LLVMSupport.dir/Allocator.cpp.o CMakeFiles/LLVMSupport.dir/BlockFrequency.cpp.o CMakeFiles/LLVMSupport.dir/BranchProbability.cpp.o CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o CMakeFiles/LLVMSupport.dir/circular_raw_ostream.cpp.o CMakeFiles/LLVMSupport.dir/COM.cpp.o CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o CMakeFiles/LLVMSupport.dir/Compression.cpp.o CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o CMakeFiles/LLVMSupport.dir/ConvertUTFWrapper.cpp.o CMakeFiles/LLVMSupport.dir/CrashRecoveryContext.cpp.o CMakeFiles/LLVMSupport.dir/DataExtractor.cpp.o CMakeFiles/LLVMSupport.dir/DataStream.cpp.o CMakeFiles/LLVMSupport.dir/Debug.cpp.o CMakeFiles/LLVMSupport.dir/DeltaAlgorithm.cpp.o CMakeFiles/LLVMSupport.dir/DAGDeltaAlgorithm.cpp.o CMakeFiles/LLVMSupport.dir/Dwarf.cpp.o CMakeFiles/LLVMSupport.dir/Error.cpp.o CMakeFiles/LLVMSupport.dir/ErrorHandling.cpp.o CMakeFiles/LLVMSupport.dir/FileUtilities.cpp.o CMakeFiles/LLVMSupport.dir/FileOutputBuffer.cpp.o CMakeFiles/LLVMSupport.dir/FoldingSet.cpp.o CMakeFiles/LLVMSupport.dir/FormattedStream.cpp.o CMakeFiles/LLVMSupport.dir/GraphWriter.cpp.o CMakeFiles/LLVMSupport.dir/Hashing.cpp.o CMakeFiles/LLVMSupport.dir/IntEqClasses.cpp.o CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.o CMakeFiles/LLVMSupport.dir/IntrusiveRefCntPtr.cpp.o CMakeFiles/LLVMSupport.dir/JamCRC.cpp.o CMakeFiles/LLVMSupport.dir/LEB128.cpp.o CMakeFiles/LLVMSupport.dir/LineIterator.cpp.o CMakeFiles/LLVMSupport.dir/Locale.cpp.o CMakeFiles/LLVMSupport.dir/LockFileManager.cpp.o CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o CMakeFiles/LLVMSupport.dir/MathExtras.cpp.o CMakeFiles/LLVMSupport.dir/MemoryBuffer.cpp.o CMakeFiles/LLVMSupport.dir/MemoryObject.cpp.o CMakeFiles/LLVMSupport.dir/MD5.cpp.o CMakeFiles/LLVMSupport.dir/Options.cpp.o CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o CMakeFiles/LLVMSupport.dir/PrettyStackTrace.cpp.o CMakeFiles/LLVMSupport.dir/RandomNumberGenerator.cpp.o CMakeFiles/LLVMSupport.dir/Regex.cpp.o CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o CMakeFiles/LLVMSupport.dir/ScopedPrinter.cpp.o CMakeFiles/LLVMSupport.dir/SHA1.cpp.o CMakeFiles/LLVMSupport.dir/SmallPtrSet.cpp.o CMakeFiles/LLVMSupport.dir/SmallVector.cpp.o CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o CMakeFiles/LLVMSupport.dir/SpecialCaseList.cpp.o CMakeFiles/LLVMSupport.dir/Statistic.cpp.o CMakeFiles/LLVMSupport.dir/StreamingMemoryObject.cpp.o CMakeFiles/LLVMSupport.dir/StringExtras.cpp.o CMakeFiles/LLVMSupport.dir/StringMap.cpp.o CMakeFiles/LLVMSupport.dir/StringPool.cpp.o CMakeFiles/LLVMSupport.dir/StringSaver.cpp.o CMakeFiles/LLVMSupport.dir/StringRef.cpp.o CMakeFiles/LLVMSupport.dir/SystemUtils.cpp.o CMakeFiles/LLVMSupport.dir/TargetParser.cpp.o CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o CMakeFiles/LLVMSupport.dir/Timer.cpp.o CMakeFiles/LLVMSupport.dir/ToolOutputFile.cpp.o CMakeFiles/LLVMSupport.dir/Triple.cpp.o CMakeFiles/LLVMSupport.dir/Twine.cpp.o CMakeFiles/LLVMSupport.dir/Unicode.cpp.o CMakeFiles/LLVMSupport.dir/YAMLParser.cpp.o CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o CMakeFiles/LLVMSupport.dir/raw_os_ostream.cpp.o CMakeFiles/LLVMSupport.dir/raw_ostream.cpp.o CMakeFiles/LLVMSupport.dir/regcomp.c.o CMakeFiles/LLVMSupport.dir/regerror.c.o CMakeFiles/LLVMSupport.dir/regexec.c.o CMakeFiles/LLVMSupport.dir/regfree.c.o CMakeFiles/LLVMSupport.dir/regstrlcpy.c.o CMakeFiles/LLVMSupport.dir/Atomic.cpp.o CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o CMakeFiles/LLVMSupport.dir/Errno.cpp.o CMakeFiles/LLVMSupport.dir/Host.cpp.o CMakeFiles/LLVMSupport.dir/Memory.cpp.o CMakeFiles/LLVMSupport.dir/Mutex.cpp.o CMakeFiles/LLVMSupport.dir/Path.cpp.o CMakeFiles/LLVMSupport.dir/Process.cpp.o CMakeFiles/LLVMSupport.dir/Program.cpp.o CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o CMakeFiles/LLVMSupport.dir/SearchForAddressOfSpecialSymbol.cpp.o CMakeFiles/LLVMSupport.dir/Signals.cpp.o CMakeFiles/LLVMSupport.dir/TargetRegistry.cpp.o CMakeFiles/LLVMSupport.dir/ThreadLocal.cpp.o CMakeFiles/LLVMSupport.dir/Threading.cpp.o CMakeFiles/LLVMSupport.dir/TimeValue.cpp.o CMakeFiles/LLVMSupport.dir/Valgrind.cpp.o CMakeFiles/LLVMSupport.dir/Watchdog.cpp.o
/usr/bin/ranlib …/libLLVMSupport.a
/usr/bin/ranlib …/libLLVMSupport.a

Sorry for the clutter here… :frowning:

and from the above mentioned example the build failed with

…/…/lib/libLLVMSupport.a(Process.cpp.o): In function llvm::sys::Process::GetRandomNumber()': Process.cpp:(.text._ZN4llvm3sys7Process15GetRandomNumberEv+0x70): undefined reference to llvm::sys::TimeValue::now()’
collect2: error: ld returned 1 exit status

I also see exactly 4 instances of “warning: jobserver unavailable: using -j1. Add `+’ to parent make rule.” and this was reported at https://llvm.org/bugs/show_bug.cgi?format=multiple&id=23328 quite some time ago. Has there been any movement on this? Can the mentioned warning cause such a trouble? I doubt that because the warning appears in successful builds as well but I’d love to hear expert opinion on this.

NATIVE builds are done for the host which is then utilized for generating the target binaries, correct? If that is so, what can cause multiple builds for the NATIVE system?

We’re building with CMake with the “Unix Makefiles” generator prior to this we were building 3.7.1 using autotools and never saw such an issue. GCC version is 5.4.0 on both instances with GNU Make at 4.1. Any pointers/help would be highly appreciated.

"Belal, Awais via llvm-dev" <llvm-dev@lists.llvm.org> writes:

I am building LLVM 3.9.1 using the Yocto build system for a cross
build. The compiled bins/libs work totally fine on the target machine
however there seems to be an intermittent race condition during the
build which causes a build failure. On the failed builds I usually see
things being linking/compiling twice e.g.

...

and from the above mentioned example the build failed with

../../lib/libLLVMSupport.a(Process.cpp.o): In function
`llvm::sys::Process::GetRandomNumber()':
Process.cpp:(.text._ZN4llvm3sys7Process15GetRandomNumberEv+0x70):
undefined reference to `llvm::sys::TimeValue::now()'
collect2: error: ld returned 1 exit status

This looks like something I fixed recently, in r290271:

  commit 8bddda3652b36619cc8cd916c33d38c9cd41f024
  Author: Justin Bogner <mail@justinbogner.com>

    cmake: Don't build llvm-config and tblgen concurrently in cross builds

    This sets USES_TERMINAL for the native llvm-config build, so that it
    doesn't run at the same time as builds of other native tools (namely,
    tablegen). Without this, if you're very unlucky with the timing it's
    possible to be relinking libSupport as one of the tools is linking,
    causing a spurious failure.

    The tablegen build adopted USES_TERMINAL for this same reason in
    r280748.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290271 91177308-0d34-0410-b5e6-96231b3b80d8

Tom: if we do a 3.9.2, it's probably worth pulling this change in.

Hi Justin,

This looks like something I fixed recently, in r290271:

...
...

The tablegen build adopted USES_TERMINAL for this same reason in
  r280748.

I applied the 2 patches you mentioned above on my 3.9.1 tree and although the build seems to go along nicely than the earlier reported symptoms I can still see LLVMSupport being built a bit too many times than expected.

$ cat log.do_compile | grep "Built target" | cut -d "]" -f2 | grep Support
Built target LLVMSupport
Built target LLVMSupport
Built target LLVMSupport
Built target LLVMSupport

Now, I would expect to see LLVMSupport being built only twice, once for the NATIVE build and the other for the target. I dug through the whole log and LLVMSupport gets built twice for the NATIVE side and twice for the target side, is this the intended behavior? Would it be possible for you to share a cross build log with me so I can compare what I might be doing wrong?

And hey, the above mentioned patches did fix 3 out of the 4 "warning: jobserver unavailable: using -j1. Add `+' to parent make rule." messages I was getting. Now I only get this warning when the native llvm-config target starts building.

Thanks a lot for all the help!

BR,
Awais

Hi Justin,

> This looks like something I fixed recently, in r290271:
...
...
> The tablegen build adopted USES_TERMINAL for this same reason in
> r280748.

I applied the 2 patches you mentioned above on my 3.9.1 tree and although the build seems to go along nicely than the earlier reported symptoms I can still see LLVMSupport being built a bit too many times than expected.

$ cat log.do_compile | grep "Built target" | cut -d "]" -f2 | grep Support
Built target LLVMSupport
Built target LLVMSupport
Built target LLVMSupport
Built target LLVMSupport

Now, I would expect to see LLVMSupport being built only twice, once for the NATIVE build and the other for the target. I dug through the whole log and LLVMSupport gets built twice for the NATIVE side and twice for the target side, is this the intended behavior? Would it be possible for you to share a cross build log with me so I can compare what I might be doing wrong?

And hey, the above mentioned patches did fix 3 out of the 4 "warning: jobserver unavailable: using -j1. Add `+' to parent make rule." messages I was getting. Now I only get this warning when the native llvm-config target starts building.

Hi,

Would you be able to file a bug for this against LLVM 3.9 and assign it
to me?

Thanks,
Tom

Hi Tom,

Would you be able to file a bug for this against LLVM 3.9 and assign it
to me?

Sure, but I do not have an account on the LLVM bugzilla. I've requested an account on the llvm-admin mailing list, would that suffice or do I need to follow this up with someone directly for some escalation?

BR,
Awais