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

[C++20] [Modules] Introduce thin BMI #71622

Closed
wants to merge 2 commits into from
Closed

Commits on Nov 8, 2023

  1. [C++20] [Modules] Introduce thin BMI

    Close llvm#71034
    
    This patch introduces thin BMI, which doesn't contain the definitions of
    functions and variables if its definitions won't contribute to the ABI.
    
    Testing is a big part of the patch. We want to make sure the thin BMI
    contains the same behavior with the existing and relatively stable
    fatBMI. This is pretty helpful for further reduction.
    
    For user interfeaces, this patch introduces `-fthinBMI-output=`
    arguments to specify the position of thin BMI. This should be used when
    compiling a single module unit.
    
    The design is helpful to use thin BMI in two phase compilations too.
    With thin BMI, In two phase compilations, we'll generate 2 BMIs, one
    thin BMI for being used by consumers, one fat BMI for compiling itself
    to object files. Maybe it sounds confusing to have 2 BMIs for one module
    unit. But only the thin BMI will be the BMI we're talking about
    generally and the fat BMI is only visible by the module unit itself.
    
    With one phase compilation, we may find the behavior of
    `-fthinBMI-output=` is pretty similar with `-fmodule-output=`, except
    one generating thin BMI and the other generating fat BMI. The design
    here is based on 2 things:
    (1) The serialization of C++ is pretty complex. We can't be sure we're handling
    every detail correctly in the every beginning.
    (2) The fat BMI is relatively widely used and relatively stable.
    So it looks not good to replace the fat BMI immediately with thin BMI.
    
    But, of course, in the end of the day, we want the consumers to use the
    thin BMI only. When that day comes, the `-fmodule-output=` will be an alias to
    `-fthinBMI-output=`.
    
    Another design choice is to reuse `-fmodule-output=` and introduce a flag
    `-femit-thin-BMI`. Then `-femit-thin-BMI -fmodule-output=` will have the same effect
    with `-fthinBMI-output=` now.
    The flag `-femit-thin-BMI` should be opt-in now and opt-off later
    and finally deprecated.
    
    The roadmap for thin BMI in my mind is:
    
    (1) In clang18, release thin BMI and mark it as experimental. Also
    encourage users and build systems to try this new mode.
    (2) In clang19 or clang20 (based on the issue feedbacks), remove the
    experimental mark for thin BMI and mark fat BMI as deprecated to be
    used by consumers.
    (3) In clang21 or clang22, error out if we found the users are trying to
    import a fat BMI.
    ChuanqiXu9 committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    3f98ce1 View commit details
    Browse the repository at this point in the history
  2. fmt

    ChuanqiXu9 committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    387f312 View commit details
    Browse the repository at this point in the history