Skip to content

Support for ad-hoc diagnostic and fixits #25

@jerrymarino

Description

@jerrymarino

Consider adding a way to emit ad-hoc diagnostics and fixits for swift and clang. There's a different codepath for these in Xcode's UI with xcbuild. It's likely possible to add this support in just a SWIFT_EXEC stub, however it might interface nicely inside of this build system.

Prototype

FunnyLookingSwiftOutput

Prototype impl

I've created a prototype of this by stubbing out SWIFT_EXEC, and attached a demo project with the relevant details

# Example of stubbing out `SWIFT_EXEC` with a program that can transmit arbitrary diags
def _main():
    # type: () -> None
    if sys.argv[1:] == ["-v"]:
        os.system("swiftc -v")
        return

    _touch_deps_files(sys.argv)
    _touch_swiftmodule_files(sys.argv)


    os.system("mkdir -p  /Users/jmarino/Library/Developer/Xcode/DerivedData/Some-hettvdxoaohocfempirmoljvflkq/Build/Intermediates.noindex/Some.build/Debug/Some.build/Objects-normal/x86_64/")

    # During xcbuild, the build system seems to read in a dia. This is a
    # contrived diagnostic file, but xcbuild reads it in once swiftc emits it.
    # /tmp/main.dia resides in-tree at TMP_main.dia
    os.system("cp /tmp/main.dia /Users/jmarino/Library/Developer/Xcode/DerivedData/Some-hettvdxoaohocfempirmoljvflkq/Build/Intermediates.noindex/Some.build/Debug/Some.build/Objects-normal/x86_64/main.dia")

    os.system("echo xxxxx > /Users/jmarino/Library/Developer/Xcode/DerivedData/Some-hettvdxoaohocfempirmoljvflkq/Build/Intermediates.noindex/Some.build/Debug/Some.build/Objects-normal/x86_64/main.o")

    # Under the xcbuild, it runs the swift compiler with -parseable output. XCBuild
    # parses this is and dumps message pack material over the stdout file descriptor 
    # which Xcode further processes.
    # NOTE: for swift compilation, the .dias must be on the file system in this file.
    # /tmp/out resides in-tree at TMP_out
    os.system("cat /tmp/out >&2")

I have attached an example of the swiftc stub working - DiagReversingExample.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions