Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2107,11 +2107,21 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
// On ELF platforms there's no built in autolinking mechanism, so we
// pull the info we need from the .o files directly and pass them as an
// argument input file to the linker.
const auto &Triple = TC.getTriple();
SmallVector<const Action *, 2> AutolinkExtractInputs;
for (const Action *A : AllLinkerInputs)
if (A->getType() == file_types::TY_Object)
if (A->getType() == file_types::TY_Object) {
// Shared objects on ELF platforms don't have a swift1_autolink_entries
// section in them because the section in the .o files is marked as
// SHF_EXCLUDE.
if (auto *IA = dyn_cast<InputAction>(A)) {
StringRef ObjectName = IA->getInputArg().getValue();
if (Triple.getObjectFormat() == llvm::Triple::ELF &&
ObjectName.endswith(".so"))
continue;
}
AutolinkExtractInputs.push_back(A);
const auto &Triple = TC.getTriple();
}
const bool AutolinkExtractRequired =
(Triple.getObjectFormat() == llvm::Triple::ELF && !Triple.isPS4()) ||
Triple.getObjectFormat() == llvm::Triple::Wasm ||
Expand Down
1 change: 1 addition & 0 deletions test/Driver/Inputs/libEmpty.so
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Just an empty file that looks like an ELF shared object */
5 changes: 5 additions & 0 deletions test/Driver/autolink-no-shared-objects-elf.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %target-swiftc_driver -### %s %S/Inputs/libEmpty.so | %FileCheck %s

// REQUIRES: autolink-extract

// CHECK-NOT: swift-autolink-extract {{.+}}.o {{.+}}Inputs/libEmpty.so -o {{.+}}.autolink