On Wed, 19 Feb 2020 21:20:46 -0500 George Koehler <kern...@gmail.com> wrote:
> ... I fixed my macppc build by adding the line > *arg++ = "-latomic"; > after -lm in qjsc.c.... Bad news: my macppc qjsc needs /usr/ports/pobj/quickjs-2020.01.19/bin in PATH, so it works during the build, but not after the install. $ qjsc -o example example.js ... /usr/local/include/quickjs/quickjs.h:168: warning: ... ... /usr/bin/ld: cannot find -latomic collect2: ld returned 1 exit status When WRKDIR/bin is in the path, then qjsc works without any warnings from quick.js. (The linker gives the usual warnings for calling strcpy(), strcat(), sprintf() in libc.) Good news: the only failing test is on macppc is test_typed_array in test_builtin.js, and it only fails because it assumes little endian, but QuickJS uses big endian. (ES2019 allows both.) If I skip or modify the test, then all other tests pass. Also, the tests write WRKDIR/qjs.core on both amd64 and macppc, but this is only a side effect of a successful test to send SIGQUIT to a cat(1) process. My macppc wrote qjs.core and not cat.core, because the child never returned from fork(2). Here's what I changed from Brian's update diff. I added a CFLAGS line in the port Makefile: # Fix "undefined reference to `__atomic_store_8'" .if ${MACHINE_ARCH:Mpowerpc} || ${MACHINE_ARCH:Mhppa} WANTLIB += atomic CFLAGS += -DLINK_ATOMIC # for patch-qjsc_c MAKE_FLAGS += LDFLAGS="${LDFLAGS} -latomic" .endif I can't put CFLAGS in MAKE_FLAGS, because that would disable some "CFLAGS += ..." lines in WRKSRC/Makefile. Instead, I rely on MAKE_ENV to forward CFLAGS. I edited the chunk in patch-qjsc_c: @@ -446,7 +446,9 @@ static int output_executable(const char *out_filename, lib_dir, bn_suffix, lto_suffix); *arg++ = libjsname; *arg++ = "-lm"; - *arg++ = "-ldl"; +#ifdef LINK_ATOMIC + *arg++ = "-latomic"; +#endif *arg = NULL; if (verbose) { I added a chunk to patch-tests_test_builtin_js: @@ -410,7 +410,10 @@ function test_typed_array() a = new Uint8Array(buffer); - assert(a.toString(), "0,0,255,255,0,0,0,0,0,0,128,63,255,255,255,255"); + if (a[8] == 63) // big endian? + assert(a.toString(), "0,0,255,255,0,0,0,0,63,128,0,0,255,255,255,255"); + else + assert(a.toString(), "0,0,255,255,0,0,0,0,0,0,128,63,255,255,255,255"); assert(a.buffer, buffer);