Skip to content

Conversation

@antoyo
Copy link
Contributor

@antoyo antoyo commented Nov 26, 2025

r? @Kobzol

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

This PR changes how GCC is built. Consider updating src/bootstrap/download-ci-gcc-stamp.

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

Kobzol is not on the review rotation at the moment.
They may take a while to respond.

@antoyo antoyo marked this pull request as draft November 26, 2025 14:04
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
@antoyo
Copy link
Contributor Author

antoyo commented Nov 26, 2025

@Kobzol: I'm sending this PR to gather some feedback from you or others.

How can I add tests for this new bootstrap config?
Where should I document this new config?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Nov 28, 2025

☔ The latest upstream changes (presumably #149348) made this pull request unmergeable. Please resolve the merge conflicts.

@antoyo antoyo force-pushed the bootstrap-config/libgccjit-libs-dir branch from 1bf3007 to 2125647 Compare November 28, 2025 16:41
@Kobzol
Copy link
Member

Kobzol commented Dec 6, 2025

I will focus on #149426 first, as I think that we should first deal with the compiler/cg_gcc side of things, before we go modify bootstrap.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, although the implementation needs some changes. I'd be happy to play with this if you don't want to deal with doing these bootstrap changes.

View changes since this review

@bors
Copy link
Collaborator

bors commented Dec 9, 2025

☔ The latest upstream changes (presumably #149426) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label Dec 11, 2025
@antoyo antoyo force-pushed the bootstrap-config/libgccjit-libs-dir branch from 7eb0416 to dc178b5 Compare December 11, 2025 21:02
antoyo and others added 4 commits December 11, 2025 19:07
This will allow users to provide pre-built cross-compiled dylibs, while still downloading common (e.g. x64) dylibs from the CI.
@Kobzol
Copy link
Member

Kobzol commented Dec 12, 2025

I refactored the code a bit to more explicitly model that we have multiple target libgccjit dylibs per host, and also to enable both downloading from CI and using prebuilt libgccjit.so files (so that people don't also have to build their x64 libgccjit.so from scratch). Please let me know if it makes sense to you.

@rust-log-analyzer

This comment has been minimized.

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

Please let me know if it makes sense to you.

This commit makes sense to me.
For the other commit, I do not understand bootstrap enough to understand what's happening here. Would that commit help keep the m68k libgccjit.so file that was deleted? Do you want me to try to cross-compile rustc locally with that commit?

@Kobzol
Copy link
Member

Kobzol commented Dec 12, 2025

Do you want me to try to cross-compile rustc locally with that commit?

If you already have it prepared, yeah, you could try it. Although CI failed, so maybe there's something else wrong.

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

If you already have it prepared, yeah, you could try it. Although CI failed, so maybe there's something else wrong.

Good. I try that right away.

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

If you already have it prepared, yeah, you could try it. Although CI failed, so maybe there's something else wrong.

The command finished running and the issue with the m68k libgccjit.so file being deleted still seems there. Any ideas of how to fix this? Do the steps I posted above give you any hint?

@Kobzol
Copy link
Member

Kobzol commented Dec 12, 2025

I suspect I know where is the issue. bootstrap hacks around this for LLVM, but I don't like how it is done (I want to refactor how LLVM is handled in bootstrap, as it's super messy right now, but it's very hard).

In that case, I would actually suggest to sidestep this issue entirely and use a different directory structure: <sysroot>/lib/rustlib/<host-target>/codegen-backends/lib/<target>/libgccjit.so. This I think also makes it clearer that cg_gcc is actually invoked on <host-target>, and it will use libraries from its lib subdirectory, rather than from completely different directories in <sysroot>/lib/rustlib/....

This will run into an issue with Rustup later, but we would have the exact same issue even with the current layout, so it doesn't really matter.

What do you think?

@rust-log-analyzer

This comment has been minimized.

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

What do you think?

I'm OK with this directory structure.
But since this is still in rustlib, won't that get deleted too?

@Kobzol
Copy link
Member

Kobzol commented Dec 12, 2025

I certainly hope not 😆 Bootstrap should only be deleting rustlib/<target>/lib, I think. If not, then I misunderstood the issue.

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

I certainly hope not 😆 Bootstrap should only be deleting rustlib/<target>/lib, I think. If not, then I misunderstood the issue.

Ok. I'll try this new directory structure locally to see if that works. If so, I'll push it here.

@rust-log-analyzer

This comment has been minimized.

return;
}

// <rustc>/lib/<host-target>/codegen-backends
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember @bjorn3 had some concerns about a similar directory structure.
@bjorn3: Could you please confirm that this won't result in having multiple directories in /usr/lib with different target triples when doing a global install?

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

There seems to be one issue: the native m68k libgccjit.so library is not copied in the sysroot. Instead, it takes a native x86 libgccjit.so:

rust/build/m68k-unknown-linux-gnu/stage2/lib/rustlib/m68k-unknown-linux-gnu/codegen-backends/lib/m68k-unknown-linux-gnu/libgccjit.so:       ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7fb2bb8bf0436221a668bcd67d6042c067463bd6, with debug_info, not stripped

@Kobzol: Any idea what could be wrong here?

Edit: Could it be the step "Uplifting library (stage1:x86_64-unknown-linux-gnu -> stage2:m68k-unknown-linux-gnu)" that does that?

@antoyo
Copy link
Contributor Author

antoyo commented Dec 12, 2025

My investigation leads me to believe that we don't fill properly dylibs here.

My understanding is that for a specific stage, we need:

  • target of the built rustc (usually x86-64 for stage1, but here is m68k for stage2) -> target of the build rustc (here would be x86-64 -> x86-64 for stage1 and m68k -> m68k for stage2).
  • and possibly target of the build rustc (usually x86-64 for stage1) -> other targets configured (here is m68k) (here would be x86-64 -> m68k for stage1).

But that code seems to consider the host target (the one used to build the rustc) instead.

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

Labels

A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants