Re: [PATCH Rust front-end v2 09/37] gccrs: Add Lexer for Rust front-end

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:04 PM  wrote:
>
> 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  |   46 +
>  gcc/rust/lex/rust-lex.cc   | 2729 
>  gcc/rust/lex/rust-lex.h|  271 
>  gcc/rust/lex/rust-token.cc |  135 ++
>  gcc/rust/lex/rust-token.h  |  455 ++
>  gcc/rust/rust-buffered-queue.h |  204 +++
>  6 files changed, 3840 insertions(+)
>  create mode 100644 gcc/rust/lex/rust-codepoint.h
>  create mode 100644 gcc/rust/lex/rust-lex.cc
>  create mode 100644 gcc/rust/lex/rust-lex.h
>  create mode 100644 gcc/rust/lex/rust-token.cc
>  create mode 100644 gcc/rust/lex/rust-token.h
>  create mode 100644 gcc/rust/rust-buffered-queue.h
>
> diff --git a/gcc/rust/lex/rust-codepoint.h b/gcc/rust/lex/rust-codepoint.h
> new file mode 100644
> index 000..22da080bbb2
> --- /dev/null
> +++ b/gcc/rust/lex/rust-codepoint.h
> @@ -0,0 +1,46 @@
> +// Copyright (C) 2020-2022 Free Software Foundation, Inc.
> +
> +// This file is part of GCC.
> +
> +// GCC is free software; you can redistribute it and/or modify it under
> +// the terms of the GNU General Public License as published by the Free
> +// Software Foundation; either version 3, or (at your option) any later
> +// version.
> +
> +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +// WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +// for more details.
> +
> +// You should have received a copy of the GNU General Public License
> +// along with GCC; see the file COPYING3.  If not see
> +// .
> +
> +#ifndef RUST_CODEPOINT_H
> +#define RUST_CODEPOINT_H
> +
> +#include 
> +
> +namespace Rust {
> +struct Codepoint
> +{
> +  uint32_t value;
> +
> +  // Creates a zero codepoint.
> +  Codepoint () : value (0) {}
> +
> +  // Creates a codepoint from an encoded UTF-8 value.
> +  Codepoint (uint32_t value) : value (value) {}
> +
> +  static Codepoint eof () { return Codepoint (UINT32_MAX); }
> +  bool is_eof () const { return value == UINT32_MAX; }
> +
> +  // Returns a C++ string containing string value of codepoint.
> +  std::string as_string ();
> +
> +  bool operator== (Codepoint other) const { return value == other.value; }
> +  bool operator!= (Codepoint other) const { return !operator== (other); }
> +};
> +} // namespace Rust
> +
> +#endif
> diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
> new file mode 100644
> index 000..70e6b50209f
> --- /dev/null
> +++ b/gcc/rust/lex/rust-lex.cc
> @@ -0,0 +1,2729 @@
> +// Copyright (C) 2020-2022 Free Software Foundation, Inc.
> +
> +// This file is part of GCC.
> +
> +// GCC is free software; you can redistribute it and/or modify it under
> +// the terms of the GNU General Public License as published by the Free
> +// Software Foundation; either version 3, or (at your option) any later
> +// version.
> +
> +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +// WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +// for more details.
> +
> +// You should have received a copy of the GNU General Public License
> +// along with GCC; see the file COPYING3.  If not see
> +// .
> +
> +#include "rust-lex.h"
> +
> +#include "rust-system.h"  // for rust_assert and rust_unreachable
> +#include "rust-diagnostics.h" // for rust_error_at
> +#include "rust-linemap.h"
> +#include "rust-session-manager.h"
> +#include "safe-ctype.h"

just diving into a random patch here - I'm assuming I can take rust-lex.cc as
a boiler-plate example for the #include structure.

In GCC all files should start with #including "config.h" followed by
"system.h" where _all_ system, including C++ standard library headers
should be pulled via system.h to allow working around OS and system
compiler issues.

