From 18923c3b703b9380b079d59a52db3f83fd2b3e37 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 15 May 2023 10:01:30 +0000 Subject: [PATCH] [wasm] Read autolink entries from custom section instead of data segments This change is required since https://github.com/apple/llvm-project/commit/d0f00c4d76d1d3d6595cb8f0ce4aca1afae87781 and we no longer need wasm custom implementation. --- lib/DriverTool/autolink_extract_main.cpp | 30 ------------------------ 1 file changed, 30 deletions(-) diff --git a/lib/DriverTool/autolink_extract_main.cpp b/lib/DriverTool/autolink_extract_main.cpp index 1f2538e1ac6e1..4008341b02652 100644 --- a/lib/DriverTool/autolink_extract_main.cpp +++ b/lib/DriverTool/autolink_extract_main.cpp @@ -153,36 +153,6 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile, return false; } -/// Look inside the object file 'WasmObjectFile' and append any linker flags -/// found in its ".swift1_autolink_entries" section to 'LinkerFlags'. Return -/// 'true' if there was an error, and 'false' otherwise. -static bool -extractLinkerFlagsFromObjectFile(const llvm::object::WasmObjectFile *ObjectFile, - std::vector &LinkerFlags, - std::unordered_map &SwiftRuntimeLibraries, - CompilerInstance &Instance) { - // Search for the data segment we hold autolink entries in - for (const llvm::object::WasmSegment &Segment : ObjectFile->dataSegments()) { - if (Segment.Data.Name == ".swift1_autolink_entries") { - - StringRef SegmentData = llvm::toStringRef(Segment.Data.Content); - // entries are null-terminated, so extract them and push them into - // the set. - llvm::SmallVector SplitFlags; - SegmentData.split(SplitFlags, llvm::StringRef("\0", 1), -1, - /*KeepEmpty=*/false); - for (const auto &Flag : SplitFlags) { - auto RuntimeLibEntry = SwiftRuntimeLibraries.find(Flag.str()); - if (RuntimeLibEntry == SwiftRuntimeLibraries.end()) - LinkerFlags.emplace_back(Flag.str()); - else - RuntimeLibEntry->second = true; - } - } - } - return false; -} - /// Look inside the binary 'Bin' and append any linker flags found in its /// ".swift1_autolink_entries" section to 'LinkerFlags'. If 'Bin' is an archive, /// recursively look inside all children within the archive. Return 'true' if