Skip to content

Instantly share code, notes, and snippets.

@adrianparvino
Created May 13, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianparvino/c049dd5ca8085edb25ceef5f613ebc02 to your computer and use it in GitHub Desktop.
Save adrianparvino/c049dd5ca8085edb25ceef5f613ebc02 to your computer and use it in GitHub Desktop.
{ pkgs ? (import <nixpkgs> {})
, useClang ? false
, binutils ? pkgs.binutils
, lib ? pkgs.lib
, stdenv' ? pkgs.stdenv
, gcc ? pkgs.gcc
, clangStdenv ? pkgs.clangStdenv
, gnumake ? pkgs.gnumake
, llvmPackages ? pkgs.llvmPackages
}:
let
stdenv = stdenv';
compilerString = if useClang
then "clang"
else "gcc";
internalCompiler = if useClang
then "${llvmPackages.clang-unwrapped}/bin/${compilerString}"
else "${gcc}/bin/${compilerString}";
in
stdenv.mkDerivation rec {
name = "hlibc";
version = "0.0.1";
src = ./../..;
phases = [ "unpackPhase" "patchPhase" "checkPhase" "configurePhase" "installPhase" ];
patchPhase = if useClang then
''
substituteInPlace ./tools/create_wrappers.sh --replace '"clang' '"hardeningDisable=all exec ${internalCompiler}'
''
else "";
checkPhase = ''
echo ./tools/build.sh ${compilerString}test ${gcc}/bin/gcc
'';
postInstall = ''
ln -s $out/bin/gcc-wrap $out/bin/cc
substituteInPlace $out/bin/${compilerString}-wrap --replace 'exec ${compilerString}' 'hardeningDisable=all exec ${stdenv.cc}/bin/${compilerString}'
'';
doCheck = true;
dontDisableStatic = true;
hardeningDisable = ["all"];
nativeBuildInputs = [ ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment