Skip to content
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

Use a two step Fortran and C++ dependency scanner #12539

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Commits on Oct 1, 2024

  1. environment: build_dir is allowed to be None in the initializer

    But we really expect it to be a string once the initializer is done.
    Therefore, let's set it to `''` just like we do with the scratchdir in
    the case that it's set to None in the initializer.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    072d637 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0eba09d View commit details
    Browse the repository at this point in the history
  3. tests: our fortran order deps are wrong if a new module is introduced

    Because we don't set the appropriate dependencies
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    1a791a3 View commit details
    Browse the repository at this point in the history
  4. backend/ninja: fortran must fully depend on all linked targets

    Because we use this dependency to ensure that any binary module files
    are generated, we must have a full dependency. Otherwise, if a new
    module is added to a dependent target, and used in our target, we race
    the generation of the binary module definition.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    810ae00 View commit details
    Browse the repository at this point in the history
  5. build: annotate all get_all_link_deps the same

    And fix some internal annotations
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    aa5f8bf View commit details
    Browse the repository at this point in the history
  6. build: include each target in get_transitive_link_deps

    Otherwise only shared libraries get installed, which isn't correct.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    cd7acdc View commit details
    Browse the repository at this point in the history
  7. build: add link_whole_targets to get_transitive_link_deps

    Otherwise we again miss out on half of the targets we need
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    3db1209 View commit details
    Browse the repository at this point in the history
  8. backend/ninja: Fortran targets need to -I transitive deps private dirs

    Otherwise they won't be able to find their module outputs.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    de2b237 View commit details
    Browse the repository at this point in the history
  9. backend/ninja: depfile generation needs a full dependency on all scan…

    …ned sources
    
    It is not sufficient to have an order dependency on generated sources.
    If any of those sources change we need to rescan, otherwise we may not
    notice changes to modules.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    346b252 View commit details
    Browse the repository at this point in the history
  10. backend/ninja: fix cross module dependencies

    This requires that every Fortran target that uses modules have a full
    dependency on the scan target of it's dependencies. This means that for
    a three step target `A -> B -> C`, we cannot start compiling any of B
    until all of A is linked, and cannot start compiling any of C until
    all of A and B is linked.
    
    This fixes various kinds of races, but it serializes the build and makes
    it slow. This is the best we can do though, since we don't have any sort
    of portable format for telling C what is in A and B, so C can't know
    what sources to wait on for it's modules to be fulfilled.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    8d9bb1e View commit details
    Browse the repository at this point in the history
  11. backend/ninja: use a two step process for dependency scanning

    This splits the scanner into two discrete steps, one that scans the
    source files, and one that that reads in the dependency information and
    produces a dyndep.
    
    The scanner uses the JSON format from
    https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html,
    which is the same format the MSVC and Clang use for C++ modules
    scanning. This will allow us to more easily move to using MSVC and
    clang-scan-deps when possible.
    
    As an added bonus, this correctly tracks dependencies across TU and
    Target boundaries, unlike the previous implementation, which assumed
    that if it couldn't find a provider that everything was good, but could
    run into issues. Because of that limitation Fortran code had to fully
    depend on all of it's dependencies, transitive or not. Now, when using
    the dep scanner, we can remove that restriction, allowing more
    parallelism.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    86bfada View commit details
    Browse the repository at this point in the history
  12. tests/fortran: also test using a generator()

    We already test for custom_targets and configure_file, but we should
    test a generator too
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    680c117 View commit details
    Browse the repository at this point in the history
  13. tests/fortran: use fs.copyfile

    Since the comment saying we need a generic way to do this is a little
    outdated.
    dcbaker committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    0ce68be View commit details
    Browse the repository at this point in the history