It might be that rust-system.h plays the role of config.h + system.h
but then the rust-lex.h include is before it.

rust-codepoint.h including  is also problematic btw.

Richard.

> +namespace Rust {
> +// TODO: move to separate compilation unit?
> +// overload += for uint32_t to allow 32-bit encoded utf-8 to be added
> +std::string &
> +operator+= (std::string &str, Codepoint char32)
> +{
> +  if (char32.value < 0x80)
> +{
> +  str += static_cast (char32.value);
> +}
> +  else if (char32.value < (0x1F + 1) << (1 * 6))
> +{
> +  str += static_cast (0xC0 | ((char32.value >> 6) & 0x1F));
> +  str += static_cast (0x80 | ((char32.value >> 0) & 0x3F));
> +}
> +  else if (char32.value < (0x0F + 1) << (2 *

Re: [PATCH Rust front-end v2 31/37] gccrs: Add GCC Rust front-end Make-lang.in

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:22 PM  wrote:
>
> From: Philip Herron 
>
> This is the Makefile for our front-end.
> ---
>  gcc/rust/Make-lang.in | 400 ++
>  1 file changed, 400 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
> index 000..f687cc2f667
> --- /dev/null
> +++ b/gcc/rust/Make-lang.in
> @@ -0,0 +1,400 @@
> +# Make-lang.in -- Top level -*- makefile -*- fragment for GCC Rust frontend.
> +
> +# Copyright (C) 2009-2022 Free Software Foundation, Inc.
> +
> +# This file is part of GCC.
> +
> +# GCC is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3, or (at your option)
> +# any later version.
> +
> +# GCC is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with GCC; see the file COPYING3.  If not see
> +# .
> +
> +# This file provides the language dependent support in the main Makefile.
> +
> +#RUST_EXES = rust
> +
> +# Use strict warnings for this front end.
> +rust-warn = $(STRICT_WARN)
> +
> +# Installation name. Useful for cross compilers and used during install.
> +GCCRS_INSTALL_NAME := $(shell echo gccrs|sed '$(program_transform_name)')
> +GCCRS_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccrs|sed 
> '$(program_transform_name)')
> +
> +# Define the names for selecting rust in LANGUAGES.
> +rust: rust1$(exeext)
> +
> +# Tell GNU make to ignore files by these names if they exist.
> +.PHONY: rust
> +
> +# removed GRS_CFLAGS from here
> +
> +CFLAGS-rust/rustspec.o += $(DRIVER_DEFINES)
> +
> +# Create the compiler driver gccrs.
> +# A compiler driver is the program that interprets command argument and can 
> be called from the command
> +# line - e.g. gcc or g++, and not cc1, which is the actual compiler
> +
> +# Create driver objects
> +GCCRS_D_OBJS = \
> +   $(GCC_OBJS) \
> +   rust/rustspec.o \
> +   $(END)
> +
> +gccrs$(exeext): $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a 
> $(LIBDEPS)
> +   +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
> + $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
> + $(EXTRA_GCC_LIBS) $(LIBS)
> +
> +# List of host object files used by the rust language - files for 
> translation from the parse tree
> +# to GENERIC
> +# The compiler proper, not driver
> +GRS_OBJS = \
> +rust/rust-lang.o \
> +rust/rust-object-export.o \
> +rust/rust-linemap.o \
> +rust/rust-gcc-diagnostics.o \
> +rust/rust-diagnostics.o \
> +rust/rust-gcc.o \
> +rust/rust-token.o \
> +rust/rust-lex.o \
> +rust/rust-cfg-parser.o \
> +rust/rust-parse.o \
> +rust/rust-ast-full-test.o \
> +rust/rust-ast-dump.o \
> +rust/rust-hir-dump.o \
> +rust/rust-session-manager.o \
> +rust/rust-compile.o \
> +rust/rust-mangle.o \
> +rust/rust-compile-resolve-path.o \
> +rust/rust-macro-expand.o \
> +rust/rust-attribute-visitor.o \
> +rust/rust-macro-invoc-lexer.o \
> +rust/rust-macro-substitute-ctx.o \
> +rust/rust-macro-builtins.o \
> +rust/rust-hir-full-test.o \
> +rust/rust-hir-map.o \
> +rust/rust-attributes.o \
> +rust/rust-abi.o \
> +rust/rust-ast-lower.o \
> +rust/rust-ast-lower-base.o \
> +rust/rust-ast-lower-pattern.o \
> +rust/rust-ast-lower-item.o \
> +rust/rust-name-resolver.o \
> +rust/rust-ast-resolve.o \
> +rust/rust-ast-resolve-base.o \
> +rust/rust-ast-resolve-item.o \
> +rust/rust-ast-resolve-pattern.o \
> +rust/rust-ast-resolve-expr.o \
> +rust/rust-ast-resolve-type.o \
> +rust/rust-ast-resolve-path.o \
> +rust/rust-ast-resolve-stmt.o \
> +rust/rust-ast-resolve-struct-expr-field.o \
> +rust/rust-hir-type-check.o \
> +rust/rust-privacy-check.o \
> +rust/rust-privacy-ctx.o \
> +rust/rust-reachability.o \
> +rust/rust-visibility-resolver.o \
> +rust/rust-pub-restricted-visitor.o \
> +rust/rust-privacy-reporter.o \
> +rust/rust-tyty.o \
> +rust/rust-tyty-call.o \
> +rust/rust-tyctx.o \
> +rust/rust-tyty-bounds.o \
> +rust/rust-hir-type-check-util.o \
> +rust/rust-hir-trait-resolve.o \
> +rust/rust-hir-type-check-toplevel.o \
> +rust/rust-hir-type-check-item.o \
> +rust/rust-hir-type-check-type.o \
> +rust/rust-hir-type-check-struct.o \
> +rust/rust-hir-type-check-pattern.o \
> +rust/rust-hir-type-check-expr.o \
> +rust/rust-hir-type-check-stmt.o \
> +rust/rust-hir-type-check-enumitem.o \
> +rust/rust-hir-type-check-implitem.o \
> +rust/rust-hir-dot-o

Re: [PATCH Rust front-end v2 09/37] gccrs: Add Lexer for Rust front-end

2022-09-14 Thread Jakub Jelinek via Gcc-rust
On Wed, Sep 14, 2022 at 03:30:39PM +0200, Richard Biener via Gcc-patches wrote:
> > +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> > +// WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > +// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> > +// for more details.
> > +
> > +// You should have received a copy of the GNU General Public License
> > +// along with GCC; see the file COPYING3.  If not see
> > +// .
> > +
> > +#include "rust-lex.h"
> > +
> > +#include "rust-system.h"  // for rust_assert and rust_unreachable
> > +#include "rust-diagnostics.h" // for rust_error_at
> > +#include "rust-linemap.h"
> > +#include "rust-session-manager.h"
> > +#include "safe-ctype.h"
> 
> just diving into a random patch here - I'm assuming I can take rust-lex.cc as
> a boiler-plate example for the #include structure.
> 
> In GCC all files should start with #including "config.h" followed by
> "system.h" where _all_ system, including C++ standard library headers
> should be pulled via system.h to allow working around OS and system
> compiler issues.
> 
> It might be that rust-system.h plays the role of config.h + system.h
> but then the rust-lex.h include is before it.
> 
> rust-codepoint.h including  is also problematic btw.

E.g. the Go FE has two parts, one very GCC specific that uses the explicit
config.h + system.h etc. includes, the other is generic and there it
includes go-system.h in every file first, where that starts with
#include 

various C++ standard includes

#include 
etc.

Jakub

-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 34/37] gccrs: add lang.opt

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:13 PM  wrote:
>
> 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.

LGTM

Richard.

> ---
>  gcc/rust/lang.opt | 118 ++
>  1 file changed, 118 insertions(+)
>  create mode 100644 gcc/rust/lang.opt
>
> diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
> new file mode 100644
> index 000..1f6855ede1d
> --- /dev/null
> +++ b/gcc/rust/lang.opt
> @@ -0,0 +1,118 @@
> +; Options for the Rust front end.
> +; Copyright (C) 2003-2022 Free Software Foundation, Inc.
> +;
> +; This file is part of GCC.
> +;
> +; GCC is free software; you can redistribute it and/or modify it under
> +; the terms of the GNU General Public License as published by the Free
> +; Software Foundation; either version 3, or (at your option) any later
> +; version.
> +;
> +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +; for more details.
> +;
> +; You should have received a copy of the GNU General Public License
> +; along with GCC; see the file COPYING3.  If not see
> +; .
> +
> +; See the GCC internals manual for a description of this file's format.
> +
> +; Please try to keep this file in ASCII collating order.
> +
> +; Describes command-line options used by this frontend
> +
> +Language
> +Rust
> +
> +I
> +Rust Joined Separate
> +; Documented in c.opt
> +
> +L
> +Rust Joined Separate
> +; Not documented
> +
> +Wall
> +Rust
> +; Documented in c.opt
> +
> +Wunused-variable
> +Rust Var(warn_unused_variable) Init(1) Warning
> +; documented in common.opt
> +
> +Wunused-const-variable
> +Rust Warning Alias(Wunused-const-variable=, 2, 0)
> +Warn when a const variable is unused.
> +
> +Wunused-const-variable=
> +Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) Init(1) 
> Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 2)
> +Warn when a const variable is unused.
> +
> +Wunused-result
> +Rust Var(warn_unused_result) Init(1) Warning
> +Warn if a caller of a function, marked with attribute warn_unused_result, 
> does not use its return value.
> +
> +frust-crate=
> +Rust Joined RejectNegative
> +-frust-crate= Set the crate name for the compilation
> +
> +frust-debug
> +Rust Var(flag_rust_debug)
> +Dump various Rust front end internals.
> +
> +frust-dump-
> +Rust Joined RejectNegative
> +-frust-dump- Dump Rust frontend internal information.
> +
> +frust-max-recursion-depth=
> +Rust RejectNegative Type(int) Var(rust_max_recursion_depth) Init(64)
> +-frust-max-recursion-depth=integer
> +
> +frust-mangling=
> +Rust Joined RejectNegative Enum(frust_mangling) Var(flag_rust_mangling)
> +-frust-mangling=[legacy|v0] Choose which version to use for name mangling
> +
> +Enum
> +Name(frust_mangling) Type(int) UnknownError(unknown rust mangling option %qs)
> +
> +EnumValue
> +Enum(frust_mangling) String(legacy) Value(0)
> +
> +EnumValue
> +Enum(frust_mangling) String(v0) Value(1)
> +
> +frust-cfg=
> +Rust Joined RejectNegative
> +-frust-cfg= Set a config expansion option
> +
> +frust-edition=
> +Rust Joined RejectNegative Enum(frust_edition) Var(flag_rust_edition)
> +-frust-edition=[2015|2018|2021] Choose which edition to use when 
> compiling rust code
> +
> +Enum
> +Name(frust_edition) Type(int) UnknownError(unknown rust edition %qs)
> +
> +EnumValue
> +Enum(frust_edition) String(2015) Value(0)
> +
> +EnumValue
> +Enum(frust_edition) String(2018) Value(1)
> +
> +EnumValue
> +Enum(frust_edition) String(2021) Value(2)
> +
> +frust-embed-metadata
> +Rust Var(flag_rust_embed_metadata)
> +Flag to enable embeding metadata directly into object files
> +
> +frust-metadata-output=
> +Rust Joined RejectNegative
> +-frust-metadata-output=  Path to output crate metadata
> +
> +o
> +Rust Joined Separate
> +; Documented in common.opt
> +
> +; This comment is to ensure we retain the blank line above.
> --
> 2.25.1
>
-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 32/37] gccrs: Add config-lang.in

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:19 PM  wrote:
>
> 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.

LGTM

> ---
>  gcc/rust/config-lang.in | 34 ++
>  1 file changed, 34 insertions(+)
>  create mode 100644 gcc/rust/config-lang.in
>
> diff --git a/gcc/rust/config-lang.in b/gcc/rust/config-lang.in
> new file mode 100644
> index 000..d2ff376032a
> --- /dev/null
> +++ b/gcc/rust/config-lang.in
> @@ -0,0 +1,34 @@
> +# config-lang.in -- Top level configure fragment for gcc Rust frontend.
> +
> +# Copyright (C) 2009-2022 Free Software Foundation, Inc.
> +
> +# This file is part of GCC.
> +
> +# GCC is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3, or (at your option)
> +# any later version.
> +
> +# GCC is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with GCC; see the file COPYING3.  If not see
> +# .
> +
> +# Configure looks for the existence of this file to auto-config each 
> language.
> +# We define several parameters used by configure:
> +#
> +# language - name of language as it would appear in $(LANGUAGES)
> +# compilers- value to add to $(COMPILERS)
> +
> +language="rust"
> +compilers="rust1\$(exeext)"
> +
> +build_by_default="no"
> +
> +target_libs="target-libffi target-libbacktrace"
> +
> +gtfiles="\$(srcdir)/rust/rust-lang.cc"
> --
> 2.25.1
>
-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 33/37] gccrs: add lang-spec.h

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:20 PM  wrote:
>
> From: Philip Herron 
>
> This specifies the extensions of the Rust language.

LGTM

> ---
>  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..9b14a559dd6
> --- /dev/null
> +++ b/gcc/rust/lang-specs.h
> @@ -0,0 +1,26 @@
> +/* lang-specs.h -- gcc driver specs for Rust frontend.
> +   Copyright (C) 2009-2022 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it under
> +   the terms of the GNU General Public License as published by the Free
> +   Software Foundation; either version 3, or (at your option) any later
> +   version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +   WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +   for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with GCC; see the file COPYING3.  If not see
> +   .  */
> +
> +/* This is the contribution to the `default_compilers' array in gcc.cc
> +   for the Rust language.  */
> +
> +{".rs", "@rs", 0, 1, 0},
> +  {"@rs",
> +   "rust1 %i %(cc1_options) %{I*} %{L*} %D %{!fsyntax-only:%(invoke_as)}", 
> 0, 1,
> +   0},
> --
> 2.25.1
>
-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 07/37] gccrs: Add gcc-check-target check-rust

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Aug 24, 2022 at 2:08 PM  wrote:
>
> From: Philip Herron 
>
> This allows us to invoke the rust testsuite.

OK.

>
> ChangeLog:
> * Makefile.def: Add autogen target
> * Makefile.in: regenerate via autogen
> ---
>  Makefile.def | 1 +
>  Makefile.in  | 8 
>  2 files changed, 9 insertions(+)
>
> diff --git a/Makefile.def b/Makefile.def
> index 3291b126b26..821016af3a2 100644
> --- a/Makefile.def
> +++ b/Makefile.def
> @@ -681,6 +681,7 @@ languages = { language=go;  gcc-check-target=check-go;
>  languages = { language=d;  gcc-check-target=check-d;
> lib-check-target=check-target-libphobos; };
>  languages = { language=jit;gcc-check-target=check-jit; };
> +languages = { language=rust;   gcc-check-target=check-rust; };
>
>  // Toplevel bootstrap
>  bootstrap_stage = { id=1 ; };
> diff --git a/Makefile.in b/Makefile.in
> index 1919dfee829..9ed2c0dec52 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -60583,6 +60583,14 @@ check-gcc-jit:
> (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-jit);
>  check-jit: check-gcc-jit
>
> +.PHONY: check-gcc-rust check-rust
> +check-gcc-rust:
> +   r=`${PWD_COMMAND}`; export r; \
> +   s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
> +   $(HOST_EXPORTS) \
> +   (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-rust);
> +check-rust: check-gcc-rust
> +
>
>  # The gcc part of install-no-fixedincludes, which relies on an intimate
>  # knowledge of how a number of gcc internal targets (inter)operate.  
> Delegate.
> --
> 2.25.1
>
-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 07/37] gccrs: Add gcc-check-target check-rust

2022-09-14 Thread Jakub Jelinek via Gcc-rust
On Wed, Sep 14, 2022 at 03:41:48PM +0200, Richard Biener via Gcc-patches wrote:
> On Wed, Aug 24, 2022 at 2:08 PM  wrote:
> >
> > From: Philip Herron 
> >
> > This allows us to invoke the rust testsuite.
> 
> OK.
> 
> >
> > ChangeLog:
> > * Makefile.def: Add autogen target
> > * Makefile.in: regenerate via autogen

The changelog doesn't match what the patch does (Add rust language.
and Regenerate.), plus missing . at the end and in one case capital
letter after :

Jakub

-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH Rust front-end v2 34/37] gccrs: add lang.opt

2022-09-14 Thread Thomas Schwinge
Hi!

On 2022-09-14T15:39:47+0200, Richard Biener via Gcc-patches 
 wrote:
> On Wed, Aug 24, 2022 at 2:13 PM  wrote:
>>
>> 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.
>
> LGTM

Actually, NACK.  ;-)

See 
"gccrs setting warn_unused_variable breaks thousands of non-Rust tests".
The 'Init(1)' in 'gcc/rust/lang.opt' are in conflict with any (default)
'Init(0)' in other '*.opt' files -- remember that all '*.opt' files are
processed together by GCC's "options machinery", and thus
'gcc/rust/lang.opt' may (and here, does) affect non-Rust front end code.

