Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6368] swift build fetch log is printed after compile log when output is redirected #4919

Closed
omochi opened this issue Nov 12, 2017 · 4 comments
Labels

Comments

@omochi
Copy link
Contributor

omochi commented Nov 12, 2017

Previous ID SR-6368
Radar rdar://problem/40205154
Original Reporter @omochi
Type Bug
Status Resolved
Resolution Cannot Reproduce
Environment

macOS Sierra 10.12.6
Xcode9.0

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 9d61f2f5913c0019495d6209d1e22d2a

Issue Description:

With this `Package.swift`, `swift build` output normally this.

```
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SwiftPMClient",
dependencies: [
.package(url: "https://github.com/jpsim/Yams.git", .exact("0.5.0"))
],
targets: [
.target(name: "SwiftPMClient",
dependencies: ["Yams"]),
]
)
```

```
$ rm -rf .build
$ swift build
Fetching https://github.com/jpsim/Yams.git
Cloning https://github.com/jpsim/Yams.git
Resolving https://github.com/jpsim/Yams.git at 0.5.0
Compile CYaml src/writer.c
Compile CYaml src/scanner.c
Compile CYaml src/reader.c
Compile CYaml src/parser.c
Compile CYaml src/emitter.c
Compile CYaml src/api.c
Compile Swift Module 'Yams' (15 sources)
Compile Swift Module 'SwiftPMClient' (1 sources)
Linking ./.build/x86_64-apple-macosx10.10/debug/SwiftPMClient
```

But If output is redirected, `Fetch` messages are delayed after `Compile` messages.

```
$ rm -rf .build
$ swift build > a.txt
$ cat a.txt
Compile CYaml src/scanner.c
Compile CYaml src/reader.c
Compile CYaml src/writer.c
Compile CYaml src/parser.c
Compile CYaml src/emitter.c
Compile CYaml src/api.c
Compile Swift Module 'Yams' (15 sources)
Compile Swift Module 'SwiftPMClient' (1 sources)
Linking ./.build/x86_64-apple-macosx10.10/debug/SwiftPMClient
Fetching https://github.com/jpsim/Yams.git
Cloning https://github.com/jpsim/Yams.git
Resolving https://github.com/jpsim/Yams.git at 0.5.0
```

@omochi
Copy link
Contributor Author

omochi commented Nov 13, 2017

@norio-nomura helped me at SwiftPM slack.

He says that this patch fix issue.
I have not check this yet by myself, it may be helpful information.

```
diff --git a/Sources/Basic/Process.swift b/Sources/Basic/Process.swift
index 6a1e1951..8642887c 100644

      • a/Sources/Basic/Process.swift
        +++ b/Sources/Basic/Process.swift
        @@ -293,6 +293,14 @@ public final class Process: ObjectIdentifierProtocol {
        var outputPipe: [Int32] = [0, 0]
        var stderrPipe: [Int32] = [0, 0]
        if redirectOutput {
        • #if os(macOS)
        • setlinebuf(Darwin.stdout)
        • setlinebuf(Darwin.stderr)
        • #else
        • setlinebuf(Glibc.stdout)
        • setlinebuf(Glibc.stderr)
        • #endif
        // Open the pipes.
        try open(pipe: &outputPipe)
        try open(pipe: &stderrPipe)
        ```

@swift-ci
Copy link
Contributor

swift-ci commented Mar 3, 2018

Comment by aniket sharma (JIRA)

opened a pr for this #1515

@ankitspd
Copy link
Member

@swift-ci create

@ankitspd
Copy link
Member

I am seeing the correct behavior with ToT SwiftPM.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants