Skip to content

Instantly share code, notes, and snippets.

@yvt
Last active May 1, 2022 01:43
Show Gist options
  • Save yvt/e325b65db5fcd0ca27ea7294f9dfbba4 to your computer and use it in GitHub Desktop.
Save yvt/e325b65db5fcd0ca27ea7294f9dfbba4 to your computer and use it in GitHub Desktop.
Nix code to build a patched version of `libgccjit.so` for <https://github.com/rust-lang/rustc_codegen_gcc>
with import <nixpkgs> {};
with lib;
let
antoyoGccRev = "72cb89f82a6c9c5471f0b2c122b21dbe387c7904";
gccjit = (gcc11.cc.overrideAttrs (oldAttrs: oldAttrs // {
src = fetchFromGitHub {
owner = "antoyo";
repo = "gcc";
rev = antoyoGccRev;
sha256 = "+h/ezfeEs+VoPjK1nl3LKk+proeGaoNQEduwZ+2aJos=";
};
name = "libgccjit";
version = antoyoGccRev;
nativeBuildInputs = oldAttrs.nativeBuildInputs
++ [ flex ];
prePatch = ''
mv gcc/gcc.cc gcc/gcc.c
mv gcc/cppdefault.cc gcc/cppdefault.c
'';
postPatch = oldAttrs.postPatch + ''
mv gcc/gcc.c gcc/gcc.cc
mv gcc/cppdefault.c gcc/cppdefault.cc
'';
configureFlags = oldAttrs.configureFlags ++
[ "--disable-werror" ];
})).override {
langFortran = false;
langCC = false;
langC = false;
profiledCompiler = false;
langJit = true;
enableLTO = false;
# noSysDirs = false;
};
in
runCommand "dummy" rec {
buildInputs = [
gccjit
];
GCC_PATH = "${gccjit}/lib";
} ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment