Skip to content

Sync with upstream 0d52a736a3856871761c89fefa59c2ff39f3a5f8 #3860

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

Merged
merged 1,605 commits into from
Jul 22, 2025
Merged

Conversation

dkm
Copy link
Member

@dkm dkm commented Jun 26, 2025

This is a sync with upstream gcc:

@dkm dkm self-assigned this Jun 26, 2025
@dkm dkm marked this pull request as draft June 26, 2025 20:18
@dkm dkm force-pushed the dkm/bump-2025-06-26 branch from d1c858c to 84d63a5 Compare June 26, 2025 20:24
@powerboat9
Copy link
Collaborator

Could we just do a regular merge? It looks like it'd go through with no conflicts

@dkm
Copy link
Member Author

dkm commented Jun 27, 2025

Could we just do a regular merge? It looks like it'd go through with no conflicts

Sounds like we've already discussed all this when we decided how to proceed. At least here is public and other interested parties could chime in (e.g. @thesamesam ).

I would like to use the process as discussed, at least for a few rounds. We can always adjust if something is painful, not friendly, anything else.

The good property of doing this is that the main branch is always mostly ready for the upstreaming. The main branch is always: a few gccrs commits, an empty merge commit with the --strategy=ours which first parent is a sequence of gccrs commits rebased over an upstream gcc base (recent). The git history becomes a bit like the history of the gccrs commit rebased: first parent of the merge is the current series, the second parent is the previous branch (from there, you again have the exact same pattern).

The daily routine is rather easy and doesn't involve to be a git expert to do. See for example my WIP for gerris...

https://github.com/Rust-GCC/gerris/blob/dkm/upstream-command/src/rebaseupstream.rs => this is used to rebase the github branch onto a fresh upstream (it rebases onto a new base, and it moves all the commits that were after the commit before the new one, so that you have: merge<-gccrs sequence<-fresh upstream gcc).

https://github.com/Rust-GCC/gerris/blob/11b5ee7372da00a40a493a88a53a3530cd81d38b/src/upstream.rs#L249 => this is used to prepare the branch before upstreaming. It is not 100% done, but it gives a good start.

I fear that having regular merge would make things harder to read, and the upstreaming would need a different process. Again, I'm not saying it's not a good idea, but I think I like the process as proposed initially and would like to give it a try.

@powerboat9
Copy link
Collaborator

Alright, we can table the discussion for now. I figured I'd bring it up again since #3761 has already been merged.

@dkm
Copy link
Member Author

dkm commented Jun 27, 2025

Alright, we can table the discussion for now. I figured I'd bring it up again since #3761 has already been merged.

The goal, at least as I understand it, is to do similar merge on a weekly basis, with corresponding upstreaming...

@dkm dkm force-pushed the dkm/bump-2025-06-26 branch 2 times, most recently from 142d78e to 5399542 Compare July 3, 2025 19:24
@dkm
Copy link
Member Author

dkm commented Jul 4, 2025

Not sure why there's an extra warning here, but I have a fix for it that I'll submit later (will be afk until monday)

@powerboat9
Copy link
Collaborator

Oddly enough, it's not an extra warning, it's a missing warning

@dkm
Copy link
Member Author

dkm commented Jul 7, 2025

Oddly enough, it's not an extra warning, it's a missing warning

We probably need to read what are the warnings and get rid of them if needed.
I do have the warning locally on master and I have a fix... Not sure why it's missing I'll have a better look later.

@dkm dkm force-pushed the dkm/bump-2025-06-26 branch from 5399542 to bdba370 Compare July 8, 2025 18:14
@dkm dkm force-pushed the dkm/bump-2025-06-26 branch 2 times, most recently from eb57e26 to 732353b Compare July 12, 2025 05:48
@dkm dkm changed the title Bump test. Sync with upstream 451b6dbf47595922518b9672 Jul 12, 2025
@dkm dkm requested a review from CohenArthur July 12, 2025 06:06
@dkm
Copy link
Member Author

dkm commented Jul 12, 2025

@CohenArthur I think, if the CI is ✔️ , the branch can be pushed in master. This will sync with GCC and allow easier upstreaming

@dkm
Copy link
Member Author

dkm commented Jul 12, 2025

@CohenArthur I think, if the CI is ✔️ , the branch can be pushed in master. This will sync with GCC and allow easier upstreaming

of course the changelog check is not happy because of old commits, but none of them is meant to be upstreamed (github infra things, or moving readme around)

@dkm dkm force-pushed the dkm/bump-2025-06-26 branch from 732353b to 43abdf8 Compare July 15, 2025 18:28
@dkm dkm changed the title Sync with upstream 451b6dbf47595922518b9672 Sync with upstream 3fbed69502770851c8a5bfece99e9ee8c6d9e4b0 Jul 15, 2025
@dkm
Copy link
Member Author

dkm commented Jul 15, 2025

@CohenArthur this is ready to be pushed in master branch (if all CI jobs are ✔️ , except the git log checks)

@powerboat9
Copy link
Collaborator

git diff with the result of a merge between 3fbed69 and 5dc8c4d is empty, looks good to merge

@dkm dkm marked this pull request as ready for review July 17, 2025 14:59
@dkm dkm changed the title Sync with upstream 3fbed69502770851c8a5bfece99e9ee8c6d9e4b0 Sync with upstream fa099f248e2462ecd5ab8b0cadd348aaf11bb093 Jul 21, 2025
@dkm dkm force-pushed the dkm/bump-2025-06-26 branch from 43abdf8 to 9af669d Compare July 21, 2025 16:40
CohenArthur and others added 3 commits July 22, 2025 17:43
This adds a version of the build-and-check job that runs with clang on
macOS.
This will provide some synchronization for output lines, and so will
make comparisons with known warnings as part of CI more reliable.
CohenArthur and others added 26 commits July 22, 2025 17:44
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Check for a label
	before visiting it.
…rcions

This case:

    let i = 1;
    let j = i as i64;

'i' is meant to default to i32 but the inference was making both of these
i64 because the code was prefering coercion logic which can end up with a
default unify which causes the ?integer to unify with i64 making them both
i64.

But all we need to do is allow the simple cast rules to run first then
fallback to coercions but special consideration has to be made to ensure
that if there are dyn objects needed then this needs a unsize coercion, but
also we need to ensure the underlying types are a valid simple cast too
otherwise these also need to fallback to the coercion code.

Fixes #2680

gcc/rust/ChangeLog:

	* typecheck/rust-casts.cc (TypeCastRules::resolve): optional emit_error flag
	(TypeCastRules::check): try the simple cast rules then fallback to coercions
	(TypeCastRules::check_ptr_ptr_cast): ensure the underlying's
	(TypeCastRules::emit_cast_error): make this a static helper
	* typecheck/rust-casts.h: new emit_error prototype

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2680.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
We just had a typo returning ok true when it should have been false.

Fixes #3876

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): fix typo

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3876.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Fixes #3599

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3599.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Fixes #3144

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3144.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Fixes #1048

gcc/testsuite/ChangeLog:

	* rust/compile/issue-1048.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* util/rust-attribute-values.h: Add declarations for them.
	* util/rust-attributes.cc: Add definitions.
We have more complex test cases already but this will close out this issue.

Fixes #2005

gcc/testsuite/ChangeLog:

	* rust/execute/torture/issue-2005.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc(TypeCheckPattern::visit(SlicePattern)):
		Implement size checking for SlicePattern when type checking against array parent

Signed-off-by: Yap Zhi Heng <[email protected]>
…ype scrutinee

Example GIMPLE output from compiling testsuite/rust/compile/match-pattern-array.rs:

  ...
  a[0] = 0;
  a[1] = 1;
  RUSTTMP.3 = a;
  _1 = RUSTTMP.3[0];
  _2 = _1 == 0;
  _3 = RUSTTMP.3[1];
  _4 = _3 == 1;
  _5 = _2 & _4;
  if (_5 != 0) goto <D.122>; else goto <D.123>;
  <D.122>:
  {
    {

		}
	}
  goto <D.117>;
  }
  <D.123>:
	...

gcc/rust/ChangeLog:

	* rust-backend.h: New size_constant_expression function.
	* rust-gcc.cc: Implementation of size_constant_expression function to generate tree node
		for array access.
	* backend/rust-compile-pattern.h: Remove empty visits for SlicePattern.
	* backend/rust-compile-pattern.cc: Implement SlicePattern check expression & binding
		compilation against ArrayType scrutinee.

