anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 33 forks source link

Add dependency diagnostics #325

Closed jcivlin closed 1 year ago

jcivlin commented 1 year ago

It is useful for both: compiler development and user debugging. On option --diagnostics it will produce information about the resolution of dependency set in -p option, also the names, addresses and list of files to compile in the package. It is an example:

Package Dependency Graph pointed by .
ResolutionGraph {
    root_package_path: ".",
    build_options: BuildConfig {
        dev_mode: true,
        test_mode: true,
        generate_docs: false,
        generate_abis: false,
        install_dir: None,
        force_recompilation: false,
        lock_file: None,
        additional_named_addresses: {},
        architecture: Some(
            Move,
        ),
        fetch_deps_only: true,
        skip_fetch_latest_git_deps: true,
        bytecode_version: None,
    },
    root_package: SourceManifest {
        package: PackageInfo {
            name: "my_option_tests",
            version: (
                1,
                5,
                0,
            ),
            authors: [],
            license: None,
            custom_properties: {},
        },
        addresses: Some(
            {
                "std": Some(
                    0x0000000000000000000000000000000000000000000000000000000000000001,
                ),
            },
        ),
        dev_address_assignments: None,
        build: None,
        dependencies: {
            "MoveStdlib": Dependency {
                kind: Local(
                    "../../../move-stdlib/",
                ),
                subst: None,
                version: None,
                digest: None,
            },
        },
        dev_dependencies: {},
    },
    graph: {
        "my_option_tests": [
            (
                "MoveStdlib",
                Outgoing,
            ),
        ],
        "MoveStdlib": [
            (
                "my_option_tests",
                Incoming,
            ),
        ],
    },
    package_table: {
        "MoveStdlib": ResolutionPackage {
            resolution_graph_index: "MoveStdlib",
            source_package: SourceManifest {
                package: PackageInfo {
                    name: "MoveStdlib",
                    version: (
                        1,
                        5,
                        0,
                    ),
                    authors: [],
                    license: None,
                    custom_properties: {},
                },
                addresses: Some(
                    {
                        "std": None,
                    },
                ),
                dev_address_assignments: Some(
                    {
                        "std": 0x0000000000000000000000000000000000000000000000000000000000000001,
                    },
                ),
                build: None,
                dependencies: {},
                dev_dependencies: {},
            },
            package_path: "./../../../move-stdlib/",
            renaming: {},
            resolution_table: {
                "std": 0x0000000000000000000000000000000000000000000000000000000000000001,
            },
            source_digest: "A2FC5BD6D84CA5BEC65DFA3D7FE20E7FB3A29E2AE459B62725CAD8B0252030EB",
        },
        "my_option_tests": ResolutionPackage {
            resolution_graph_index: "my_option_tests",
            source_package: SourceManifest {
                package: PackageInfo {
                    name: "my_option_tests",
                    version: (
                        1,
                        5,
                        0,
                    ),
                    authors: [],
                    license: None,
                    custom_properties: {},
                },
                addresses: Some(
                    {
                        "std": Some(
                            0x0000000000000000000000000000000000000000000000000000000000000001,
                        ),
                    },
                ),
                dev_address_assignments: None,
                build: None,
                dependencies: {
                    "MoveStdlib": Dependency {
                        kind: Local(
                            "../../../move-stdlib/",
                        ),
                        subst: None,
                        version: None,
                        digest: None,
                    },
                },
                dev_dependencies: {},
            },
            package_path: ".",
            renaming: {},
            resolution_table: {
                "std": 0x0000000000000000000000000000000000000000000000000000000000000001,
            },
            source_digest: "8AD9E0DB810A70D670400AC8C50E1D3673D04E595A435946495A50932D869EA8",
        },
    },
}
Dependency and Names
DependencyAndAccountAddress {
    compilation_dependency: [
        "./sources/my_option_tests.move",
        "./../../../move-stdlib/sources/ascii.move",
        "./../../../move-stdlib/sources/vector.move",
        "./../../../move-stdlib/sources/bcs.move",
        "./../../../move-stdlib/sources/type_name.move",
        "./../../../move-stdlib/sources/signer.move",
        "./../../../move-stdlib/sources/unit_test.move",
        "./../../../move-stdlib/sources/fixed_point32.move",
        "./../../../move-stdlib/sources/hash.move",
        "./../../../move-stdlib/sources/error.move",
        "./../../../move-stdlib/sources/bit_vector.move",
        "./../../../move-stdlib/sources/option.move",
        "./../../../move-stdlib/sources/string.move",
    ],
    account_addresses: [
        (
            "std",
            0x0000000000000000000000000000000000000000000000000000000000000001,
        ),
    ],
}
jcivlin commented 1 year ago

Added optional diagnostics (printing out) of order of compilation of modules in dep path and disasm of modules.

jcivlin commented 1 year ago

It prints the byte code and then generated llvm. The convenience of this is that if compilation panics (for a big package, for example) it shows the module where it's happened.