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.
Is the SourceKit-LSP ignoring
unsafeFlags intentionally and if so, is there any workaround?
I have tried using
swift package generate-xcodeproj and Xcode project works correctly (all the include paths are configured correctly).
You are probably best posting this in the sourcekit-lsp section of the forums. The VS Code extension is not involved at this point. The only time it gets involved is when you are adding cxxSettings via the command line build arguments
I have tried that too, using the Workspace Extension Settings and it didn't work for me.
I guess the
sourcekit-lsp was installed alongside the Xcode Toolchain. The
sourcekit-lsp program itself didn't respond for command
mikolasstuchlik@Mikolas-MacBook-Pro ~ % swift --version
swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-188.8.131.523.66 clang-13184.108.40.206)
mikolasstuchlik@Mikolas-MacBook-Pro ~ % which sourcekit-lsp
mikolasstuchlik@Mikolas-MacBook-Pro ~ % ls -la /usr/bin/sourcekit-lsp
-rwxr-xr-x 76 root wheel 167120 9 kvě 23:30 /usr/bin/sourcekit-lsp
Ah, OK, that wouldn’t contain the fix yet.
Could you try toe following
- Download the most recent main open source snapshot toolchain from Swift.org - Download Swift
Swift: Path in the settings of the Swift VSCode plugin to
- See if the issue still reproduces
I have followed your steps, the
settings.json has following lines:
but it didn't fix the issue. (I have restarted window multiple times.)
I have also tried to build the project via
mikolasstuchlik@10 RunLib % rm -rf .build
mikolasstuchlik@10 RunLib % /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-06-a.xctoolchain/usr/bin/swift build
and it started to compile the project really slowly, my M1 MacBook Pro (base model) is going 90 °C on CPU and 7200 rpm on fan. Also
clangd is the most cpu% process right now. (Edit 2: It also requested 1.34 GB for project with ~ 200 lines of C++ and Swift code.) (Edit 3: Now
clangd uses 624% of the CPU.)
(It is compiling 22 line
.cpp file which includes
#include <boost/multiprecision/cpp_int.hpp> ~ 10 minutes and isn't finished yet :D
I have aborted the build, restarted the VSCode window, and another
clangd process appeared, but it still uses 700% CPU.
Closing VSCode would not help, so I have killed all the
clangd task manually.
Thanks for checking. Looks like there’s another issue then. Could you file a bug report at Issues · apple/sourcekit-lsp · GitHub for this issue?
clangd using so much CPU is definitely an unrelated bug and probably an issue of
clangd itself and not
sourcekit-lsp. Anyway, could you file a separate bug report for that issue and include a project that reproduces the issue (if possible)?