Signed-off-by: Yap Zhi Heng <[email protected]>
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Add a catch for const/static.

gcc/testsuite/ChangeLog:

	* rust/compile/loop_constant_context.rs: New test.
	* rust/compile/issue-3618.rs:

Signed-off-by: lishin <[email protected]>
Fixes #3524

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3524.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_simple_path): Be more
	careful about skipping SCOPE_RESOLUTION tokens.
	(Parser::parse_simple_path_segment): Allow parsing from a
	starting offset.
	(Parser::parse_use_tree): Handle a non-skipped SCOPE_RESOLUTION
	token.
	* parse/rust-parse.h (Parser::parse_simple_path_segment): Add
	parameter for parsing from a starting offset.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_simple_path_fail_1.rs: New test.
	* rust/compile/parse_simple_path_fail_2.rs: New test.

Signed-off-by: Owen Avery <[email protected]>
Rust seems to allow duplicate HIR::Item 'main' functions but it needs
to be a root item to be the true main entry point. This means we can
use the canonical path to determine if this is a root one where
its CrateName::main or CrateName::Module::main.

Fixes #3978

gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc: check the canonical path

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3978.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
In the test case:

  fn test (len: usize) -> u64 {
     let mut i = 0;
     let mut out = 0;
     if i + 3 < len {
        out = 123;
     }
     out
  }

The issue is to determine the correct type of 'i', out is simple because it hits a
coercion site in the resturn position for u64. But 'i + 3', 'i' is an integer infer
variable and the same for the literal '3'. So when it comes to resolving the type for
the Add expression we hit the resolve the operator overload code and because of this:

  macro_rules! add_impl {
      ($($t:ty)*) => ($(
          impl Add for $t {
              type Output = $t;

              #[inline]
              #[rustc_inherit_overflow_checks]
              fn add(self, other: $t) -> $t { self + other }
          }
      )*)
  }

  add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }

This means the resolution for 'i + 3' is ambigious because it could be any of these Add
implementations. But because we unify against the '< len' where len is defined as usize
later in the resolution we determine 'i' is actually a usize. Which means if we defer the
resolution of this operator overload in the ambigious case we can simply resolve it at the
end.

Fixes #3916

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-expr.cc (OperatorExprMeta::OperatorExprMeta): track the rhs
	* hir/tree/rust-hir-expr.h: likewise
	* hir/tree/rust-hir-path.h: get rid of old comments
	* typecheck/rust-hir-trait-reference.cc (TraitReference::get_trait_substs): return
	references instead of copy
	* typecheck/rust-hir-trait-reference.h: update header
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::ResolveOpOverload): write ambigious
	operator overloads to a table and try to resolve it at the end
	* typecheck/rust-hir-type-check-expr.h: new static helper
	* typecheck/rust-hir-type-check.h (struct DeferredOpOverload): new model to defer resolution
	* typecheck/rust-typecheck-context.cc (TypeCheckContext::lookup_operator_overload): new
	(TypeCheckContext::compute_ambigious_op_overload): likewise
	(TypeCheckContext::compute_inference_variables): likewise

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3916.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Not adding the test case here we emit more errors than rustc for the error
type node so its just noisy and dejagnu is being a pain.

Fixes #3933

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): return error_mark_node

Signed-off-by: Philip Herron <[email protected]>
This should make it easier for us to handle attribute meta items of the
form <SimplePath> '=' <Expression> where the expression isn't a literal.
Some low hanging fruit remains here, but I think I should keep this
patch small as I had some trouble debugging it as-is (see:
Rust::Token::as_string vs Rust::Token::get_str vs
Rust::AST::Token::as_string).

gcc/rust/ChangeLog:

	* ast/rust-ast.cc: Include "rust-macro-invoc-lexer.h".
	(AttributeParser::~AttributeParser): Move function definition
	here.
	(AttributeParser::AttributeParser): Likewise and adjust member
	initialization.
	(AttributeParser::parse_meta_item_inner): Handle changes to
	peek_token.
	(AttributeParser::parse_literal): Likewise.
	(AttributeParser::parse_simple_path_segment): Likewise.
	(AttributeParser::parse_meta_item_seq): Handle changes to
	AttributeParser fields.
	(AttributeParser::peek_token): Move function definition here and
	wrap MacroInvocLexer.
	(AttributeParser::skip_token): Likewise.
	* ast/rust-macro.h (class MacroInvocLexer): Forward declare.
	(class Parser): Likewise.
	(AttributeParser::token_stream): Remove field.
	(AttributeParser::stream_pos): Likewise.
	(AttributeParser::lexer): New field.
	(AttributeParser::parser): Likewise.
	(AttributeParser::AttributeParser): Move definition to
	"rust-ast.cc".
	(AttributeParser::~AttributeParser): Likewise.
	(AttributeParser::peek_token): Likewise.
	(AttributeParser::skip_token): Likewise.

