---
# System prepended metadata

title: Metadata exports for GCCRS

---

# Metadata exports for GCCRS

**Statement:**  Rustc support several different metadata outputs which are used in order to support importing crates. We need to support this, there is code in gccrs for the simple case and a framework that we can work to ensure we complete the metadata exports.

**Current State:** Currently the metadata export is about a general and export all the public stuff but missing a lot via the encoded AST dump. It doesn't support any format like rlib , clib to export the metadata.

**ToDo:** Take the general metadata and export it according to their crate type format. 

**Implemention Ideas:** 
1. *Create a Struct:*  Create a struct that represent the metadata for a crate. This struct contains a `root` field which representing the root module of the crate. The `root` module contains all of the other modules and items in the crate. Where each node contain a specific crate-type.
2. *Traverses the AST:* Traverses the AST and extracts the relevant metadata for the specified crate type using `jq` based on the value of the crate-type field in the AST dump.
     -For `lib`:  Export all the crates functions,type and other symbols.
     -For `rlib`: Export rust library crates functions, type and other symbols.
     -For `clib`: Export extern C functions.
     -For `dylib`: Export rust dynamic library crates functions, type and other symbols.
     -For `staticlib`: Export rust rust static library crates functions, type and other symbols.
     -For `cdylib`: Export system dynamic library crates functions, type and other symbols.
3. *Export via file:* We can export the metadata via writeing it on files with different extensions.
     -For `lib`: For linux or mac with `.so` extension and for windows `.dll` extension.
     -For `rlib`: `.rlib` extension for all the systems
     -For `clib`: `.clib` extension for all the systems
     -For `dylib`,`cdylib`: For linux with `.so` extension, for mac `.dylib` extension and for windows `.dll` extension.
     -For `staticlib`: For linux or mac with `.a` extension and for windows `.lib` extension.
      