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-13692] NSCocoaErrorDomain 256 during compile #4492

Closed
swift-ci opened this issue Oct 7, 2020 · 7 comments
Closed

[SR-13692] NSCocoaErrorDomain 256 during compile #4492

swift-ci opened this issue Oct 7, 2020 · 7 comments
Assignees

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Oct 7, 2020

Previous ID SR-13692
Radar None
Original Reporter alex_taffe (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Windows 10, latest swift build, VS2019

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, Windows
Assignee @stevapple
Priority Medium

md5: 949503f9dad0affab9d5d086235d5ae3

Issue Description:

I'm attempting to link a C library (libwebsockets) against Swift on Windows. Using similar steps on macOS worked fine. My steps were to make a `SourceCache` directory at the root of the C drive, then in the x64 native command line:

cd C:\SourceCache
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bash
vcpkg.exe integrate install
vcpkg.exe install libwebsockets

To compile libwebsockets. Then I am using this example swift project:

cd C:\SourceCache
git clone https://github.com/ataffeqeexo/websocket-test.git
cd websocket-test
swift package update
swift build -Xswiftc -lwebsockets -Xswiftc -I"C:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include" -Xswiftc -I"C:\SourceCache\vcpkg\packages\libuv_x64-windows\include" -Xswiftc -I"C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include" -Xswiftc -L"C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\lib" -Xlinker -lwebsockets -Xlinker /INCREMENTAL:NO -v

This resolves all of the packages properly, appears to compile properly, but fails at the link stage with a cryptic error: `error: Error Domain=NSCocoaErrorDomain Code=256 "(null)"`. 256 is `NSFileReadUnknownError` which doesn't help a ton. Full output below:

C:\SourceCache\data\websocket-test>swift build -Xswiftc -lwebsockets -Xswiftc -I"C:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include" -Xswiftc -I"C:\SourceCache\vcpkg\packages\libuv_x64-windows\include" -Xswiftc -I"C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include" -Xswiftc -L"C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\lib" -Xlinker -lwebsockets -Xlinker /INCREMENTAL:NO -v
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -print-target-info
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -print-target-info
C:\SourceCache\data\websocket-test: warning: Creating library C:\Users\Alex\AppData\Local\Temp\TemporaryDirectory.PfA8aa\websocket-test-manifest.lib and object C:\Users\Alex\AppData\Local\Temp\TemporaryDirectory.PfA8aa\websocket-test-manifest.exp
C:\SourceCache\data\websocket-test\.build\checkouts\Clibwebsockets: warning: Creating library C:\Users\Alex\AppData\Local\Temp\TemporaryDirectory.YAA7K5\clibwebsockets-manifest.lib and object C:\Users\Alex\AppData\Local\Temp\TemporaryDirectory.YAA7K5\clibwebsockets-manifest.exp
'MyLibrary' C:\SourceCache\data\websocket-test: warning: ignoring duplicate product 'MyLibrary'
uname
pkg-config --variable pc_path pkg-config
warning: failed to retrieve search paths with pkg-config; maybe pkg-config is not installed
'Clibwebsockets' libwebsockets.pc: warning: couldn't find pc file for libwebsockets
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -module-name MyLibrary -incremental -emit-dependencies -emit-module -emit-module-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.swiftmodule -output-file-map C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\output-file-map.json -c C:\SourceCache\data\websocket-test\Sources\MyLibrary\MyLibrary.swift C:\SourceCache\data\websocket-test\Sources\MyLibrary\main.swift -I C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug -target x86_64-unknown-windows-msvc -swift-version 5 -enable-batch-mode -index-store-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\index\store -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -L C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows -resource-dir C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -I C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -L C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows -libc MD -Onone -enable-testing -g -j8 -DSWIFT_PACKAGE -DDEBUG -Xcc -fmodule-map-file=C:\SourceCache\data\websocket-test\.build\checkouts\Clibwebsockets\Sources\Clibwebsockets\module.modulemap -module-cache-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -parseable-output -lwebsockets -IC:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include -IC:\SourceCache\vcpkg\packages\libuv_x64-windows\include -IC:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include -LC:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\lib
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -frontend -c -primary-file C:\SourceCache\data\websocket-test\Sources\MyLibrary\MyLibrary.swift C:\SourceCache\data\websocket-test\Sources\MyLibrary\main.swift -emit-module-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary~partial.swiftmodule -emit-module-doc-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary~partial.swiftdoc -emit-module-source-info-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary~partial.swiftsourceinfo -emit-dependencies-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary.d -emit-reference-dependencies-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary.swiftdeps -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug -I C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -I C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -I C:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include -I C:\SourceCache\vcpkg\packages\libuv_x64-windows\include -I C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include -enable-testing -g -module-cache-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -resource-dir C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=C:\SourceCache\data\websocket-test\.build\checkouts\Clibwebsockets\Sources\Clibwebsockets\module.modulemap -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL -module-name MyLibrary -o C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary.swift.o -index-store-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\index\store -index-system-modules
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -frontend -c C:\SourceCache\data\websocket-test\Sources\MyLibrary\MyLibrary.swift -primary-file C:\SourceCache\data\websocket-test\Sources\MyLibrary\main.swift -emit-module-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main~partial.swiftmodule -emit-module-doc-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main~partial.swiftdoc -emit-module-source-info-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main~partial.swiftsourceinfo -emit-dependencies-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main.d -emit-reference-dependencies-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main.swiftdeps -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug -I C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -I C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -I C:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include -I C:\SourceCache\vcpkg\packages\libuv_x64-windows\include -I C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include -enable-testing -g -module-cache-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -resource-dir C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=C:\SourceCache\data\websocket-test\.build\checkouts\Clibwebsockets\Sources\Clibwebsockets\module.modulemap -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL -module-name MyLibrary -o C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main.swift.o -index-store-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\index\store -index-system-modules
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -frontend -merge-modules -emit-module C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary~partial.swiftmodule C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\main~partial.swiftmodule -parse-as-library -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug -I C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -I C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -I C:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include -I C:\SourceCache\vcpkg\packages\libuv_x64-windows\include -I C:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include -enable-testing -g -module-cache-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -resource-dir C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=C:\SourceCache\data\websocket-test\.build\checkouts\Clibwebsockets\Sources\Clibwebsockets\module.modulemap -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL -emit-module-doc-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.swiftdoc -emit-module-source-info-path C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.swiftsourceinfo -module-name MyLibrary -o C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.swiftmodule
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -modulewrap C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.swiftmodule -o C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\MyLibrary.swiftmodule.o -target x86_64-unknown-windows-msvc
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -L C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows -resource-dir C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift -I C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -L C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows -libc MD -L C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug -o C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.exe -module-name MyLibrary -emit-executable @C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.product\Objects.LinkFileList -target x86_64-unknown-windows-msvc -Xlinker -lwebsockets -Xlinker /INCREMENTAL:NO -lwebsockets -IC:\SourceCache\vcpkg\packages\openssl-windows_x64-windows\include -IC:\SourceCache\vcpkg\packages\libuv_x64-windows\include -IC:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\include -LC:\SourceCache\vcpkg\packages\libwebsockets_x64-windows\lib
LINK : warning LNK4044: unrecognized option '/lwebsockets'; ignored
   Creating library C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.lib and object C:\SourceCache\data\websocket-test\.build\x86_64-unknown-windows-msvc\debug\MyLibrary.exp
error: Error Domain=NSCocoaErrorDomain Code=256 "(null)"
@swift-ci
Copy link
Contributor Author

swift-ci commented Oct 7, 2020

Comment by Alex Taffe (JIRA)

Will note that this is actually compiling correctly. The

error: Error Domain=NSCocoaErrorDomain Code=256 "(null)"

message looks like an error, but the exe is created correctly.

@compnerd
Copy link
Collaborator

compnerd commented Oct 7, 2020

The error is related to the invocation of pkg-config.

@swift-ci
Copy link
Contributor Author

swift-ci commented Oct 7, 2020

Comment by Alex Taffe (JIRA)

I installed pkg-config through chocolatey, but was still seeing warnings that pkg-config was failing to execute. My guess is that my path isn’t configured properly or something

@compnerd
Copy link
Collaborator

compnerd commented Nov 2, 2020

I believe that this is due to the Windows host not being in developer mode, and the user not being an administrator user (which is expected) and not having been given the rights to create symbolic links. Could you please verify that the issue is resolved when you enable developer mode on Windows? See https://docs.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging for more details on developer mode.

@compnerd
Copy link
Collaborator

compnerd commented Jun 2, 2021

I believe that this is just the lack of developer mode, which is being better tracked in SR-14259.

@stevapple
Copy link
Contributor

It’s actually another problem with Swift’s (not Git’s) symlink support, which still needs further discussion.
apple/swift-package-manager#3490 is making the first step to minimize its impact, but it cannot actually solve the problem.

@stevapple
Copy link
Contributor

Addressed by apple/swift-package-manager#3490

@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

3 participants