kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

runtime.h (2715B)


      1 #ifndef KIT_DRIVER_RUNTIME_H
      2 #define KIT_DRIVER_RUNTIME_H
      3 
      4 #include <kit/link.h>
      5 
      6 #include "cflags.h"
      7 #include "driver.h"
      8 
      9 typedef struct DriverRuntimeSupport {
     10   char* support_root;
     11   size_t support_root_size;
     12   char* rt_root;
     13   size_t rt_root_size;
     14   char* include_dir;
     15   size_t include_dir_size;
     16   /* Owned dup of the kit image path that located the rt tree — argv[0] when it
     17    * was a usable path, else the real self-exe path (GetModuleFileNameW /
     18    * /proc/self/exe). Stat'd for rt-archive cache invalidation; freed by
     19    * driver_runtime_support_fini. */
     20   const char* tool_path;
     21   size_t tool_path_size;
     22   /* Set when rt was resolved as a <bindir>/support/rt sibling, i.e. a
     23    * distribution install rather than a source checkout.  Steers the on-demand
     24    * rt archive build toward the user cache dir instead of writing into the
     25    * (read-only-by-convention) install tree.  See driver_runtime_ensure_archive.
     26    */
     27   uint8_t install_layout;
     28 } DriverRuntimeSupport;
     29 
     30 typedef struct DriverRuntimeArchive {
     31   char* path;
     32   size_t path_size;
     33   uint8_t whole_archive;
     34   uint8_t link_mode;
     35   uint8_t group_id;
     36 } DriverRuntimeArchive;
     37 
     38 int driver_runtime_resolve(DriverEnv* env, const char* explicit_support_dir,
     39                            const char* argv0, DriverRuntimeSupport* out);
     40 void driver_runtime_support_fini(DriverEnv* env, DriverRuntimeSupport* s);
     41 
     42 int driver_runtime_add_freestanding_headers(const DriverRuntimeSupport* s,
     43                                             DriverCflags* cf);
     44 int driver_runtime_append_freestanding_headers(const DriverRuntimeSupport* s,
     45                                                DriverCflags* cf);
     46 
     47 int driver_runtime_ensure_archive(DriverEnv* env, const char* tool,
     48                                   const DriverRuntimeSupport* support,
     49                                   KitTargetSpec target, uint64_t epoch,
     50                                   char** out_path, size_t* out_path_size);
     51 int driver_runtime_prepare_archive(DriverEnv* env, const char* tool,
     52                                    const DriverRuntimeSupport* support,
     53                                    KitTargetSpec target, uint64_t epoch,
     54                                    DriverRuntimeArchive* out);
     55 void driver_runtime_archive_fini(DriverEnv* env, DriverRuntimeArchive* a);
     56 
     57 /* True if kit knows how to build/provide a compiler runtime for `target`,
     58  * including the freestanding riscv32/riscv64-none-elf targets. For RISC-V the
     59  * match also keys on target.float_abi, so rv32 ilp32 (soft) and ilp32f (single)
     60  * select distinct runtimes. A target with no variant should not be auto-linked
     61  * — that image supplies its own runtime. */
     62 int driver_runtime_has_variant(KitTargetSpec target);
     63 
     64 #endif