I do have a patch series adding a 'LangInit(@var{language}, @var{value})'
option property, and patches to use this in a lot of places (here and in
other front ends' '*.opt' files), where currently we implement such logic
in '*.cc' files; '[...]_init_options_struct' functions via
'LANG_HOOKS_INIT_OPTIONS_STRUCT' (those then largely become empty and may
be removed).  I assume this idea to be uncontroversial; I "just" need to
get it polished and submitted...


Grüße
 Thomas


>>  gcc/rust/lang.opt | 118 ++
>>  1 file changed, 118 insertions(+)
>>  create mode 100644 gcc/rust/lang.opt
>>
>> diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
>> new file mode 100644
>> index 000..1f6855ede1d
>> --- /dev/null
>> +++ b/gcc/rust/lang.opt
>> @@ -0,0 +1,118 @@
>> +; Options for the Rust front end.
>> +; Copyright (C) 2003-2022 Free Software Foundation, Inc.
>> +;
>> +; This file is part of GCC.
>> +;
>> +; GCC is free software; you can redistribute it and/or modify it under
>> +; the terms of the GNU General Public License as published by the Free
>> +; Software Foundation; either version 3, or (at your option) any later
>> +; version.
>> +;
>> +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
>> +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> +; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>> +; for more details.
>> +;
>> +; You should have received a copy of the GNU General Public License
>> +; along with GCC; see the file COPYING3.  If not see
>> +; .
>> +
>> +; See the GCC internals manual for a description of this file's format.
>> +
>> +; Please try to keep this file in ASCII collating order.
>> +
>> +; Describes command-line options used by this frontend
>> +
>> +Language
>> +Rust
>> +
>> +I
>> +Rust Joined Separate
>> +; Documented in c.opt
>> +
>> +L
>> +Rust Joined Separate
>> +; Not documented
>> +
>> +Wall
>> +Rust
>> +; Documented in c.opt
>> +
>> +Wunused-variable
>> +Rust Var(warn_unused_variable) Init(1) Warning
>> +; documented in common.opt
>> +
>> +Wunused-const-variable
>> +Rust Warning Alias(Wunused-const-variable=, 2, 0)
>> +Warn when a const variable is unused.
>> +
>> +Wunused-const-variable=
>> +Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) Init(1) 
>> Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 2)
>> +Warn when a const variable is unused.
>> +
>> +Wunused-result
>> +Rust Var(warn_unused_result) Init(1) Warning
>> +Warn if a caller of a function, marked with attribute warn_unused_result, 
>> does not use its return value.
>> +
>> +frust-crate=
>> +Rust Joined RejectNegative
>> +-frust-crate= Set the crate name for the compilation
>> +
>> +frust-debug
>> +Rust Var(flag_rust_debug)
>> +Dump various Rust front end internals.
>> +
>> +frust-dump-
>> +Rust Joined RejectNegative
>> +-frust-dump- Dump Rust frontend internal information.
>> +
>> +frust-max-recursion-depth=
>> +Rust RejectNegative Type(int) Var(rust_max_recursion_depth) Init(64)
>> +-frust-max-recursion-depth=integer
>> +
>> +frust-mangling=
>> +Rust Joined RejectNegative Enum(frust_mangling) Var(flag_rust_mangling)
>> +-frust-mangling=[legacy|v0] Choose which version to use for name 
>> mangling
>> +
>> +Enum
>> +Name(frust_mangling) Type(int) UnknownError(unknown rust mangling option 
>> %qs)
>> +
>> +EnumValue
>> +Enum(frust_mangling) String(legacy) Value(0)
>> +
>> +EnumValue
>> +Enum(frust_mangling) String(v0) Value(1)
>> +
>> +frust-cfg=
>> +Rust Joined RejectNegative
>> +-frust-cfg= Set a config expansion option
>> +
>> +frust-edition=
>> +Rust Joined RejectNegative Enum(frust_edition) Var(flag_rust_edition)
>> +-frust-edition=[2015|2018|2021] Choose which edition to use 
>> when compiling rust code
>> +
>> +Enum
>> +Name(frust_edition) Type(int) UnknownError(unknown rust edition %qs)
>> +
>> +EnumValue
>> +Enum(frust_edition) String(2015) Value(0)
>> +
>> +EnumValue
>> +Enum(frust_edition) String(2018) Value(1)
>> +
>> +EnumValue
>> +Enum(frust_edition) 

