Philip Herron 509e4c32c6 gccrs: Add metadata output pass
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 will now contain extra data inside
.rust-export section inside the object file which will be preserved inside
archives and shared objects. When we have another application which uses
this library 'mylib'.

  extern crate mylib;
  use mylib::foo;

  fn main() {
    foo();
  }

We compile using:

  gcc -g -O2 -frust-crate=test -c src/main.rs -o src/main.o

When the extern crate line is hit the front-end will look for mylib.o,
libmylib.a, mylib.rox. If it finds a raw object file it will read the
.rust-export section directly from the object for the public metadata
such as public functions, types constants etc. If it fails to find an
object it might find .rox which is the objdump of the .rust-export to a
raw file, it might even find libmylib.a and read the export directly out
of the archive file reusing code from gccgo to do so.

The full compiler pipeline is reused here, so the metatadata is actually
just real rust code. The benifit here is that Rust supports exporting,
macros and generics so this requires the name-resolution and type info
all to be generated and inserted into the apropriate context classes. Since
the metadata is real rust code it means we can reuse the full pipeline to
generate the code as necessary. So for the simple case of a public struct
we simply emit the AST dump of this struct directly into the metadata. If
its a non-generic public function we emit and extern rust abi block for
that function. If its a trait we can simply emit the trait with the public
memebers. Generics are more complicated since we need to emit the function
fully for it to be compiled correctly this still needs tests to be added.
The hardest part is non generic impl blocks which is still a WIP.

To finally link the two crates together you run:

  gcc -g -O2 -o rust-program.exe src/main.o src/mylib.o

	gcc/rust/
	* metadata/rust-export-metadata.cc: New.
	* metadata/rust-export-metadata.h: New.
	* metadata/rust-extern-crate.cc: New.
	* metadata/rust-extern-crate.h: New.
	* metadata/rust-import-archive.cc: New.
	* metadata/rust-imports.cc: New.
	* metadata/rust-imports.h: New.
	* rust-object-export.cc: New.
	* rust-object-export.h: New.
2022-12-13 14:00:06 +01:00
2022-11-24 00:17:47 +00:00
2022-11-15 08:32:29 +00:00
2022-12-13 00:18:07 +00:00
2022-11-24 00:17:47 +00:00
2022-12-13 14:00:06 +01:00
2022-09-01 00:17:39 +00:00
2022-08-31 00:16:45 +00:00
2022-12-08 00:17:45 +00:00
2022-11-24 00:17:47 +00:00
2022-08-26 00:16:21 +00:00
2022-11-17 00:16:52 +00:00
2022-12-11 00:17:43 +00:00
2022-11-02 00:17:38 +00:00
2022-11-24 00:17:47 +00:00
2022-12-08 00:17:45 +00:00
2022-11-24 00:17:47 +00:00
2022-12-09 00:18:54 +00:00
2022-10-13 00:17:37 +00:00
2022-12-12 14:18:14 -08:00
2022-12-11 00:17:43 +00:00
2022-11-24 00:17:47 +00:00
2022-12-12 00:22:21 +00:00
2022-10-13 00:17:37 +00:00
2022-12-13 00:18:07 +00:00
2022-11-24 00:17:47 +00:00
2022-12-01 00:17:51 +00:00
2022-11-24 00:17:47 +00:00
2022-07-19 17:07:04 +03:00
2022-12-10 00:17:39 +00:00
2021-12-21 09:10:57 +01:00
2022-12-09 11:08:55 +01:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.1 GiB
Languages
C++ 31.9%
C 31.3%
Ada 12%
D 6.5%
Go 6.4%
Other 11.5%