mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[BatchMode] Collect InputActions correctly when merging jobs.
This commit is contained in:
@@ -242,15 +242,19 @@ makeBatchCommandOutput(ArrayRef<const Job *> jobs, Compilation &C,
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set-union the \c Inputs and \c Actions from each \c Job in \p jobs into the
|
/// Set-union the \c Inputs and \c InputActions from each \c Job in \p jobs into
|
||||||
/// provided \p inputJobs and \p inputActions vectors, further adding all \c
|
/// the provided \p inputJobs and \p inputActions vectors, further adding all \c
|
||||||
/// Actions from the resulting merger to \p batchCJA. Do set-union rather than
|
/// Actions in the \p jobs -- InputActions or otherwise -- to \p batchCJA. Do
|
||||||
/// concatenation here to avoid mentioning the same input multiple times.
|
/// set-union rather than concatenation here to avoid mentioning the same input
|
||||||
|
/// multiple times.
|
||||||
static bool
|
static bool
|
||||||
mergeBatchInputs(ArrayRef<const Job *> jobs,
|
mergeBatchInputs(ArrayRef<const Job *> jobs,
|
||||||
llvm::SmallSetVector<const Job *, 16> &inputJobs,
|
llvm::SmallSetVector<const Job *, 16> &inputJobs,
|
||||||
llvm::SmallSetVector<const Action *, 16> &inputActions,
|
llvm::SmallSetVector<const Action *, 16> &inputActions,
|
||||||
CompileJobAction *batchCJA) {
|
CompileJobAction *batchCJA) {
|
||||||
|
|
||||||
|
llvm::SmallSetVector<const Action *, 16> allActions;
|
||||||
|
|
||||||
for (auto const *J : jobs) {
|
for (auto const *J : jobs) {
|
||||||
for (auto const *I : J->getInputs()) {
|
for (auto const *I : J->getInputs()) {
|
||||||
inputJobs.insert(I);
|
inputJobs.insert(I);
|
||||||
@@ -259,11 +263,18 @@ mergeBatchInputs(ArrayRef<const Job *> jobs,
|
|||||||
if (!CJA)
|
if (!CJA)
|
||||||
return true;
|
return true;
|
||||||
for (auto const *I : CJA->getInputs()) {
|
for (auto const *I : CJA->getInputs()) {
|
||||||
inputActions.insert(I);
|
// Capture _all_ input actions -- whether or not they are InputActions --
|
||||||
|
// in allActions, to set as the inputs for batchCJA below.
|
||||||
|
allActions.insert(I);
|
||||||
|
// Only collect input actions that _are InputActions_ in the inputActions
|
||||||
|
// array, to load into the JobContext in our caller.
|
||||||
|
if (auto const *IA = dyn_cast<InputAction>(I)) {
|
||||||
|
inputActions.insert(IA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const *I : inputActions) {
|
for (auto const *I : allActions) {
|
||||||
batchCJA->addInput(I);
|
batchCJA->addInput(I);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
13
test/Driver/batch_mode_bridging_pch.swift
Normal file
13
test/Driver/batch_mode_bridging_pch.swift
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: touch %t/file-01.swift %t/file-02.swift %t/file-03.swift
|
||||||
|
// RUN: echo 'public func main() {}' >%t/main.swift
|
||||||
|
// RUN: echo 'extern int foo;' >%t/foo-bridging-header.h
|
||||||
|
//
|
||||||
|
// RUN: %swiftc_driver -enable-bridging-pch -v -import-objc-header %t/foo-bridging-header.h -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift %s 2>&1 | %FileCheck %s
|
||||||
|
//
|
||||||
|
// CHECK: -emit-pch
|
||||||
|
// CHECK: -primary-file {{.*}}/file-01.swift -primary-file {{.*}}/file-02.swift
|
||||||
|
|
||||||
|
func bar() {
|
||||||
|
print(foo)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user