gcc: don't use old cross-compiler build a new native compiler#249301
Conversation
added 10 commits
August 15, 2023 01:55
This commit lifts the default gcc version to a top-level attribute so it can be overridden.
This commit causes `gccFun` to use `callPackage` with an argument `gcc_major_version` to indicate which version of gcc is desired. It defaults to `default-gcc-version`.
This is stylistic; this code has been inherited from quite a long time ago, and I never understood what the `1` meant. Let's just use `binutilsNoLibc.libc`, which is what `libcCross1` is defined to be, instead.
This commit causes `gccWithoutTargetLibc` to use `callPackage` with an argument `gcc_major_version` to indicate which version of gcc is desired. It defaults to `default-gcc-version`.
…uild gccWithoutTargetLibc is useful not only for building cross compilers, but also for cross-building native compilers. Let's allow it to be used in that situation.
This commit simply changes ``` pkg = lowPrio (wrapCC ... ) ``` into ``` pkg = ... ``` and wraps the sole occurrence of `pkg` with `lowPrio (wrapCC ... )`. It has no effect on eval. I am placing it in a separate commit simply to make the next commit easier to understand.
This commit checks that libgcc is being built by gcc, and that the gcc it is being built by is exactly the same version. Any other combination of compiler and libgcc is unlikely to work.
Closes #244871 This commit checks for the following situation: we are cross-building a native compiler (build!=(host==target)) using a cross-compiler ((build==host)!=target) which is *older than* the compiler being built. We check both the cross-compiler itself as well as the cross-compiler which was used to build the copy of libgcc against which the target libc is linked. This configuration often fails (see #244871 for one example). If you need to cross-build a newer-than-default-gcc-version native compiler, you must first build a newer-than-default-gcc-version cross-compiler. Previously, the user had to figure out how to hack in this upgrade on their own. The code added by this commit inserts the extra compiler build automatically.
This was referenced Aug 15, 2023
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Closes #244871
This commit checks for the following situation: we are
build!=(host==target)(build==host)!=targetwhich is older than the compiler being built.This configuration often fails (see #244871 for one example).
We check both the cross-compiler itself as well as the cross-compiler which was used to build the copy of libgcc against which the target libc is linked.
An example of this situation would be
since the current nixpkgs default version of gcc is
gcc12.If you need to cross-build a newer-than-default-gcc-version native compiler for a different platform, you must first build a newer-than-default-gcc-version cross-compiler which targets that platform. Previously, the user had to figure out how to hack in this upgrade on their own. The code added by this commit inserts the extra compiler build automatically. There are fallback
asserts to warn us if this automation for some reason does not kick in (or you use.overrideAttrsto circumvent it).Things done
x86_64-linux)x86_64-linux)