diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix index b4bc2a35a55d..e2e0c92a162d 100644 --- a/pkgs/development/compilers/qbe/default.nix +++ b/pkgs/development/compilers/qbe/default.nix @@ -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/"; diff --git a/pkgs/development/compilers/qbe/test-can-run-hello-world.nix b/pkgs/development/compilers/qbe/test-can-run-hello-world.nix new file mode 100644 index 000000000000..5192bb881f34 --- /dev/null +++ b/pkgs/development/compilers/qbe/test-can-run-hello-world.nix @@ -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 + ''; +} +