Skip to content

Conversation

jakepetroules
Copy link
Collaborator

@jakepetroules jakepetroules commented Aug 29, 2025

This would have caught a recent regression (#750 / #751).

@jakepetroules jakepetroules force-pushed the eng/PR-cmake-smoke-windows branch 5 times, most recently from 5dba721 to 1b9252a Compare August 29, 2025 09:50
@jakepetroules jakepetroules requested a review from compnerd August 29, 2025 10:27
@jakepetroules
Copy link
Collaborator Author

@compnerd Any idea what's up with this?

LINK : fatal error LNK1104: cannot open file 'libTSCLibc.lib'

It seems TSC can't build itself because TSCBasic is trying to link libTSCLibc.lib when it should actually be TSCLibc.lib, but the wrong spelling is not referenced anywhere on the command line or in response files! Does it somehow get embedded in the .obj files by the compiler?

How is Swift CI currently building TSC successfully with CMake?

@jakepetroules jakepetroules force-pushed the eng/PR-cmake-smoke-windows branch from 1b9252a to bbcbc04 Compare August 29, 2025 23:46
@compnerd
Copy link
Member

@compnerd Any idea what's up with this?

LINK : fatal error LNK1104: cannot open file 'libTSCLibc.lib'

It seems TSC can't build itself because TSCBasic is trying to link libTSCLibc.lib when it should actually be TSCLibc.lib, but the wrong spelling is not referenced anywhere on the command line or in response files! Does it somehow get embedded in the .obj files by the compiler?

How is Swift CI currently building TSC successfully with CMake?

Yes, the spelling is embedded into the object file by the compiler. The new prefix of lib for the static libraries is only available as of 6.2 I believe. For the time being, you can remove -D CMAKE_STATIC_LIBRARY_PREFIX_Swift=lib until we update to a new enough compiler where it will break in the inverse way: libTSCLibc.lib not found as the file on disk will be TSCLibc.lib as written out by CMake/Ninja, but the compiler expects it to be libTSCLibc.lib to indicate that that it is a (Swift) static library.

@jakepetroules
Copy link
Collaborator Author

jakepetroules commented Aug 30, 2025

Yes, the spelling is embedded into the object file by the compiler. The new prefix of lib for the static libraries is only available as of 6.2 I believe

This is all with nightly (6.3) toolchains...

remove -D CMAKE_STATIC_LIBRARY_PREFIX_Swift=lib

"remove"? I was able to get past this error by adding that flag.

That said, I now get this:

clang++: error: no such file or directory: '\INCREMENTAL:NO'

...due to this flag being passed manually here and here. Should we actually remove those? It seems /INCREMENTAL:NO makes more sense to pass for the build as a whole (which Swift CI does) rather than having it on individual targets. These flags were added by swiftlang/swift-llbuild#475 back in 2019. The justification was "Disable incremental linking so llbuild.ilk's don't conflict", which made sense as the library and tool had the same OUTPUT_NAME back then, which you recently fixed in swiftlang/swift-llbuild#1005, so I think that workaround seems no longer necessary.

If I instead set CLANG_C_COMPILER / CLANG_CXX_COMPILER to clang-cl to work around the unrecognized flags issue, I'm getting this:

error: processError(terminationReason: Foundation.Process.TerminationReason.exit, terminationStatus: 1)
C:\Windows\system32\cmd.exe /C "cd . && C:\Users\ContainerAdministrator\AppData\Local\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swiftc.exe -j 4 -num-threads 4 -emit-library -module-cache-path C:\source\.build\plugins\cmake-smoke-test\outputs\module-cache -Onone -g -libc MD  /machine:x64 /debug /INCREMENTAL -cxx-interoperability-mode=default -Xlinker -implib:lib\SWBCSupport.lib   -o bin\SWBCSupport.dll Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\CLibclang.cpp.obj Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\CLibRemarksHelper.c.obj Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\empty.swift.obj  -lBlocksRuntime.lib && cd ."
clang++: error: no such file or directory: '\machine:x64'
clang++: error: no such file or directory: '\debug'
clang++: error: no such file or directory: '\INCREMENTAL'

jakepetroules added a commit to jakepetroules/swift-llbuild that referenced this pull request Aug 30, 2025
…n Windows

These were originally added 6 years ago in swiftlang#475 to "Disable incremental linking so llbuild.ilk's don't conflict" because at the time the command line tool and library targets were given the same OUTPUT_NAME, which conflicted. In swiftlang#1005 these targets were given distinct names, so the workaround should no longer be necessary.

This helps unblock swiftlang/swift-build#757 because this flag is currently added without regard for the specific compiler driver in use, so the flag might not work based on whether clang-cl.exe or cl.exe vs clang.exe (where it would require a -Xlinker prefix), is used.
@jakepetroules
Copy link
Collaborator Author

It seems fairly clear that those llbuild flags should be removed, so I went ahead and put that up for review: swiftlang/swift-llbuild#1011

@compnerd
Copy link
Member

Yes, the spelling is embedded into the object file by the compiler. The new prefix of lib for the static libraries is only available as of 6.2 I believe

This is all with nightly (6.3) toolchains...

remove -D CMAKE_STATIC_LIBRARY_PREFIX_Swift=lib

"remove"? I was able to get past this error by adding that flag.

Ah, okay. I always get confused about the directionality :(. Its just a question of matching the output from CMake to match what the compiler wants.

That said, I now get this:

clang++: error: no such file or directory: '\INCREMENTAL:NO'

...due to this flag being passed manually here and here. Should we actually remove those? It seems /INCREMENTAL:NO makes more sense to pass for the build as a whole (which Swift CI does) rather than having it on individual targets. These flags were added by swiftlang/swift-llbuild#475 back in 2019. The justification was "Disable incremental linking so llbuild.ilk's don't conflict", which made sense as the library and tool had the same OUTPUT_NAME back then, which you recently fixed in swiftlang/swift-llbuild#1005, so I think that workaround seems no longer necessary.

We need to disable incremental linking as that will break everything as the Swift runtime is unable to deal with the additional padding in the protocol tables which is required for incremental linking. We should be passing /INCREMENTAL:NO as -Xlinker /INCREMENTAL:NO. This is just a matter of missing -Xlinker prefixes (this is behavioural differences between various CMake releases).

If I instead set CLANG_C_COMPILER / CLANG_CXX_COMPILER to clang-cl to work around the unrecognized flags issue, I'm getting this:

error: processError(terminationReason: Foundation.Process.TerminationReason.exit, terminationStatus: 1)
C:\Windows\system32\cmd.exe /C "cd . && C:\Users\ContainerAdministrator\AppData\Local\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swiftc.exe -j 4 -num-threads 4 -emit-library -module-cache-path C:\source\.build\plugins\cmake-smoke-test\outputs\module-cache -Onone -g -libc MD  /machine:x64 /debug /INCREMENTAL -cxx-interoperability-mode=default -Xlinker -implib:lib\SWBCSupport.lib   -o bin\SWBCSupport.dll Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\CLibclang.cpp.obj Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\CLibRemarksHelper.c.obj Sources\SWBCSupport\CMakeFiles\SWBCSupport.dir\empty.swift.obj  -lBlocksRuntime.lib && cd ."
clang++: error: no such file or directory: '\machine:x64'
clang++: error: no such file or directory: '\debug'
clang++: error: no such file or directory: '\INCREMENTAL'

I would say just write this as -Xlinker /machine:x64 -Xlinker /debug -Xlinker /INCREMENTAL:NO.

We should pass in -g -debug-info-format=codeview to generate the proper debug information, or we should consider dropping -Xlinker /debug if we do not want to generate debug information.

jakepetroules added a commit to swiftlang/swift-llbuild that referenced this pull request Sep 2, 2025
…n Windows

These were originally added 6 years ago in #475 to "Disable incremental linking so llbuild.ilk's don't conflict" because at the time the command line tool and library targets were given the same OUTPUT_NAME, which conflicted. In #1005 these targets were given distinct names, so the workaround should no longer be necessary.

This helps unblock swiftlang/swift-build#757 because this flag is currently added without regard for the specific compiler driver in use, so the flag might not work based on whether clang-cl.exe or cl.exe vs clang.exe (where it would require a -Xlinker prefix), is used.
@jakepetroules jakepetroules force-pushed the eng/PR-cmake-smoke-windows branch from bbcbc04 to 764b703 Compare September 2, 2025 23:36
@jakepetroules jakepetroules marked this pull request as ready for review September 3, 2025 00:15
@jakepetroules
Copy link
Collaborator Author

@swift-ci test

@jakepetroules jakepetroules merged commit bbf6db0 into swiftlang:main Sep 3, 2025
37 checks passed
@jakepetroules jakepetroules deleted the eng/PR-cmake-smoke-windows branch September 3, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants