Skip to content

likan999/KRTE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

KRTE (Kan's RunTime Environment) is a suite of glibc, gcc toolchain, and optionally a set of statically compiled libraries. The main goal of KRTE is to provide a bazel-friendly development/deployment cycle.

What makes KRTE special is it is installed at a fixed location (/opt/krte) and the binary it generates looks for libc under /opt/krte, and all other libraries are statically linked. There are several benefits for this:

  1. Bazel requires all third-party libraries being checked into the source tree, including the config.h generated by configure scripts and a manually written BUILD file. This is basically impractical for most third-party libraries as you have to be familiar with the library, to put the correct source files into cc_library, and to generate the correct config.h which is different under different platforms. By having a fixed toolchain, KRTE provides a reproduciable environment to generate the correct config.h;
    • KRTE comes with a growing set of pre-built third-party libraries so you don't even need to check in the libraries into source tree yourself;
  2. Binary generated by KRTE toolchain looks for libc under KRTE installation directory, which means if you compile the project on development machine and deploy to a production machine with KRTE installed, the binary will run properly. Of course, both development and production machine has to be Linux x86_64, which is the norm for most developers;
  3. Libraries come with KRTE are built with -flto -ffat-flto-objects, so they contain AST. This means:
    • The libraries are compiled with -fPIC, allowing them to be linked into dynamic libraries; on the other hand, when building binaries, non-PIC code will be regenerated from AST to provide better performance;
    • The libraries are compiled with -march=k8 to provide best compatibility; on the other hand, when building with -c opt, code will be regenerated to make use of instructions on build machine, together with whole program optimzation, to provide best performance.

Installation

  1. Install the KRTE: you need to create /opt/krte yourself and make sure it is writable to current user, then run ./install.sh, which will download the tarballs and unpack to it;
  2. Configure your bazel project:
    • Put the CROSSTOOL and BUILD into a directory you like (by either git submodule or git subtree) and build with --crosstool_top=//<directory>:toolchain;

    • Put the following lines in the WORKSPACE file so libraries will be available:

      local_repository(
          name = "third_party",
          path = "/opt/krte/libs",
      )

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published