[lld] r303788 - Replace std::call_once with llvm:call_once

Kamil Rytarowski via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 11:31:48 PDT 2017


Author: kamil
Date: Wed May 24 13:31:48 2017
New Revision: 303788

URL: http://llvm.org/viewvc/llvm-project?rev=303788&view=rev
Log:
Replace std::call_once with llvm:call_once

Summary:
This is required on some platforms, as GNU libstdc++ std::call_once is known to be buggy.

This fixes operation of LLD on at least NetBSD and perhaps OpenBSD and Linux PowerPC.

The same change has been introduced to LLVM and LLDB.

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: emaste, #lld

Tags: #lld

Differential Revision: https://reviews.llvm.org/D33508

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=303788&r1=303787&r2=303788&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed May 24 13:31:48 2017
@@ -23,6 +23,7 @@
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Threading.h"
 #include <mutex>
 
 using namespace llvm;
@@ -866,7 +867,7 @@ const SectionPiece *MergeInputSection::g
 // it is not just an addition to a base output offset.
 uint64_t MergeInputSection::getOffset(uint64_t Offset) const {
   // Initialize OffsetMap lazily.
-  std::call_once(InitOffsetMap, [&] {
+  llvm::call_once(InitOffsetMap, [&] {
     OffsetMap.reserve(Pieces.size());
     for (const SectionPiece &Piece : Pieces)
       OffsetMap[Piece.InputOff] = Piece.OutputOff;

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=303788&r1=303787&r2=303788&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed May 24 13:31:48 2017
@@ -18,6 +18,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Object/ELF.h"
+#include "llvm/Support/Threading.h"
 #include <mutex>
 
 namespace lld {
@@ -248,7 +249,7 @@ private:
   std::vector<uint32_t> Hashes;
 
   mutable llvm::DenseMap<uint64_t, uint64_t> OffsetMap;
-  mutable std::once_flag InitOffsetMap;
+  mutable llvm::once_flag InitOffsetMap;
 
   llvm::DenseSet<uint64_t> LiveOffsets;
 };




More information about the llvm-commits mailing list