From 4b8b7840cfcc3479d143cc8dbe0bf1499bf9919e Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Mon, 21 Jun 2021 15:52:48 +0200 Subject: [PATCH 1/3] qbe: unstable-2020-10-05 -> unstable-2021-06-17 --- pkgs/development/compilers/qbe/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix index b4bc2a35a55d..39241f5ee535 100644 --- a/pkgs/development/compilers/qbe/default.nix +++ b/pkgs/development/compilers/qbe/default.nix @@ -5,12 +5,12 @@ 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)" ]; From 72419d8ee07c80a17f077c2714f859ef06b4e459 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Mon, 21 Jun 2021 15:53:14 +0200 Subject: [PATCH 2/3] qbe: add hello world test --- pkgs/development/compilers/qbe/default.nix | 6 +++- .../qbe/test-can-run-hello-world.nix | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/compilers/qbe/test-can-run-hello-world.nix diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix index 39241f5ee535..35367b3b2efe 100644 --- a/pkgs/development/compilers/qbe/default.nix +++ b/pkgs/development/compilers/qbe/default.nix @@ -1,6 +1,7 @@ { lib, stdenv , fetchgit , unstableGitUpdater +, callPackage }: stdenv.mkDerivation rec { @@ -15,7 +16,10 @@ stdenv.mkDerivation rec { makeFlags = [ "PREFIX=$(out)" ]; - passthru.updateScript = unstableGitUpdater { }; + 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 + ''; +} + From d2a8d3c6231b887662216fba4d4356387d576218 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Mon, 21 Jun 2021 15:55:50 +0200 Subject: [PATCH 3/3] qbe: enable tests --- pkgs/development/compilers/qbe/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix index 35367b3b2efe..e2e0c92a162d 100644 --- a/pkgs/development/compilers/qbe/default.nix +++ b/pkgs/development/compilers/qbe/default.nix @@ -16,6 +16,8 @@ stdenv.mkDerivation rec { makeFlags = [ "PREFIX=$(out)" ]; + doCheck = true; + passthru = { tests.can-run-hello-world = callPackage ./test-can-run-hello-world.nix {}; updateScript = unstableGitUpdater { };