Re: [PATCH Rust front-end v2 34/37] gccrs: add lang.opt

2022-09-14 Thread Richard Biener via Gcc-rust
On Wed, Sep 14, 2022 at 6:20 PM Thomas Schwinge  wrote:
>
> Hi!
>
> On 2022-09-14T15:39:47+0200, Richard Biener via Gcc-patches 
>  wrote:
> > On Wed, Aug 24, 2022 at 2:13 PM  wrote:
> >>
> >> 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.
> >
> > LGTM
>
> Actually, NACK.  ;-)
>
> See 
> "gccrs setting warn_unused_variable breaks thousands of non-Rust tests".
> The 'Init(1)' in 'gcc/rust/lang.opt' are in conflict with any (default)
> 'Init(0)' in other '*.opt' files -- remember that all '*.opt' files are
> processed together by GCC's "options machinery", and thus
> 'gcc/rust/lang.opt' may (and here, does) affect non-Rust front end code.

Ah, I wondered about the duplicates adding to the list of supported FEs, I guess
that the awk script should check for obvious mismatches in other settings?

> I do have a patch series adding a 'LangInit(@var{language}, @var{value})'
> option property, and patches to use this in a lot of places (here and in
> other front ends' '*.opt' files), where currently we implement such logic
> in '*.cc' files; '[...]_init_options_struct' functions via
> 'LANG_HOOKS_INIT_OPTIONS_STRUCT' (those then largely become empty and may
> be removed).  I assume this idea to be uncontroversial; I "just" need to
> get it polished and submitted...
>
>
> Grüße
>  Thomas
>
>
> >>  gcc/rust/lang.opt | 118 ++
> >>  1 file changed, 118 insertions(+)
> >>  create mode 100644 gcc/rust/lang.opt
> >>
> >> diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
> >> new file mode 100644
> >> index 000..1f6855ede1d
> >> --- /dev/null
> >> +++ b/gcc/rust/lang.opt
> >> @@ -0,0 +1,118 @@
> >> +; Options for the Rust front end.
> >> +; Copyright (C) 2003-2022 Free Software Foundation, Inc.
> >> +;
> >> +; This file is part of GCC.
> >> +;
> >> +; GCC is free software; you can redistribute it and/or modify it under
> >> +; the terms of the GNU General Public License as published by the Free
> >> +; Software Foundation; either version 3, or (at your option) any later
> >> +; version.
> >> +;
> >> +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> >> +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
> >> +; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> >> +; for more details.
> >> +;
> >> +; You should have received a copy of the GNU General Public License
> >> +; along with GCC; see the file COPYING3.  If not see
> >> +; .
> >> +
> >> +; See the GCC internals manual for a description of this file's format.
> >> +
> >> +; Please try to keep this file in ASCII collating order.
> >> +
> >> +; Describes command-line options used by this frontend
> >> +
> >> +Language
> >> +Rust
> >> +
> >> +I
> >> +Rust Joined Separate
> >> +; Documented in c.opt
> >> +
> >> +L
> >> +Rust Joined Separate
> >> +; Not documented
> >> +
> >> +Wall
> >> +Rust
> >> +; Documented in c.opt
> >> +
> >> +Wunused-variable
> >> +Rust Var(warn_unused_variable) Init(1) Warning
> >> +; documented in common.opt
> >> +
> >> +Wunused-const-variable
> >> +Rust Warning Alias(Wunused-const-variable=, 2, 0)
> >> +Warn when a const variable is unused.
> >> +
> >> +Wunused-const-variable=
> >> +Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) 
> >> Init(1) Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 
> >> 2)
> >> +Warn when a const variable is unused.
> >> +
> >> +Wunused-result
> >> +Rust Var(warn_unused_result) Init(1) Warning
> >> +Warn if a caller of a function, marked with attribute warn_unused_result, 
> >> does not use its return value.
> >> +
> >> +frust-crate=
> >> +Rust Joined RejectNegative
> >> +-frust-crate= Set the crate name for the compilation
> >> +
> >> +frust-debug
> >> +Rust Var(flag_rust_debug)
> >> +Dump various Rust front end internals.
> >> +
> >> +frust-dump-
> >> +Rust Joined RejectNegative
> >> +-frust-dump- Dump Rust frontend internal information.
> >> +
> >> +frust-max-recursion-depth=
> >> +Rust RejectNegative Type(int) Var(rust_max_recursion_depth) Init(64)
> >> +-frust-max-recursion-depth=integer
> >> +
> >> +frust-mangling=
> >> +Rust Joined RejectNegative Enum(frust_mangling) Var(flag_rust_mangling)
> >> +-frust-mangling=[legacy|v0] Choose which version to use for name 
> >> mangling
> >> +
> >> +Enum
> >> +Name(frust_mangling) Type(int) UnknownError(unknown rust mangling option 
> >> %qs)
> >> +
> >> +EnumValue
> >> +Enum(frust_mangling) String(legacy) Value(0)
> >> +
> >> +EnumValue
> >> +Enum(frust_mangling) String(v0) Value(1)
> >> +
> >> +frust-cfg=
> >> +Rust Joined RejectNegative
> >> +-frust-cfg= Set