Closed mikolasstuchlik closed 1 year ago
rdar://98370922
It appears that we aren’t passing compiler arguments that are provided in Package.swift
to clangd
.
I came across this issue and I'm wondering if it's also the cause for my issue.
I'm trying to use a C library with Swift on Windows. Since the headers aren't installed in a global location, and pkg-config
isn't available, I've added .unsafeFlags(["-IpathToIncludeDir"])
to the swiftSettings
for my target in Package.swift
.
The target now builds fine, but in the editor, I cannot click through to the definition of an imported C function, and the return types always show <<error type>>
.
On macOS and Linux, this works fine, I'm assuming because it can find the headers through pkg-config
instead?
Is this the same issue, or should I open a new one?
What version of swift are you using? Anything older the latest main snapshot would be too old for Windows at least. But, if it is the right version, then it should be the same issue.
Ah sorry, I'm using the 5.7 release.
Hi @mikolasstuchlik, sorry for only getting back to this now. I just tried reproducing the issue and was unable to. Here’s what I tried.
mkdir /tmp/inc
echo "void testFunction() {}" > /tmp/inc/test.h
InstructionsExecuted.cpp
testFunction
to something different, I get a diagnostic but as it stands right now, I don’t, which means that we correctly find test.h
in /tmp/inc
using the custom search path in Package.swift.Are you still seeing the issue? If yes, could you attach a project that reproduces the issue for you?
Hello @ahoppen. Unfortunately, I have forgot why I've run into this issue. I will look through my archive and let you know if I find something.
I have read the original thread on the Forums. The issue was manifesting when I've attempted to manually include header files of locally built library PCL
.
I have been using Swift 5.6.1
at the time, which was ignoring said flags. However, I have been asked to DEVELOPMENT-SNAPSHOT-2022-08-06
which also failed.
I will need to build PCL again and I will let you know once I have results.
Sorry for the delay on my side. This would have been a lot easier if I had gotten back to you earlier. I really appreciate that you’re giving it another try.
I would like to let you know, that I've been on vacation last week. I will look at the issue next week.
TL;DR I can confirm, that the issue no longer manifests on
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: x86_64-apple-macosx13.0
I have cloned pcl 1.13.1. I have tried to clone, configure and edit https://github.com/mikolasstuchlik/RunPCL which is the same project, where I've observed the issue.
The SourceKit-LSP
in VSCide
works as expected (albeit with considerable delay) and no longers spawns endless clangd
tasks.
I consider this ticket solved.
Great. Thanks for verifying.
I have set up a simple project using hand-built C++ library.
I have added custom C++ header search paths outside of the Package directory using CXXSettings.unsafeFlags as follows:
but SourceKit-LSP ignores those include search paths. I have also tried to add those paths to the Swift Plugin for VSCode provided by SSWG, but this didn't work either.
@ahoppen asked me to try it out on the most recent DEVELOPMENT snapshot of the Swift Toolchain, but it didn't work either. On top of that, the
clangd
started to consume more and more cpu% and I was forced to kill it.This issue was discussed on https://forums.swift.org/t/sourcekit-lsp-seems-to-ignore-cxxsettings-unsafeflags/59503