Skip to content

Compiler build depends on libstdc++-static #103606

Description

@kubycsolutions

Location

https://github.com/rust-lang/rust#building-on-a-unix-like-system

Summary

The README lists a number of packages which have to be present for ./x.py build to succeed.

In my Win10/WSL/fedoraremix environment, I found I had to also install libstdc++-static before compilation could start. It now seems to be running without errors (though with some warnings in the .cpp files on -Warray-bounds, -Wnonnull, and -Wcast-function-type).

This may be a quirk of how this fedora was adapted to run under WSL. But adding that dependency to the instructions seems worth considering; it shouldn't hurt anything and might help some.

Activity

  1. added
    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
    on Oct 27, 2022
  2. added
    A-metaArea: Issues & PRs about the rust-lang/rust repository itself
    on Oct 27, 2022
  3. jyn514 commented on Oct 27, 2022

    @jyn514
    Member

    Seems useful :) Happy to take a PR.

  4. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    on Oct 27, 2022
  5. mati865 commented on Oct 28, 2022

    @mati865
    Member

    It's a bit unfortunate default for local development but you can change it with config.toml by setting this line to false:

    #static-libstdcpp = true

    (Also remove .example from the name).

  6. jyn514 commented on Oct 29, 2022

    @jyn514
    Member

    Changing the default also seems fine; maybe not the global default, but the named profiles in src/bootstrap/defaults at least.

  7. kubycsolutions commented on Oct 29, 2022

    @kubycsolutions
    ContributorAuthor

    OK, folks, I need a decision on that. This is the default build configuration, which beginners will not look inside until later. It would seem odd to me to have the basic README.md immediately tell folks they have the option of changing this one parameter. I think we would want their first build to succeed with as little manual work as possible.

    So our choices seem to be to add the static C++ library to the dependencies (and let them decide not to use it later, if so inclined), or to ensure x.py build runs without it -- either by changing config.toml.example, or by changing the default in the code (stylistically better than having the example override the defaults), possibly on a selective basis as @jyn514 proposed.

    The first option is strictly a one-line text change, which I can submit a pull request for. Changing the build's defaults would need to either wait for me to dive significantly deeper into this codebase, or be done by someone else.

    As a raw newbie in Rust, I don't think I should be the one to make that decision -- it's stylistic as much as coding, and I don't yet have any sense of the community's preferences or have a strong opinion either way.

  8. jyn514 commented on Nov 5, 2022

    @jyn514
    Member

    I don't know the history of this option. @jonhoo @mati865 why would you ever want to turn it on, given that it requires you to have an extra dependency turned on?

    @kubycsolutions I think adding a note to the readme that you need the dependency is a good change in the meantime.

  9. mati865 commented on Nov 5, 2022

    @mati865
    Member

    It's useful for dist builds because with that option disabled your binaries will depend on compatible libstdc++. Which might be hard to supply when building rustc for other system.
    For local development I think there is no visible differences (there might be 1% perf improvement with static lib but it doesn't really matter).

  10. jyn514 commented on Nov 5, 2022

    @jyn514
    Member

    Ok, cool. Sounds like we should disable it by default and reenable it in dist builders. @kubycsolutions are you interested in making that change? :)

    Mentoring instructions:

  11. kubycsolutions commented on Nov 5, 2022

    @kubycsolutions
    ContributorAuthor

    Soitenly. Expect pull request a bit later. I need to check your practice -- fork first, or for something this simple just submit PR? (Most projects prefer fork. I tend to cheat on my own.)

    (Woke up, got my eyes uncrossed, edited, noted that gettext needs to be added to the dependencies in the README.md and edited that, build in progress.)

  12. kubycsolutions commented on Nov 5, 2022

    @kubycsolutions
    ContributorAuthor

    Might be overkill for this, but for future reference: What's the recommended smoketest before a PR against rust? (I know the compiler built, and I believe the change is correct, but... (Belt, suspenders, helium balloons, drones.)

  13. jyn514 commented on Nov 5, 2022

    @jyn514
    Member

    @kubycsolutions x test tidy is a good smoke test, or if you're refactoring code, x check. If you've built the compiler successfully that's more than enough; PR CI will catch most of the rest.

  14. kubycsolutions commented on Nov 5, 2022

    @kubycsolutions
    ContributorAuthor

    Good 'nuff.

  15. kubycsolutions commented on Nov 5, 2022

    @kubycsolutions
    ContributorAuthor

    OK. Fixed the missing quote.

    The pull request is still failing its sanity checks. Current failure seems to be
    RuntimeError: failed to find config line for static-stdcpp

    It isn't entirely clear which file it's complaining about, but I'm guessing that it wanted config.llvm_static_stdcpp = true; flipped rather than removed. Trying that.

  16. 11 remaining items

  17. jyn514 commented on Nov 13, 2022

    @jyn514
    Member

    Hmm, we could gate the default on channel = dev, maybe. I think I should have a larger conversation with @Mark-Simulacrum about defaults based on the channel, I think defaulting to profile = user for a non-dev channel would sidestep a lot of these issues.

  18. RalfJung commented on Nov 13, 2022

    @RalfJung
    Member

    Most people working with x.py and developing rustc won't build their own LLVM, x.py will download the one from CI for them. Did this here also change the way that that LLVM is built? What does this change even mean for that setting? It will still affect what rustc_llvm does, but obviously it won't affect how LLVM is built...

  19. kubycsolutions commented on Nov 13, 2022

    @kubycsolutions
    ContributorAuthor
  20. kubycsolutions commented on Nov 13, 2022

    @kubycsolutions
    ContributorAuthor
  21. RalfJung commented on Nov 13, 2022

    @RalfJung
    Member

    To be clear I am happy about this change for entirely unrelated reasons.^^ It brings me one step closer to having rustc_llvm not be rebuilt when I share a build cache between the flatpak sandbox and the host.

    I just don't understand why this helps, since I figured either way I must link to the downloaded LLVM. There is logic in bootstrap that prevents one from (un)setting LLVM options, but it seems when the default changes that still somehow has an effect...

  22. jyn514 commented on Nov 13, 2022

    @jyn514
    Member

    @RalfJung see #104289 for how we got the downloaded llvm to remain unchanged while still changing the default

  23. reopened this on Nov 13, 2022
  24. RalfJung commented on Nov 13, 2022

    @RalfJung
    Member

    Looks like a wrong link? I think you mean #104245.

    But bootstrap then still invokes rustc_llvm as if llvm_static_stdcpp = false -- but the artifact we link against was built with llvm_static_stdcpp = true. Or am I misunderstanding?

  25. jyn514 commented on Nov 13, 2022

    @jyn514
    Member

    That might be a bug ... Can you open an issue?

  26. RalfJung commented on Nov 13, 2022

    @RalfJung
    Member

    What is a bug? I don't know what I am talking about here.^^ I just observe that, if I understood the code correctly, default_opts is used when using LLVM from CI. There are checks that will error if any of these settings is locally changed.

  27. mati865 commented on Nov 13, 2022

    @mati865
    Member

    But bootstrap then still invokes rustc_llvm as if llvm_static_stdcpp = false -- but the artifact we link against was built with llvm_static_stdcpp = true. Or am I misunderstanding?

    We build dist with static libstdc++.

  28. RalfJung commented on Nov 13, 2022

    @RalfJung
    Member

    Yes. And then local bootstrap uses the default value for llvm_static_stdcpp which is now false. So there is a mismatch. Right?

    It seems to work though...

  29. jyn514 commented on Nov 14, 2022

    @jyn514
    Member

    @RalfJung the defaults are mostly ignored when using downloaded LLVM. Instead we use the settings LLVM was built with. The logic is non-trivial but unless you've run into issues I'm inclined to think there's no bug here.

  30. RalfJung commented on Nov 14, 2022

    @RalfJung
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-metaArea: Issues & PRs about the rust-lang/rust repository itselfT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions