Re: Rust frontend patches v3

2022-10-26 Thread David Malcolm via Gcc-rust
On Wed, 2022-10-26 at 10:17 +0200, arthur.co...@embecosm.com wrote: > This is the fixed version of our previous patch set for gccrs - We've > adressed > the comments raised in our previous emails. [...snip...] (Caveat: I'm not a global reviewer) Sorry if this is answered in the docs in the patch

Re: [PATCH Rust front-end v3 35/46] gccrs: Add metadata ouptput pass

2022-10-26 Thread David Malcolm via Gcc-rust
%{On Wed, 2022-10-26 at 10:18 +0200, arthur.co...@embecosm.com wrote: > From: Philip Herron > > Extern crates statements to tell the front-end to look for another > library. > The mechanism here is heavily inspired from gccgo, so when we compile > a > library for example we invoke: > [...snip..

Re: [PATCH Rust front-end v3 20/46] gccrs: Add wrapper for make_unique

2022-10-26 Thread David Malcolm via Gcc-rust
On Wed, 2022-10-26 at 10:17 +0200, arthur.co...@embecosm.com wrote: > From: Philip Herron > > This is a wrapper for make_unique we can likely get rid of this as > there > are other implementations available or simply keep using the > unique_ptr > constructor. [CCing Jonathan] As it happens, I j

☠ Buildbot (GNU Toolchain): gccrust - failed 'grep unexpected ...' (failure) (master)

2022-10-26 Thread builder--- via Gcc-rust
A new failure has been detected on builder gccrust-fedora-arm64 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#builders/179/builds/228 Build state: failed 'grep unexpected ...' (failure) Revision: 1e11f00ca1d04548704fe899ba36e1fd91802752 Worke

☺ Buildbot (GNU Toolchain): gccrust - build successful (master)

2022-10-26 Thread builder--- via Gcc-rust
A restored build has been detected on builder gccrust-fedora-arm64 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#builders/179/builds/227 Build state: build successful Revision: db4b399c25fd3c37e52c6b8dbdf6bc9c0f1deb6c Worker: fedora-arm64 Bui

[PATCH Rust front-end v3 46/46] gccrs: Add README, CONTRIBUTING and compiler logo

2022-10-26 Thread arthur . cohen
From: Philip Herron We still need to write out documentation section but these README's will help in the mean time. --- gcc/rust/CONTRIBUTING.md | 130 +++ gcc/rust/README.md | 264 +++ gcc/rust/logo.png| Bin 0 -> 70864 bytes 3 f

[PATCH Rust front-end v3 45/46] gccrs: Compiler proper interface kicks off the pipeline

2022-10-26 Thread arthur . cohen
From: Philip Herron This is a wrapper to get out of C land in the rust-lang.cc and into our class hierarchy for the rust front-end. We expect that the front-end only support one source file input as the expansion pass will attempt to resolve that relative pass and parse accordingly. The main mis

Re: [PATCH Rust front-end v3 01/46] Use DW_ATE_UTF for the Rust 'char' type

2022-10-26 Thread Jakub Jelinek via Gcc-rust
On Wed, Oct 26, 2022 at 10:17:26AM +0200, arthur.co...@embecosm.com wrote: > @@ -25201,6 +25215,13 @@ gen_compile_unit_die (const char *filename) > } >else if (strcmp (language_string, "GNU F77") == 0) > language = DW_LANG_Fortran77; > + else if (strcmp (language_string, "GNU Rust")

[PATCH Rust front-end v3 34/46] gccrs: Add unused variable scan

2022-10-26 Thread arthur . cohen
From: Philip Herron This is a simple walk_tree which acts on the monomorphized code. By walking the compiled translation unit of functions. --- gcc/rust/checks/lints/rust-lint-unused-var.cc | 98 +++ gcc/rust/checks/lints/rust-lint-unused-var.h | 36 +++ 2 files changed, 134

[PATCH Rust front-end v3 41/46] gccrs: Add config-lang.in

2022-10-26 Thread arthur . cohen
From: Philip Herron This was a copy paste from gccgo front-end, we do not use any of the target_libs yet but we will need these when we support the libpanic crate. --- gcc/rust/config-lang.in | 34 ++ 1 file changed, 34 insertions(+) create mode 100644 gcc/rust/c

[PATCH Rust front-end v3 33/46] gccrs: Add dead code scan on HIR

2022-10-26 Thread arthur . cohen
From: Thomas Young In order to find dead code we use a depth first search and keep liveness variables, after type resolution. In this case, if a function is unused and it calls another function the 2nd function is now unused since the caller is not used etc. The algorithm is a depth first search.

[PATCH Rust front-end v3 28/46] gccrs: Add Rust type information

2022-10-26 Thread arthur . cohen
From: Philip Herron Contains abstractions over Rust's types, used when performing the HIR's type-resolution. --- gcc/rust/typecheck/rust-tyty.cc | 2885 +++ gcc/rust/typecheck/rust-tyty.h | 2533 +++ 2 files changed, 5418 insertions(+) create

[PATCH Rust front-end v3 44/46] gccrs: Add compiler driver

2022-10-26 Thread arthur . cohen
From: Philip Herron Our compiler driver is pretty simple so far, the key piece to enforce is that a compilation unit in Rust is the whole crate so the process for compiling rust means pointing the compiler at the main entry point such as src/lib.rs or src/main.rs where the expansion pass takes ov

[PATCH Rust front-end v3 43/46] gccrs: Add lang.opt

2022-10-26 Thread arthur . cohen
From: Philip Herron We have some rust specific langugage options note -fwrapv is enabled by default in the code. We are trying to respect options such as -Wunused-result which we get by porting over c++ no-discard for rust's must-use attribute, so we have enabled these by default directly here. -

[PATCH Rust front-end v3 42/46] gccrs: Add lang-spec.h

2022-10-26 Thread arthur . cohen
From: Philip Herron This specifies the extensions of the Rust language. --- gcc/rust/lang-specs.h | 26 ++ 1 file changed, 26 insertions(+) create mode 100644 gcc/rust/lang-specs.h diff --git a/gcc/rust/lang-specs.h b/gcc/rust/lang-specs.h new file mode 100644 index 000

[PATCH Rust front-end v3 40/46] gccrs: Add GCC Rust front-end Make-lang.in

2022-10-26 Thread arthur . cohen
From: Philip Herron This is the Makefile for our front-end. --- gcc/rust/Make-lang.in | 399 ++ 1 file changed, 399 insertions(+) create mode 100644 gcc/rust/Make-lang.in diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in new file mode 100644 ind

[PATCH Rust front-end v3 39/46] gccrs: These are wrappers ported from reusing gccgo

2022-10-26 Thread arthur . cohen
From: Philip Herron The wrappers over linemap and location will eventually disappear here but served as a useful starting point for us. We have wrappers over the diagnostics system which we might be able to get rid of as well. --- gcc/rust/rust-diagnostics.cc | 244 ++

[PATCH Rust front-end v3 30/46] gccrs: Add unsafe checks for Rust

2022-10-26 Thread arthur . cohen
From: Arthur Cohen The UnsafeChecker visitor verifies that unsafe actions are only performed in unsafe contexts. Otherwise, an error should be reported to the user and the compilation pipeline should be halted. These contexts, which include unsafe blocks or unsafe functions, are allowed to perfor

[PATCH Rust front-end v3 38/46] gccrs: Add HIR to GCC GENERIC lowering entry point

2022-10-26 Thread arthur . cohen
From: Philip Herron This patch contains the entry point and utilities used for the lowering of HIR nodes to `tree`s. It also contains a constant evaluator, ported over from the C++ frontend. Co-authored-by: David Faust Co-authored-by: Faisal Abbas <90.abbasfai...@gmail.com> --- gcc/rust/backen

[PATCH Rust front-end v3 32/46] gccrs: Add privacy checks

2022-10-26 Thread arthur . cohen
From: Arthur Cohen This pass is responsible for resolving the privacy of items and verifying that access to these items is performed within the limits of that privacy. By default, items in Rust are private and only public to the current module and its submodules. However, the user can annotate an

[PATCH Rust front-end v3 21/46] gccrs: Add port of FNV hash used during legacy symbol mangling

2022-10-26 Thread arthur . cohen
From: Philip Herron This hash was ported from the go runime as we needed a hash for the legacy symbol mangling system. Which means all symbols in Rust contain a hash of some metadata for uniqueness on generic functions. --- gcc/rust/util/fnv-hash.h | 95

[PATCH Rust front-end v3 26/46] gccrs: Add helpers mappings canonical path and lang items

2022-10-26 Thread arthur . cohen
From: Philip Herron These are various helper classes used in the compiler pipeline. --- gcc/rust/util/rust-canonical-path.h | 195 + gcc/rust/util/rust-common.h | 53 ++ gcc/rust/util/rust-hir-map.cc | 980 ++ gcc/rust/util/rust-hir-map.h

[PATCH Rust front-end v3 25/46] gccrs: Add attributes checker

2022-10-26 Thread arthur . cohen
From: Arthur Cohen The attribute checker is responsible for checking the validity of various attributes including built-in ones. It is currently unfinished and will receive some modifications, as well as become the host of some existing code in the compiler which needs to be refactored. One of it

[PATCH Rust front-end v3 35/46] gccrs: Add metadata ouptput pass

2022-10-26 Thread arthur . cohen
From: Philip Herron Extern crates statements to tell the front-end to look for another library. The mechanism here is heavily inspired from gccgo, so when we compile a library for example we invoke: gccrs -g -O2 -frust-crate=mylib -c src/lib.rs -o src/mylib.o All going well this object file w

[PATCH Rust front-end v3 31/46] gccrs: Add const checker

2022-10-26 Thread arthur . cohen
From: Arthur Cohen Similarly to the unsafe checker, constant evaluation can only be performed in a few contexts and include restrictions on the Rust language. Should the user fail to uphold those conditions, errors will be reported and the compilation pipeline interrupted. These contexts are as

[PATCH Rust front-end v3 20/46] gccrs: Add wrapper for make_unique

2022-10-26 Thread arthur . cohen
From: Philip Herron This is a wrapper for make_unique we can likely get rid of this as there are other implementations available or simply keep using the unique_ptr constructor. --- gcc/rust/util/rust-make-unique.h | 35 1 file changed, 35 insertions(+) create m

[PATCH Rust front-end v3 23/46] gccrs: Add Base62 implementation

2022-10-26 Thread arthur . cohen
From: Arthur Cohen Used for V0 symbol mangling scheme which. --- gcc/rust/util/rust-base62.cc | 46 gcc/rust/util/rust-base62.h | 34 ++ 2 files changed, 80 insertions(+) create mode 100644 gcc/rust/util/rust-base62.cc create mode 1

[PATCH Rust front-end v3 22/46] gccrs: Add Rust ABI enum helpers

2022-10-26 Thread arthur . cohen
From: Philip Herron This is a simple helper over an enum of possible ABI options in Rust. --- gcc/rust/util/rust-abi.cc | 72 +++ gcc/rust/util/rust-abi.h | 45 2 files changed, 117 insertions(+) create mode 100644 gcc/rust/util/rust

[PATCH Rust front-end v3 18/46] gccrs: Add HIR definitions and visitor framework

2022-10-26 Thread arthur . cohen
From: Philip Herron This patch implements the classes mentionned in the previous HIR patch, as well as a set of visitor frameworks used in handling that HIR. --- gcc/rust/hir/tree/rust-hir-full-decls.h | 232 + gcc/rust/hir/tree/rust-hir-full-test.cc | 5292 +++ gcc/rust/hir

[PATCH Rust front-end v3 24/46] gccrs: Add implementation of Optional

2022-10-26 Thread arthur . cohen
From: Arthur Cohen Add an Optional class to improve error handling --- gcc/rust/util/rust-optional-test.cc | 110 +++ gcc/rust/util/rust-optional.h | 278 2 files changed, 388 insertions(+) create mode 100644 gcc/rust/util/rust-optional-test.cc create

[PATCH Rust front-end v3 09/46] gccrs: Add definitions of Rust Items in AST data structures

2022-10-26 Thread arthur . cohen
From: The Other This adds the proper definitions of our AST Item nodes. Co-authored-by: Philip Herron --- gcc/rust/ast/rust-item.h | 4382 ++ 1 file changed, 4382 insertions(+) create mode 100644 gcc/rust/ast/rust-item.h diff --git a/gcc/rust/ast/rust-item

[PATCH Rust front-end v3 12/46] gccrs: Add Lexer for Rust front-end

2022-10-26 Thread arthur . cohen
From: The Other The lexer is refered to as a ManagedTokenSource within the parser, this lexer does not currently support unicode but serves as a starting point to do so. Co-authored-by: Philip Herron Co-authored-by: Arthur Cohen Co-authored-by: Mark Wielaard --- gcc/rust/lex/rust-codepoint.h

[PATCH Rust front-end v3 11/46] gccrs: Add Rust AST visitors

2022-10-26 Thread arthur . cohen
From: The Other This patch contains the basic framework of our AST visitors, as well as one aimed at pretty-printing and exporting these AST nodes Co-authored-by: Philip Herron Co-authored-by: Arthur Cohen --- gcc/rust/ast/rust-ast-dump.cc| 1089 ++ gcc/rust/as

[PATCH Rust front-end v3 07/46] gccrs: Add gcc-check-target check-rust

2022-10-26 Thread arthur . cohen
From: Philip Herron This allows us to invoke the rust testsuite. ChangeLog: * Makefile.def: Add Rust language. * Makefile.in: Regenerate via autogen. --- Makefile.def | 1 + Makefile.in | 8 2 files changed, 9 insertions(+) diff --git a/Makefile.def b/Makefile.def ind

[PATCH Rust front-end v3 02/46] gccrs: Add nessecary hooks for a Rust front-end testsuite

2022-10-26 Thread arthur . cohen
From: Philip Herron This copy's over code from other front-end testsuites to enable testing for the rust front-end specifically. Co-authored-by: Marc Poulhiès Co-authored-by: Thomas Schwinge --- gcc/testsuite/lib/rust-dg.exp | 49 + gcc/testsuite/lib/rust.exp| 186 +++

[PATCH Rust front-end v3 01/46] Use DW_ATE_UTF for the Rust 'char' type

2022-10-26 Thread arthur . cohen
From: Tom Tromey The Rust 'char' type should use the DWARF DW_ATE_UTF encoding. --- gcc/dwarf2out.cc | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e3920c898f5..a8bccbabca4 100644 --- a/gcc/dwarf2out.cc +++ b/

[PATCH Rust front-end v3 03/46] gccrs: Add Debug info testsuite

2022-10-26 Thread arthur . cohen
From: Philip Herron This testsuite is specifically about testcases which scan the asm debug info for results. Co-authored-by: Tom Tromey --- gcc/testsuite/rust/debug/chartype.rs | 10 ++ .../rust/debug/custom_link_section.rs | 13 gcc/testsuite/rust/debug/debug.ex

[PATCH Rust front-end v3 04/46] gccrs: Add link cases testsuite

2022-10-26 Thread arthur . cohen
From: Philip Herron This testsuite is heavily inspired from the lto testsuite which uses a pattern that each file is compiled to an object file and finally linked together. Since rust does not have headers/prototypes we rely on the ordering here so that all files numbered greater than zero get co

Rust frontend patches v3

2022-10-26 Thread arthur . cohen
This is the fixed version of our previous patch set for gccrs - We've adressed the comments raised in our previous emails. This patch set does not contain any work that was not previously included, such as closure support, the constant evaluator port, or the better implementation of target hooks b