Skip to content

In LLDB section of Getting Started, modify instructions for Windows 10 #123

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

Open
KimTheLearner opened this issue Aug 25, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@KimTheLearner
Copy link

Page and Section

Page: Swift - Getting Started
Section: Using the LLDB Debugger

Requested Change

Where it says to run:

swiftc -g Factorial.swift

please convert these instructions to be platform based, perhaps using the On macOS/On Linux/On Windows technique used elsewhere on the page. Then in the Windows section, replace the swiftc command with the following:

set SWIFTFLAGS=-sdk %SDKROOT% -I %SDKROOT%\usr\lib\swift -L %SDKROOT%\usr\lib\swift\windows
swiftc -g -use-ld=lld -Xlinker -debug:dwarf Factorial.swift -o Factorial.exe %SWIFTFLAGS%

The "ls" command should also be replaced with the "dir" command and its command output.

Why Needed

Without the "SWIFTFLAGS" options, on Windows 10 swiftc gets:
error: clang: error: no such file or directory: 'C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\windows\x86_64\swiftrt.obj'. :0: error: link command failed with exit code 1 (use -v to see invocation)

Without the "-o", swiftc produces an executable file with no .exe extension.

I found these options in: Compiling a simple hello.swift on Windows

If you use "SWIFTFLAGS" and "-o", but without the "-use-ld=lld -Xlinker -debug:dwarf", on Windows 10 the lldb breakpoint command "b 2" (as shown in Getting Started) gets:
error: No selected frame to use to find the default file. error: No file supplied and no default file available.
Most breakpoint commands fail similarly, I did find one that does not elicit an error: "b main". However after giving the "r" run command, lldb breaks at main, but then shows assembly code instead of swift source code.

I found these options in the build commands made available in VS Code when you have the 'Swift' extension. (THANKS!)

Environment

This is needed for Swift 5.6.1 on Windows 10, and probably prior versions.

References

These changes for Getting Started were first requested in the following issues, before Getting Started was open-sourced:
SWIFTFLAGS/-o -- swiftlang/swift#58435
-use-ld=lld -Xlinker -debug:dwarf -- swiftlang/swift#58449

@KimTheLearner KimTheLearner added the bug Something isn't working label Aug 25, 2022
@0xTim
Copy link
Member

0xTim commented Aug 25, 2022

@Kim4444 Thanks for reporting this! Do you fancy doing a PR to update the instructions?

@KimTheLearner
Copy link
Author

@0xTim Thanks for looking at this so quickly! I can't work on this in the immediate future, but if it's still open after, I would be happy to take a stab at it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants