Skip to content
Open
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
4 changes: 4 additions & 0 deletions stdlib/public/Platform/tgmath.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ public func lgamma(_ x: ${T}) -> (${T}, Int) {
@_transparent
public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
var quo = Int32(0)
#if !os(Windows)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem should occur for any platform that doesn't differentiate long double from double right?

I think that rather than differentiating this on os(Windows), we want to use something to differentiate this based on sizeof(long double) == sizeof(double).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. This also requires another condition: the way the Windows headers declare it. This doesn't occur and the following reproducer test doesn't err on macos because the macos C++ header imports the C remquo into the std namespace for C++ rather than declaring another remquo for long double that would cause an overload with C remquo for long in Swift. I added text on it in the bug description here. So I think this is specific to Windows.

let rem = unsafe remquo${f}(${CT}(x), ${CT}(y), &quo)
#else
let rem = unsafe corecrt.remquo${f}(${CT}(x), ${CT}(y), &quo)
#endif
return (${T}(rem), Int(quo))
}
% if T == 'Float80':
Expand Down
54 changes: 54 additions & 0 deletions test/ScanDependencies/win-crt-explicit-cxx.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// REQUIRES: OS=windows-msvc

// Test building the CRT module with C++ interop enabled on Windows

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -scan-dependencies -module-name Test \
// RUN: -module-cache-path %t/clang-module-cache -disable-objc-interop \
// RUN: -cxx-interoperability-mode=default \
// RUN: -parse-stdlib -module-load-mode prefer-serialized \
// RUN: %t/Test.swift -o %t/deps.json -I %t 2>&1

// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:SAL > %t/SAL.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:vcruntime > %t/vcruntime.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/SwiftShims.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json Swift > %t/Swift.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_Builtin_stddef > %t/_Builtin_stddef.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:corecrt > %t/corecrt.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:std_config > %t/std_config.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_float > %t/_float.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_fenv > %t/_fenv.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_stdlib > %t/_stdlib.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_malloc > %t/_malloc.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_Builtin_intrinsics > %t/_Builtin_intrinsics.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:ucrt > %t/ucrt.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:std > %t/std.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:_complex > %t/_complex.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftOverlayShims > %t/SwiftOverlayShims.cmd
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json CRT > %t/CRT.cmd

// Remove the candidate module file flag to force building from the swiftinterface file.
// RUN: cat %t/CRT.cmd | sed '/candidate-module-file/d; /CRT.swiftmodule.*swiftmodule/d' > %t/CRT.mod.cmd

// RUN: %swift_frontend_plain @%t/SAL.cmd 2>&1
// RUN: %swift_frontend_plain @%t/vcruntime.cmd 2>&1
// RUN: %swift_frontend_plain @%t/SwiftShims.cmd 2>&1
// RUN: %swift_frontend_plain @%t/Swift.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_Builtin_stddef.cmd 2>&1
// RUN: %swift_frontend_plain @%t/corecrt.cmd 2>&1
// RUN: %swift_frontend_plain @%t/std_config.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_float.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_fenv.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_stdlib.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_malloc.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_Builtin_intrinsics.cmd 2>&1
// RUN: %swift_frontend_plain @%t/ucrt.cmd 2>&1
// RUN: %swift_frontend_plain @%t/std.cmd 2>&1
// RUN: %swift_frontend_plain @%t/_complex.cmd 2>&1
// RUN: %swift_frontend_plain @%t/SwiftOverlayShims.cmd 2>&1
// RUN: %swift_frontend_plain @%t/CRT.mod.cmd 2>&1

//--- Test.swift
import CRT