Merge pull request #127674 from fgaz/qbe/2021-06-17
This commit is contained in:
commit
d514b8d012
2 changed files with 42 additions and 4 deletions
|
@ -1,21 +1,27 @@
|
|||
{ lib, stdenv
|
||||
, fetchgit
|
||||
, unstableGitUpdater
|
||||
, callPackage
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "qbe";
|
||||
version = "unstable-2020-10-05";
|
||||
version = "unstable-2021-06-17";
|
||||
|
||||
src = fetchgit {
|
||||
url = "git://c9x.me/qbe.git";
|
||||
rev = "496c069405cd79aed968f59dd5a5f92d1f96809f";
|
||||
sha256 = "1vpszl77j9mnw8r0p9l23k8nxbnz31lgii7v3mai130nbpjsjsdf";
|
||||
rev = "6d9ee1389572ae985f6a39bb99dbd10cdf42c123";
|
||||
sha256 = "NaURS5Eu8NBd92wGQcyFEXCALU9Z93nNQeZ8afq4KMw=";
|
||||
};
|
||||
|
||||
makeFlags = [ "PREFIX=$(out)" ];
|
||||
|
||||
passthru.updateScript = unstableGitUpdater { };
|
||||
doCheck = true;
|
||||
|
||||
passthru = {
|
||||
tests.can-run-hello-world = callPackage ./test-can-run-hello-world.nix {};
|
||||
updateScript = unstableGitUpdater { };
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://c9x.me/compile/";
|
||||
|
|
32
pkgs/development/compilers/qbe/test-can-run-hello-world.nix
Normal file
32
pkgs/development/compilers/qbe/test-can-run-hello-world.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ stdenv
|
||||
, writeText
|
||||
, qbe
|
||||
}:
|
||||
|
||||
# The hello world program available at https://c9x.me/compile/
|
||||
let helloWorld = writeText "hello-world.ssa" ''
|
||||
function w $add(w %a, w %b) { # Define a function add
|
||||
@start
|
||||
%c =w add %a, %b # Adds the 2 arguments
|
||||
ret %c # Return the result
|
||||
}
|
||||
export function w $main() { # Main function
|
||||
@start
|
||||
%r =w call $add(w 1, w 1) # Call add(1, 1)
|
||||
call $printf(l $fmt, w %r, ...) # Show the result
|
||||
ret 0
|
||||
}
|
||||
data $fmt = { b "One and one make %d!\n", b 0 }
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "qbe-test-can-run-hello-world";
|
||||
meta.timeout = 10;
|
||||
buildCommand = ''
|
||||
${qbe}/bin/qbe -o asm.s ${helloWorld}
|
||||
cc -o out asm.s
|
||||
./out | grep 'One and one make 2!'
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
|
Loading…
Reference in a new issue