git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #127674 from fgaz/qbe/2021-06-17
commitd514b8d0128cb5ba87488f0cc349bb72a44c8606 authorSandro <sandro.jaeckel@gmail.com> dateTue 22 Jun 2021, 02:38 (5 years ago) parent6636bc0d2a8d3c
2 files changed+42−4
pkgs/development/compilers/qbe/default.nix+10−4 pkgs/development/compilers/qbe/test-can-run-hello-world.nix+32
pkgs/development/compilers/qbe/default.nix+10−4
@@ -1,21 +1,27 @@
11{ lib, stdenv
22, fetchgit
33, unstableGitUpdater
4+, callPackage
45}:
56
67stdenv.mkDerivation rec {
78 pname = "qbe";
8− version = "unstable-2020-10-05";
9+ version = "unstable-2021-06-17";
910
1011 src = fetchgit {
1112 url = "git://c9x.me/qbe.git";
12− rev = "496c069405cd79aed968f59dd5a5f92d1f96809f";
13− sha256 = "1vpszl77j9mnw8r0p9l23k8nxbnz31lgii7v3mai130nbpjsjsdf";
13+ rev = "6d9ee1389572ae985f6a39bb99dbd10cdf42c123";
14+ sha256 = "NaURS5Eu8NBd92wGQcyFEXCALU9Z93nNQeZ8afq4KMw=";
1415 };
1516
1617 makeFlags = [ "PREFIX=$(out)" ];
1718
18− passthru.updateScript = unstableGitUpdater { };
19+ doCheck = true;
20+
21+ passthru = {
22+ tests.can-run-hello-world = callPackage ./test-can-run-hello-world.nix {};
23+ updateScript = unstableGitUpdater { };
24+ };
1925
2026 meta = with lib; {
2127 homepage = "https://c9x.me/compile/";
pkgs/development/compilers/qbe/test-can-run-hello-world.nixnew file+32
@@ -0,0 +1,32 @@
1+{ stdenv
2+, writeText
3+, qbe
4+}:
5+
6+# The hello world program available at https://c9x.me/compile/
7+let helloWorld = writeText "hello-world.ssa" ''
8+ function w $add(w %a, w %b) { # Define a function add
9+ @start
10+ %c =w add %a, %b # Adds the 2 arguments
11+ ret %c # Return the result
12+ }
13+ export function w $main() { # Main function
14+ @start
15+ %r =w call $add(w 1, w 1) # Call add(1, 1)
16+ call $printf(l $fmt, w %r, ...) # Show the result
17+ ret 0
18+ }
19+ data $fmt = { b "One and one make %d!\n", b 0 }
20+'';
21+
22+in stdenv.mkDerivation {
23+ name = "qbe-test-can-run-hello-world";
24+ meta.timeout = 10;
25+ buildCommand = ''
26+ ${qbe}/bin/qbe -o asm.s ${helloWorld}
27+ cc -o out asm.s
28+ ./out | grep 'One and one make 2!'
29+ touch $out
30+ '';
31+}
32+