GithubHelp home page GithubHelp logo

langston-barrett / nixpkgs-blight Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 0.0 20 KB

Instrument the builds of tens of thousands of open-source packages

Makefile 10.61% Nix 88.41% Shell 0.98%
nix blight

nixpkgs-blight's Introduction

nixpkgs-blight

tl;dr

nixpkgs-blight can instrument the builds of tens of thousands of open-source packages. This can be used to:

  • Record and analyze compiler/linker flags used by open-source projects
  • Inject dynamic instrumentation like ASan into build processes and run the resulting program's test suite
  • Build LLVM bitcode instead of normal executables using gllvm
  • Stress test your static analysis tool, compiler, or LLVM pass against thousands of real-world programs

Table of Contents

Table of Contents

What

blight is a wrapper for C/C++ build tools (CC, CXX, LD, etc.). Out of the box, it can perform a variety of useful actions:

  • Recording flags passed to each tool
  • Injecting flags
  • Benchmarking builds
  • Finding build outputs

nixpkgs is a massive, active package repository with extensible, reproducible builds.

This repo combines the two to allow for reproducible instrumentation of thousands of open-source packages. Specifically, it provides:

  • A Nix expression for blight
  • A framework for using blight inside nixpkgs builds that use common build tools:
    • Make
    • CMake
    • Autotools

Usage

First, install Make and Nix.

In all the following examples, package-name can be replaced with any package in nixpkgs, e.g. entr or hello. For a full list, see

nix eval '(builtins.attrNames (import <nixpkgs> { }))'

or

nix search "some package"

or https://search.nixos.org/packages.

Recording a Build Log

make out/instrument/package-name
less out/instrument/package-name/record.jsonl

Building LLVM Bitcode

make out/bitcode/package-name

Injecting -Werror

make out/inject/package-name

How

For each relevant build system, there is a Nix function that overrides a derivation to check if that derivation is using that build system, writing the result to a file in the overriden derivation's output. This can be used in further Nix expressions to instrument the build system appropriately (for example, by setting CC for Make-based builds, setting cmakeFlags for CMake-based builds, etc.).

After deducing a build system, Nix expressions can override the derivation again, this time configuring blight to do its job.

Development

PRs welcome!

Debugging

make NIXFLAGS="--show-trace --arg debug true"

Testing

  • For a package with a Makefile, try entr.
  • For a package with a CMakeLists.txt, try yarp.

nixpkgs-blight's People

Contributors

langston-barrett avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.