The C library a choice: -libc glibc|musl, musl by default where only its loader is Elf names glibc's loader and libc.so.6, or musl's and libc.so, which musl's loader takes for itself (setMusl). Raz takes -libc, or else chooses musl on a machine with musl's loader and not glibc's, as Alpine has. Sys over C, to run over musl: close_range through syscall, as musl has no close_range; and inetAddr reads an address into a buffer of its own first, since musl's inet_pton leaves what it read of an IPv4 address it refuses, which fell in the IPv6 one's flow bytes. make check runs test/libc again over musl where its loader is installed; make alpine (test/alpine.sh) compiles and runs it in an Alpine container, where the default must be musl.
| @@ -81,6 +81,10 @@ | ||
| 81 | 81 | # native threads under load: 40,000 spawned and joined, 200 alive at a |
| 82 | 82 | # time, all waiting on one Mutex; then, with little memory, spawn must |
| 83 | 83 | # fail with Thread.Failed. make check runs a small version. |
| 84 | +# test/libc on Alpine, over musl, in docker | |
| 85 | +alpine: raz | |
| 86 | + test/alpine.sh | |
| 87 | + | |
| 84 | 88 | stress: raz | build |
| 85 | 89 | ./raz -o build/Stress lib/Thread.linux-x86_64.raz |
| 86 | 90 | build/Stress 40000 200 |
| @@ -181,4 +185,4 @@ | ||
| 181 | 185 | site: raz pdf |
| 182 | 186 | python3 site/build.py |
| 183 | 187 | |
| 184 | -.PHONY: units tests seed-bench fixpoint check gdb bench kernels stress fmt loc man pdf dist site clean install uninstall | |
| 188 | +.PHONY: units tests seed-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site clean install uninstall |
| @@ -83,7 +83,7 @@ | ||
| 83 | 83 | |
| 84 | 84 | ## Using it |
| 85 | 85 | |
| 86 | - raz [-I dir]... [-o file] [-Werror] [-S] [-s] [-noprofile] Main.raz | |
| 86 | + raz [-I dir]... [-o file] [-Werror] [-S] [-s] [-noprofile] [-libc glibc|musl] Main.raz | |
| 87 | 87 | raz run [option]... Main.raz [arg]... |
| 88 | 88 | raz -h |
| 89 | 89 | raz --version |
| @@ -22,8 +22,8 @@ | ||
| 22 | 22 | | `src/Item.raz` | 2,037 | 1,651 | Items: types, constants, variables, operators, conversions, calls | |
| 23 | 23 | | `src/Parse.raz` | 4,176 | 3,615 | Declarations, statements, expressions, built-ins, recovery, warnings | |
| 24 | 24 | | `src/Link.raz` | 381 | 298 | Tree shaking, layout, patching, the places | |
| 25 | -| `src/Elf.raz` | 431 | 344 | Static and dynamic ELF, symbol table, line numbers | | |
| 26 | -| `src/Raz.raz` | 305 | 238 | The command line | | |
| 25 | +| `src/Elf.raz` | 449 | 355 | Static and dynamic ELF, symbol table, line numbers | | |
| 26 | +| `src/Raz.raz` | 326 | 253 | The command line | | |
| 27 | 27 | |
| 28 | 28 | Every file opens with a comment that says what it is, what it depends |
| 29 | 29 | on and what it leaves out. Read those first; they are the map. |
| @@ -1636,8 +1636,15 @@ | ||
| 1636 | 1636 | section naming the libraries; and, for each C symbol the program uses, |
| 1637 | 1637 | a symbol and a `GLOB_DAT` relocation that has the loader write the |
| 1638 | 1638 | symbol's address into the quadword `Chunk.externChunk` made. Code calls C |
| 1639 | -through that quadword. There is no PLT and no lazy binding. | |
| 1640 | -`sizeTables` and `putTables` lay these out in the room `Link.raz` left | |
| 1639 | +through that quadword. There is no PLT and no lazy binding. The | |
| 1640 | +loader and the first library are glibc's, | |
| 1641 | +`/lib64/ld-linux-x86-64.so.2` and `libc.so.6`, or musl's, | |
| 1642 | +`/lib/ld-musl-x86_64.so.1` and `libc.so`, which musl's loader, being | |
| 1643 | +the library itself, takes to mean itself (`Elf.setMusl`). `-libc` | |
| 1644 | +chooses; left out, `Raz.muslHere` chooses musl where the machine has | |
| 1645 | +its loader and not glibc's, as Alpine does. A symbol that isn't live | |
| 1646 | +gets no relocation, so a program runs over a C library that lacks a | |
| 1647 | +procedure it declares but never reaches. `sizeTables` and `putTables` lay these out in the room `Link.raz` left | |
| 1641 | 1648 | at the end of rodata. |
| 1642 | 1649 | |
| 1643 | 1650 | Line numbers are DWARF 4: the line table `makeLines` made from the |
| @@ -1682,7 +1689,9 @@ | ||
| 1682 | 1689 | - **The target.** x86-64 Linux, `linux-x86_64`: `INT` is 64 bits, and |
| 1683 | 1690 | there are reals. Every module of a program is compiled together, in |
| 1684 | 1691 | one run, into a static ELF executable, or a dynamic one if the |
| 1685 | - program uses C; no object files. | |
| 1692 | + program uses C; no object files. The C library is glibc or musl, | |
| 1693 | + as `-libc` says, or by default glibc, and musl where only its | |
| 1694 | + loader is there. | |
| 1686 | 1695 | - **Finding modules.** `raz Main.raz` looks for `X`, imported, in |
| 1687 | 1696 | `Main.raz`'s directory, then in each `-I dir` in the order given |
| 1688 | 1697 | (16 at most), then in `lib` beside the `raz` executable, following |
| @@ -103,6 +103,16 @@ | ||
| 103 | 103 | Leave out the profiler, which |
| 104 | 104 | .Ev RAZ_PROFILE |
| 105 | 105 | turns on, but keep the rest. |
| 106 | +.It Fl libc Ar name | |
| 107 | +Link a program that uses C against | |
| 108 | +.Ar name , | |
| 109 | +.Cm glibc | |
| 110 | +or | |
| 111 | +.Cm musl . | |
| 112 | +Left out, it is glibc, or musl on a machine that has musl's loader, | |
| 113 | +.Pa /lib/ld-musl-x86_64.so.1 , | |
| 114 | +and not glibc's, as Alpine has. | |
| 115 | +A program without C needs no C library, and runs on either. | |
| 106 | 116 | .It Fl h , Fl \-help |
| 107 | 117 | Say the options. |
| 108 | 118 | .It Fl \-version |
| @@ -76,6 +76,7 @@ | ||
| 76 | 76 | extern proc dup2*(fd, fd2: I32): I32; |
| 77 | 77 | extern proc dup*(fd: I32): I32; |
| 78 | 78 | extern proc close_range*(first, last: U32; flags: I32): I32; |
| 79 | +extern proc syscall*(n: INT; ...): INT; (* a system call by its number, on Linux *) | |
| 79 | 80 | extern proc execve*(path: ^U8; argv, envp: ^^U8): I32; |
| 80 | 81 | extern proc waitpid*(pid: I32; status: ^I32; options: I32): I32; |
| 81 | 82 | extern proc kill*(pid, signal: I32): I32; |
| @@ -7,7 +7,8 @@ | ||
| 7 | 7 | only the two struct timeval that begin struct rusage are read. What |
| 8 | 8 | is glibc's, on x86-64: where a name lies in struct dirent; struct |
| 9 | 9 | stat; open's flags; the numbers of the requests TIOCGWINSZ, |
| 10 | - TIOCSWINSZ and TIOCSCTTY, and of F_DUPFD_CLOEXEC; close_range; | |
| 10 | + TIOCSWINSZ and TIOCSCTTY, and of F_DUPFD_CLOEXEC; close_range's | |
| 11 | + system call; | |
| 11 | 12 | SOCK_CLOEXEC, AF_INET6 and SO_REUSEADDR; struct sockaddr_un and sockaddr_in, which on the BSDs |
| 12 | 13 | start with a byte of length; the numbers of the signals and of the |
| 13 | 14 | limits, and RLIM_INFINITY, all ones. A C library that differs needs |
| @@ -772,13 +773,24 @@ | ||
| 772 | 773 | of its struct sockaddr_in or sockaddr_in6, or 0 if either is |
| 773 | 774 | wrong. *) |
| 774 | 775 | proc inetAddr(addr: []U8; port: INT; a: ^Sockaddr): INT; |
| 775 | -var s: [64]U8; | |
| 776 | +var s: [64]U8; b: [16]U8; | |
| 776 | 777 | begin |
| 777 | 778 | if (port < 0) or (port > 65535) or not cstr(addr, s) then return 0; end; |
| 778 | 779 | a^.port[0] := U8(port shr 8); (* in the network's order, the high byte first *) |
| 779 | 780 | a^.port[1] := U8(port & 255); |
| 780 | - if C.inet_pton(2, ADR(s[0]), ADR(a^.data[0])) = 1 then a^.family := 2; return 16; end; (* AF_INET *) | |
| 781 | - if C.inet_pton(10, ADR(s[0]), ADR(a^.data[4])) = 1 then a^.family := 10; return 28; end; (* AF_INET6 *) | |
| 781 | + (* into b first, since musl's inet_pton leaves what it read of an | |
| 782 | + address it refuses, and the IPv6 one's first four bytes are its | |
| 783 | + flow, to be zero *) | |
| 784 | + if C.inet_pton(2, ADR(s[0]), ADR(b[0])) = 1 then (* AF_INET *) | |
| 785 | + a^.family := 2; | |
| 786 | + COPY(a^.data[0..4], b[0..4]); | |
| 787 | + return 16; | |
| 788 | + end; | |
| 789 | + if C.inet_pton(10, ADR(s[0]), ADR(b[0])) = 1 then (* AF_INET6 *) | |
| 790 | + a^.family := 10; | |
| 791 | + COPY(a^.data[4..20], b); | |
| 792 | + return 28; | |
| 793 | + end; | |
| 782 | 794 | return 0; |
| 783 | 795 | end; |
| 784 | 796 | |
| @@ -1378,7 +1390,8 @@ | ||
| 1378 | 1390 | (* Closes every fd from 3 on but those of keep, which stay open in the |
| 1379 | 1391 | program exec starts. It runs in spawn's child, after the fork, so it |
| 1380 | 1392 | takes no memory: it closes the runs between the fds kept, the lowest |
| 1381 | - first, each with one close_range. *) | |
| 1393 | + first, each with one close_range: through syscall, since musl has no | |
| 1394 | + close_range of its own. *) | |
| 1382 | 1395 | proc closeAllBut(keep: []INT); |
| 1383 | 1396 | var lo, next, i: INT; |
| 1384 | 1397 | begin |
| @@ -1389,9 +1402,9 @@ | ||
| 1389 | 1402 | if (keep[i] >= lo) and ((next < 0) or (keep[i] < next)) then next := keep[i]; end; |
| 1390 | 1403 | end; |
| 1391 | 1404 | if next < 0 then |
| 1392 | - _ := C.close_range(U32(lo), 0FFFFFFFFH, 0); (* the rest *) | |
| 1405 | + _ := C.syscall(436, lo, 0FFFFFFFFH, 0); (* close_range, the rest *) | |
| 1393 | 1406 | else |
| 1394 | - if next > lo then _ := C.close_range(U32(lo), U32(next - 1), 0); end; | |
| 1407 | + if next > lo then _ := C.syscall(436, lo, next - 1, 0); end; | |
| 1395 | 1408 | _ := C.fcntl(I32(next), 2, 0); (* F_SETFD: kept on exec *) |
| 1396 | 1409 | lo := next + 1; |
| 1397 | 1410 | end; |
| @@ -19,8 +19,11 @@ | ||
| 19 | 19 | Leaves out: position independent executables, symbol versions, the |
| 20 | 20 | rest of DWARF. |
| 21 | 21 | |
| 22 | - Exported variables can't be set from outside, so needLib, setMainPath | |
| 23 | - and setStripped do it. *) | |
| 22 | + The C library is glibc's or musl's, as setMusl says: the loader the | |
| 23 | + program names, and the library it needs first. | |
| 24 | + | |
| 25 | + Exported variables can't be set from outside, so needLib, setMusl, | |
| 26 | + setMainPath and setStripped do it. *) | |
| 24 | 27 | module Elf; |
| 25 | 28 | import Sys, Files, Fmt, Diag, Scan, Chunk, Link; |
| 26 | 29 | |
| @@ -29,6 +32,8 @@ | ||
| 29 | 32 | numNeeded*: INT; (* none: a static program *) |
| 30 | 33 | mainPath: []U8; (* the main module's file, for gdb *) |
| 31 | 34 | stripped*: BOOL; (* -s: no symbols and no line numbers; the sections are there, empty *) |
| 35 | + interp: []U8; (* the loader a program that uses C names *) | |
| 36 | + libc*: []U8; (* and the C library it needs *) | |
| 32 | 37 | |
| 33 | 38 | buf: ^U8; |
| 34 | 39 | len, cap: INT; |
| @@ -53,6 +58,20 @@ | ||
| 53 | 58 | numNeeded := 0; |
| 54 | 59 | end; |
| 55 | 60 | |
| 61 | +(* A program that uses C is linked against musl, if yes, or glibc. | |
| 62 | + musl's library is its own loader, which takes libc.so to mean | |
| 63 | + itself, whatever file the system keeps it in. *) | |
| 64 | +proc setMusl*(yes: BOOL); | |
| 65 | +begin | |
| 66 | + if yes then | |
| 67 | + interp := "/lib/ld-musl-x86_64.so.1"; | |
| 68 | + libc := "libc.so"; | |
| 69 | + else | |
| 70 | + interp := "/lib64/ld-linux-x86-64.so.2"; | |
| 71 | + libc := "libc.so.6"; | |
| 72 | + end; | |
| 73 | +end; | |
| 74 | + | |
| 56 | 75 | proc setMainPath*(path: []U8); |
| 57 | 76 | begin |
| 58 | 77 | mainPath := path; |
| @@ -195,7 +214,6 @@ | ||
| 195 | 214 | end; |
| 196 | 215 | |
| 197 | 216 | const |
| 198 | - Interp = "/lib64/ld-linux-x86-64.so.2"; | |
| 199 | 217 | (* program header types *) |
| 200 | 218 | PtLoad = 1; PtDynamic = 2; PtInterp = 3; PtGnuStack = 6474E551H; |
| 201 | 219 | |
| @@ -224,7 +242,7 @@ | ||
| 224 | 242 | strLen := strLen + LEN(Scan.nameOf(Chunk.chunks[c].name)) + 1; |
| 225 | 243 | end; |
| 226 | 244 | end; |
| 227 | - symAt := (LEN(Interp) + 1 + 7) div 8 * 8; | |
| 245 | + symAt := (LEN(interp) + 1 + 7) div 8 * 8; | |
| 228 | 246 | relaAt := symAt + nsym * 24; |
| 229 | 247 | hashAt := relaAt + (nsym - 1) * 24; |
| 230 | 248 | strAt := hashAt + 4 * (3 + nsym); |
| @@ -240,7 +258,7 @@ | ||
| 240 | 258 | var c, k, i, at, name: INT; |
| 241 | 259 | begin |
| 242 | 260 | len := Link.extraAdr - Link.roAdr + Link.roOff; |
| 243 | - putStr(Interp); | |
| 261 | + putStr(interp); | |
| 244 | 262 | padTo(Link.extraAdr - Link.roAdr + Link.roOff + symAt); |
| 245 | 263 | putN(0, 24); |
| 246 | 264 | name := strLen; |
| @@ -334,7 +352,7 @@ | ||
| 334 | 352 | |
| 335 | 353 | (* flags: 4 read, 5 read and run, 6 read and write *) |
| 336 | 354 | if dyn then |
| 337 | - phdr(PtInterp, 4, Link.extraAdr - Link.roAdr + Link.roOff, Link.extraAdr, LEN(Interp) + 1, LEN(Interp) + 1, 1); | |
| 355 | + phdr(PtInterp, 4, Link.extraAdr - Link.roAdr + Link.roOff, Link.extraAdr, LEN(interp) + 1, LEN(interp) + 1, 1); | |
| 338 | 356 | end; |
| 339 | 357 | (* the first segment maps the headers too, so text can follow them *) |
| 340 | 358 | phdr(PtLoad, 5, 0, Link.Base, Link.textOff + Link.textSize, Link.textOff + Link.textSize, Link.Page); |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | (* Raz: the command line. |
| 2 | 2 | |
| 3 | - raz [-I dir]... [-o file] [-Werror] [-S] Main.raz | |
| 3 | + raz [-I dir]... [-o file] [-Werror] [-S] [-libc glibc|musl] Main.raz | |
| 4 | 4 | raz run [-I dir]... Main.raz [arg]... |
| 5 | 5 | raz --version |
| 6 | 6 | |
| @@ -18,7 +18,9 @@ | ||
| 18 | 18 | status. A static program does this from its entry point. One that |
| 19 | 19 | uses C starts through the C library, __libc_start_main, which sets |
| 20 | 20 | C up and calls this as C's main; first it gives Rt C's exit, which |
| 21 | - Rt.exit then ends the program with. | |
| 21 | + Rt.exit then ends the program with. The C library is glibc, or musl | |
| 22 | + on a machine that has musl's loader and not glibc's, unless -libc | |
| 23 | + names one. | |
| 22 | 24 | |
| 23 | 25 | Depends on: everything else, and Version, a module the build makes |
| 24 | 26 | (build/src/Version.raz) from what git describe says, as the seed's |
| @@ -72,7 +74,7 @@ | ||
| 72 | 74 | begin |
| 73 | 75 | st := nil; c := nil; |
| 74 | 76 | Elf.noLibs(); |
| 75 | - _ := Elf.needLib(internStr("libc.so.6")); | |
| 77 | + _ := Elf.needLib(internStr(Elf.libc)); | |
| 76 | 78 | m := Parse.firstModule; |
| 77 | 79 | while m # nil do |
| 78 | 80 | if m^.used and m^.linkStatic then st := m; end; |
| @@ -104,12 +106,23 @@ | ||
| 104 | 106 | Out.str(" -s strips symbols, line numbers, the places a failure is told\n"); |
| 105 | 107 | Out.str(" by and the profiler: a failure says only its address\n"); |
| 106 | 108 | Out.str(" -noprofile leaves out the profiler, which RAZ_PROFILE turns on\n"); |
| 109 | + Out.str(" -libc name links a program that uses C against glibc or musl; by\n"); | |
| 110 | + Out.str(" default glibc, or musl where only its loader is there\n"); | |
| 107 | 111 | Out.str(" -h, --help says this\n"); |
| 108 | 112 | Out.str(" --version says the version, and the report it follows\n"); |
| 109 | 113 | Out.str("see raz(1), and the report, doc/raz.md\n"); |
| 110 | 114 | Out.flush(); |
| 111 | 115 | end; |
| 112 | 116 | |
| 117 | +(* Whether a program that uses C is linked against musl when -libc | |
| 118 | + doesn't say: only if the machine has musl's loader and not glibc's, | |
| 119 | + as Alpine has *) | |
| 120 | +proc muslHere: BOOL; | |
| 121 | +begin | |
| 122 | + return (Sys.access("/lib64/ld-linux-x86-64.so.2", {}) # 0) | |
| 123 | + and (Sys.access("/lib/ld-musl-x86_64.so.1", {}) = 0); | |
| 124 | +end; | |
| 125 | + | |
| 113 | 126 | (* The module named n, or nil if the program has none *) |
| 114 | 127 | proc moduleNamed(n: []U8): ^Sym.Module; |
| 115 | 128 | var m: ^Sym.Module; |
| @@ -159,12 +172,13 @@ | ||
| 159 | 172 | path, outPath, s: []U8; dir: []U8; |
| 160 | 173 | i, first, entry, fd, last, errno: INT; |
| 161 | 174 | m, rt, thread: ^Sym.Module; mainObj: ^Sym.Obj; |
| 162 | - run, noProfile, listing, dynamic: BOOL; err: ERROR; | |
| 175 | + run, noProfile, listing, dynamic, libcSaid: BOOL; err: ERROR; | |
| 163 | 176 | begin |
| 164 | 177 | path := ""; |
| 165 | 178 | outPath := ""; |
| 166 | 179 | noProfile := false; |
| 167 | 180 | listing := false; |
| 181 | + libcSaid := false; | |
| 168 | 182 | run := (ARGC() >= 2) and (Files.arg(1) = "run"); |
| 169 | 183 | if run then i := 2; else i := 1; end; |
| 170 | 184 | while i < ARGC() do |
| @@ -185,6 +199,12 @@ | ||
| 185 | 199 | Elf.setStripped(true); |
| 186 | 200 | elsif s = "-noprofile" then |
| 187 | 201 | noProfile := true; |
| 202 | + elsif s = "-libc" then | |
| 203 | + INC(i); | |
| 204 | + s := Files.arg(i); | |
| 205 | + if (s # "glibc") and (s # "musl") then Diag.fatal(say1("unknown C library {}: glibc or musl", s)); end; | |
| 206 | + Elf.setMusl(s = "musl"); | |
| 207 | + libcSaid := true; | |
| 188 | 208 | elsif (s = "-h") or (s = "--help") then |
| 189 | 209 | usage(); |
| 190 | 210 | return 0; |
| @@ -206,6 +226,7 @@ | ||
| 206 | 226 | return 1; |
| 207 | 227 | end; |
| 208 | 228 | if run and (LEN(outPath) > 0) then Diag.fatal("raz run takes no -o"); end; |
| 229 | + if not libcSaid then Elf.setMusl(muslHere()); end; | |
| 209 | 230 | (* where raz is, as the system says, for the library beside it *) |
| 210 | 231 | dir, errno := Sys.readLink("/proc/self/exe"); |
| 211 | 232 | if errno # 0 then dir := Files.arg(0); end; |
| @@ -0,0 +1,32 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# Runs test/libc on Alpine, whose C library is musl, in a docker | |
| 3 | +# container: raz, a static program, compiles each program there, so it | |
| 4 | +# links it against musl by default, having only musl's loader; then | |
| 5 | +# each runs, its output and status compared as test/check.sh compares | |
| 6 | +# them. Needs docker, and the network the first time, for the image. | |
| 7 | + | |
| 8 | +image=${ALPINE:-alpine:3.20} | |
| 9 | +exec docker run --rm -v "$PWD":/raz:ro -w /raz "$image" sh -c ' | |
| 10 | +pass=0; fail=0; out=/tmp/out; mkdir -p $out | |
| 11 | +for f in test/libc/*.raz; do | |
| 12 | + name=$(basename $f .raz) | |
| 13 | + if ! ./raz -Werror -I test/libc/mods -o $out/$name $f 2>$out/$name.cerr; then | |
| 14 | + echo "FAIL $f: does not compile: $(cat $out/$name.cerr)"; fail=$((fail + 1)); continue | |
| 15 | + fi | |
| 16 | + if ! grep -q ld-musl $out/$name; then # the loader it names | |
| 17 | + echo "FAIL $f: not linked against musl"; fail=$((fail + 1)); continue | |
| 18 | + fi | |
| 19 | + [ -f test/libc/$name.expect ] || { pass=$((pass + 1)); continue; } | |
| 20 | + status=$( { ( cd /tmp && exec $out/$name ) > $out/$name.out 2>$out/$name.err; echo $?; } 2>/dev/null ) | |
| 21 | + want=0; [ -f test/libc/$name.status ] && want=$(cat test/libc/$name.status) | |
| 22 | + if ! cmp -s $out/$name.out test/libc/$name.expect; then | |
| 23 | + echo "FAIL $f: output differs"; diff $out/$name.out test/libc/$name.expect | head -5; fail=$((fail + 1)) | |
| 24 | + elif [ $status != $want ]; then | |
| 25 | + echo "FAIL $f: status $status, not $want"; cat $out/$name.err | head -5; fail=$((fail + 1)) | |
| 26 | + else | |
| 27 | + pass=$((pass + 1)) | |
| 28 | + fi | |
| 29 | +done | |
| 30 | +cat /etc/alpine-release | sed "s/^/Alpine /" | |
| 31 | +echo "$pass passed, $fail failed" | |
| 32 | +[ $fail = 0 ]' |
| @@ -35,8 +35,8 @@ | ||
| 35 | 35 | dir=$1; name=$2 |
| 36 | 36 | flags= |
| 37 | 37 | [ $dir = examples ] || [ $dir = test/libc ] && flags=-Werror |
| 38 | - if ! $raz $flags -I $dir/mods -o $out/$name $dir/$name.raz 2>$out/$name.cerr; then | |
| 39 | - echo "FAIL $dir/$name: doesn't compile: $(cat $out/$name.cerr)" | |
| 38 | + if ! $raz $flags $libc -I $dir/mods -o $out/$name $dir/$name.raz 2>$out/$name.cerr; then | |
| 39 | + echo "FAIL $dir/$name$libc: doesn't compile: $(cat $out/$name.cerr)" | |
| 40 | 40 | fail=$((fail + 1)); return |
| 41 | 41 | fi |
| 42 | 42 | if [ ! -f $dir/$name.expect ]; then pass=$((pass + 1)); return; fi |
| @@ -50,15 +50,15 @@ | ||
| 50 | 50 | want=0 |
| 51 | 51 | [ -f $dir/$name.status ] && want=$(cat $dir/$name.status) |
| 52 | 52 | if ! cmp -s $out/$name.out $dir/$name.expect; then |
| 53 | - echo "FAIL $dir/$name: output differs" | |
| 53 | + echo "FAIL $dir/$name$libc: output differs" | |
| 54 | 54 | diff $out/$name.out $dir/$name.expect | head -5 |
| 55 | 55 | fail=$((fail + 1)) |
| 56 | 56 | elif [ $status != $want ]; then |
| 57 | - echo "FAIL $dir/$name: status $status, not $want" | |
| 57 | + echo "FAIL $dir/$name$libc: status $status, not $want" | |
| 58 | 58 | fail=$((fail + 1)) |
| 59 | 59 | elif [ -f $dir/$name.stderr ] && ! sed 's/0x[0-9a-f]*/0x?/g' $out/$name.err | |
| 60 | 60 | cmp -s - $dir/$name.stderr; then |
| 61 | - echo "FAIL $dir/$name: standard error differs" | |
| 61 | + echo "FAIL $dir/$name$libc: standard error differs" | |
| 62 | 62 | diff $out/$name.err $dir/$name.stderr | head -5 |
| 63 | 63 | fail=$((fail + 1)) |
| 64 | 64 | else |
| @@ -66,9 +66,16 @@ | ||
| 66 | 66 | fi |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | +libc= | |
| 69 | 70 | for f in examples/*.raz test/run/*.raz test/libc/*.raz test/bench/*.raz; do |
| 70 | 71 | run $(dirname $f) $(basename $f .raz) |
| 71 | 72 | done |
| 73 | +# test/libc again over musl, where its loader is installed | |
| 74 | +if [ -e /lib/ld-musl-x86_64.so.1 ]; then | |
| 75 | + libc=' -libc musl' | |
| 76 | + for f in test/libc/*.raz; do run test/libc $(basename $f .raz); done | |
| 77 | + libc= | |
| 78 | +fi | |
| 72 | 79 | |
| 73 | 80 | # raz run: a static program and one over C, from memory, with their |
| 74 | 81 | # arguments, output and status passed through |
| @@ -1,5 +1,5 @@ | ||
| 1 | -lib/Sys.raz:16:8: error: module C is in test/err/mods/clash/C.raz and lib/C.raz | |
| 2 | - 16 | import C; | |
| 1 | +lib/Sys.raz:17:8: error: module C is in test/err/mods/clash/C.raz and lib/C.raz | |
| 2 | + 17 | import C; | |
| 3 | 3 | | ^ |
| 4 | 4 | help: a program has one module of each name; a symbolic link to one of these files chooses it |
| 5 | 5 | raz: 1 error |