Signed-off-by: Owen Avery <[email protected]>
When we have generic paths like T::foobar during codegen sometimes we need
to enforce an extra lookup for this generic parameter type to the mono
morphized underlying type.

Fixes #3915
Fixes #1247

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): do another lookup

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3915.rs: New test.
	* rust/execute/torture/sip-hasher.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* expand/rust-expand-visitor.cc
	(ExpandVisitor::expand_inner_items): Adjust call to
	expand_macro_children.
	(ExpandVisitor::expand_inner_stmts): Likewise.
	(ExpandVisitor::visit): Likewise.
	* expand/rust-expand-visitor.h
	(ExpandVisitor::expand_macro_children): Take a pointer to member
	function instead of a std::function.

Signed-off-by: Owen Avery <[email protected]>
TopLevel would ignore just-loaded modules but Early and ExpandVisitor
wouldn't. The latter would produce errors when it hit attributes which
should have been indirectly CfgStrip'd away.

gcc/rust/ChangeLog:

	* expand/rust-cfg-strip.cc (CfgStrip::visit): Load unloaded
	modules.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
	Assume modules have been loaded by CfgStrip.

Signed-off-by: Owen Avery <[email protected]>
This is important for importing enum variants as items.

gcc/rust/ChangeLog:

	* util/rust-hir-map.cc (Mappings::insert_ast_module): Rename to...
	(Mappings::insert_glob_container): ...this.
	(Mappings::lookup_ast_module): Rename to...
	(Mappings::lookup_glob_container): ...this.
	* util/rust-hir-map.h: Change declarations.
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import): Adapt for enums.
	(Early::finalize_glob_import): Likewise.
	* resolve/rust-early-name-resolver-2.0.h: Likewise.
	* resolve/rust-finalize-imports-2.0.cc (GlobbingVisitor::go): Likewise.
	(GlobbingVisitor::visit_module_container): New function.
	(GlobbingVisitor::visit_enum_container): New function.
	* resolve/rust-finalize-imports-2.0.h: Declare them.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert enums as potential
	containers.

gcc/testsuite/ChangeLog:

	* rust/compile/glob_import_enum.rs: New test.
gcc/rust/ChangeLog:

	* ast/rust-expr.h: Add handling for deferred consts.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
	* ast/rust-ast.cc (AnonConst::as_string): Likewise.
	(ArrayType::as_string): Likewise.
	* ast/rust-type.h (class ArrayType): Use AnonConst for sizes.
	* parse/rust-parse-impl.h (Parser::parse_anon_const): New function.
	(Parser::parse_slice_or_array_type): Call it.
	* parse/rust-parse.h: Declare it.
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Handle defered consts.
	* hir/tree/rust-hir-expr.cc (AnonConst::AnonConst): Likewise.
	(AnonConst::operator=): Likewise.
	* hir/tree/rust-hir-expr.h: Likewise.
	* hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/deferred_const_inference.rs: New test.
gcc/rust/ChangeLog:

	* ast/rust-expr.h: Fix formatting.
…25-06-26

This branch has a no-op merge as the last commit:
 - one arm is the "current" development branch from github
 - the other arm is a rebased version of the "current" master branch onto a recent GCC's master

The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.
@dkm dkm force-pushed the dkm/bump-2025-06-26 branch from 9af669d to 3a57c56 Compare July 22, 2025 15:46
@dkm dkm changed the title Sync with upstream fa099f248e2462ecd5ab8b0cadd348aaf11bb093 Sync with upstream 0d52a736a3856871761c89fefa59c2ff39f3a5f8 Jul 22, 2025
@dkm
Copy link
Member Author

dkm commented Jul 22, 2025

CI is happy, everything looks good ✔️

@dkm dkm merged commit 3a57c56 into master Jul 22, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.