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-13721] swift build -Xswiftc -wmo and swift build -c release do not work properly on Windows #4487

Closed
MarSe32m opened this issue Oct 10, 2020 · 3 comments
Assignees

Comments

@MarSe32m
Copy link

Previous ID SR-13721
Radar None
Original Reporter @MarSe32m
Type Bug
Status Closed
Resolution Done
Environment

Windows 10

winver
Microsoft Windows
Version 1909 (18363.959)

Swift version:

swift --version
compnerd.org Swift version 5.3-dev (LLVM f9c85c8b92cf757, Swift 4f49b6ab81b7dcb) Target: x86_64-unknown-windows-msvc
Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug, Windows
Assignee @compnerd
Priority Medium

md5: ebf77ace392802b1ee7c637ca3618703

Issue Description:

The executable created when a package is built with `swift build -c release` doesn't work as intended.

For example an empty package with these files:

Package.swift

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package( 
 name: "resource_bug",
 targets: [.target(name: "resource_bug")])

main.swift

import Foundation 
print("Hello, world!") 

var i: Double = 0 
let startDate = Date() 
var lastPrintValue: Double = 0.0 
while i < 10_000_000.0 {
    i += Date().timeIntervalSince(startDate) 
    if i > lastPrintValue { 
        lastPrintValue += i
        print("Printing time!", i)
    } 
} 

print("Done") 

_ = readLine()

When building with swift build or swift build -Xswiftc -O -Xcc -O2 or any combination of these the console output something like this

Hello world!
Printing time! 0.0010013580322265625
Printing time! 0.002002716064453125
Printing time! 0.00400543212890625
...
Printing time! 3266880.746433258
Printing time! 6533761.248313904
Done

With swift build -c release the output is only this every time program is executed

Hello, world!
Printing time!

The program stalls like this for a couple of seconds until it eventually crashes.

When a second file is added to the package for example

Util.swift

class Queue {
    var count: Int = 1024
}

And compile it with `swift build -Xswiftc -wmo` the output error is this

swift build -Xswiftc -wmo
C:\Dev\SwiftProjects\resource_bug: warning: Creating library C:\Users\SEBAST~1\AppData\Local\Temp\TemporaryDirectory.3bgiOm\resource_bug-manifest.lib and object C:\Users\SEBAST~1\AppData\Local\Temp\TemporaryDirectory.3bgiOm\resource_bug-manifest.exp
<unknown>:0: warning: ignoring '-enable-batch-mode' because '-whole-module-optimization' was also specified[1/3] Compiling resource_bug Util.swift
<unknown>:0: error: index output filenames do not match input source files

This happens also with bigger packages but this was the minimal case where -wmo fails.

@compnerd
Copy link
Collaborator

compnerd commented Dec 7, 2021

Is this still an issue? I cannot reproduce this with the current main build:

>swiftc -emit-executable -o main.exe main.swift util.swift -sdk %SDKROOT% -O -Xcc -O2 -wmo
   Creating library main.lib and object main.exp

 >.\main.exe
Hello, world!
Printing time! 0.0149993896484375
Printing time! 0.029998779296875
Printing time! 0.05999755859375
Printing time! 0.1199951171875
Printing time! 0.239990234375
Printing time! 0.47998046875                                                                                            Printing time! 0.9599609375                                                                                             Printing time! 1.919921875                                                                                              Printing time! 3.83984375                                                                                               Printing time! 7.6796875                                                                                                Printing time! 15.359375                                                                                                Printing time! 30.71875                                                                                                 Printing time! 61.4375                                                                                                  Printing time! 122.875                                                                                                  Printing time! 245.75                                                                                                   Printing time! 491.5                                                                                                    Printing time! 983.0                                                                                                    Printing time! 1966.0                                                                                                   Printing time! 3931.9931507110596                                                                                       Printing time! 7863.981620788574                                                                                        Printing time! 15727.9915599823                                                                                         Printing time! 31455.991983413696                                                                                       Printing time! 62912.01509857178                                                                                        Printing time! 125824.0576915741                                                                                        Printing time! 251648.0285167694                                                                                        Printing time! 503296.2037410736                                                                                        Printing time! 1006592.4347782135                                                                                       Printing time! 2013184.9214076996                                                                                       Printing time! 4026370.2102794647                                                                                       Printing time! 8052740.226018906                                                                                        Done                                                                                                                     

@MarSe32m
Copy link
Author

MarSe32m commented Dec 7, 2021

It's not an issue anymore. It works on 5.5 also.

@compnerd
Copy link
Collaborator

compnerd commented Dec 8, 2021

Thanks for verifying!

@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
Projects
None yet
Development

No branches or pull requests

2 participants