Index: include/llvm/Support/TarWriter.h =================================================================== --- include/llvm/Support/TarWriter.h +++ include/llvm/Support/TarWriter.h @@ -13,6 +13,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include namespace llvm { class TarWriter { @@ -26,6 +27,7 @@ TarWriter(int FD, StringRef BaseDir); raw_fd_ostream OS; std::string BaseDir; + std::set Files; }; } Index: lib/Support/TarWriter.cpp =================================================================== --- lib/Support/TarWriter.cpp +++ lib/Support/TarWriter.cpp @@ -173,6 +173,10 @@ // Write Path and Data. std::string Fullpath = BaseDir + "/" + sys::path::convert_to_slash(Path); + // We do not want to include the same file more than once. + if (!Files.insert(Fullpath).second) + return; + StringRef Prefix; StringRef Name; if (splitUstar(Fullpath, Prefix, Name)) {