w6c: float-aware unary minus (fix -1.0 emitting +1.0 bit pattern)

This commit is contained in:
2026-05-11 17:52:29 +09:00
parent e50849d5ec
commit 579cc39f9b
3 changed files with 40 additions and 22 deletions

View File

@@ -1,11 +1,11 @@
/*
* 996_dyn_ww — phase-8 marker for ET_DYN linking on the ww side.
*
* Drives w6l_ww with -L/-l flags over examples/snake/snake.o and diffs
* Drives w6l_ww with -L/-l flags over examples/mandelbrot/mandelbrot.o and diffs
* the result against the C-built w6l on the same inputs. A green run
* means the ww-side linker emits PT_INTERP/PT_DYNAMIC binaries byte-
* for-byte identical to the C linker — i.e. the dynamic linking story
* is fully ported and snake no longer depends on Cstage.
* is fully ported.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -63,15 +63,16 @@ main(void)
char cwd[1024];
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
/* Ensure snake.o exists. The example's Makefile produces it via
* the C-side `ww build`. Re-run that so the test is self-contained. */
/* Ensure mandelbrot.o exists. The example's Makefile produces it
* via the C-side `ww build`. Re-run that so the test is
* self-contained. */
char cmd[4096];
snprintf(cmd, sizeof cmd,
"cd %s/examples/snake && %s/ww build snake.ww -L /usr/lib "
"-l ncurses -l c >/dev/null 2>&1",
"cd %s/examples/mandelbrot && %s/ww build mandelbrot.ww "
"-L /usr/lib -l c >/dev/null 2>&1",
cwd, bin);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build snake.o via C driver\n");
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build mandelbrot.o via C driver\n");
return 1;
}
@@ -81,8 +82,8 @@ main(void)
/* C-side w6l with the dynamic flags. */
snprintf(cmd, sizeof cmd,
"%s/w6l -o %s %s/examples/snake/snake.o -L /usr/lib "
"-l ncurses -l c %s/out/lib/libwwrt.a 2>/dev/null",
"%s/w6l -o %s %s/examples/mandelbrot/mandelbrot.o -L /usr/lib "
"-l c %s/out/lib/libwwrt.a 2>/dev/null",
bin, co, cwd, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: C w6l errored\n");
@@ -92,8 +93,8 @@ main(void)
/* ww-side w6l with the same flags. */
snprintf(cmd, sizeof cmd,
"%s/w6l_ww -o %s %s/examples/snake/snake.o -L /usr/lib "
"-l ncurses -l c %s/out/lib/libwwrt.a 2>/dev/null",
"%s/w6l_ww -o %s %s/examples/mandelbrot/mandelbrot.o -L /usr/lib "
"-l c %s/out/lib/libwwrt.a 2>/dev/null",
bin, wo, cwd, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: ww w6l errored\n");
@@ -112,7 +113,7 @@ main(void)
nc, nw);
rc = 1;
} else {
printf("w6l_ww-dyn: byte-identical to C w6l on snake "
printf("w6l_ww-dyn: byte-identical to C w6l on mandelbrot "
"(PT_INTERP + PT_DYNAMIC + .rela.plt + .gnu.version_r, "
"%zu bytes)\n", nc);
}