On Fri, 21 Feb 2020 00:48:36 -0500
George Koehler <kern...@gmail.com> wrote:

> 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.

I almost fixed it by adding at the bottom of the port Makefile,
after bsd.port.mk sets CHOSEN_COMPILER,

.if ${CHOSEN_COMPILER} == "ports-gcc"
CC =            egcc
RUN_DEPENDS +=  ${MODGCC4_CPPLIBDEP:S/,-libs//}
.endif

This fixes qjsc at runtime on macppc, but it is _wrong_ because
RUN_DEPENDS gets ignored, so "pkg_info -S quickjs" is missing the
dependency on ports-gcc.  I guess that after bsd.port.mk sets
CHOSEN_COMPILER, it is too late to set RUN_DEPENDS.

qjsc works like this:

$ cat example.js                                                       
import {printf} from "std";
printf("2 + 3 = %d\n", 2 + 3);
$ qjsc -o example example.js
... (linker warnings)
$ ./example
2 + 3 = 5

The diff below is Brian's update plus all of my local changes
(including the wrong RUN_DEPENDS), as I was copying them from my
macppc to my amd64.  (My patch-quickjs_h was empty because I forgot
to remove it.)

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/quickjs/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- Makefile    15 Jan 2020 14:30:50 -0000      1.4
+++ Makefile    21 Feb 2020 17:29:36 -0000
@@ -2,8 +2,7 @@
 
 COMMENT =      small, embeddable JavaScript engine in C
 
-V =            2019.10.27
-REVISION =     0
+V =            2020.01.19
 DISTNAME =     quickjs-${V:S/./-/g}
 PKGNAME =      quickjs-${V}
 
@@ -29,7 +28,13 @@ MAKE_FLAGS = CC="${CC}"
 # 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
 
 .include <bsd.port.mk>
+
+.if ${CHOSEN_COMPILER} == "ports-gcc"
+CC =           egcc
+RUN_DEPENDS += ${MODGCC4_CPPLIBDEP:S/,-libs//}
+.endif
Index: distinfo
===================================================================
RCS file: /cvs/ports/lang/quickjs/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo    21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ distinfo    21 Feb 2020 17:29:36 -0000
@@ -1,2 +1,2 @@
-SHA256 (quickjs-2019-10-27.tar.xz) = 
Uc3KTreFHS64so1ELfqjYhOSAXGgzw68BGgCNpQ0oXY=
-SIZE (quickjs-2019-10-27.tar.xz) = 763012
+SHA256 (quickjs-2020-01-19.tar.xz) = 
SuTCDE7XwgHXLCKNXodoMUlQkUumDXWfPfI9WQN/K4U=
+SIZE (quickjs-2020-01-19.tar.xz) = 735868
Index: patches/patch-Makefile
===================================================================
RCS file: /cvs/ports/lang/quickjs/patches/patch-Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-Makefile
--- patches/patch-Makefile      21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ patches/patch-Makefile      21 Feb 2020 17:29:36 -0000
@@ -23,7 +23,7 @@ Index: Makefile
  
  ifdef CONFIG_DARWIN
  # use clang instead of gcc
-@@ -81,8 +82,8 @@ ifdef CONFIG_CLANG
+@@ -83,8 +84,8 @@ ifdef CONFIG_CLANG
  else
    HOST_CC=gcc
    CC=$(CROSS_PREFIX)gcc
@@ -34,7 +34,7 @@ Index: Makefile
    ifdef CONFIG_LTO
      AR=$(CROSS_PREFIX)gcc-ar
    else
-@@ -97,7 +98,7 @@ DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat 
+@@ -102,7 +103,7 @@ endif
  CFLAGS+=$(DEFINES)
  CFLAGS_DEBUG=$(CFLAGS) -O0
  CFLAGS_SMALL=$(CFLAGS) -Os
@@ -43,7 +43,7 @@ Index: Makefile
  CFLAGS_NOLTO:=$(CFLAGS_OPT)
  LDFLAGS=-g
  ifdef CONFIG_LTO
-@@ -165,7 +166,7 @@ QJSBN_OBJS=$(OBJDIR)/qjs.bn.o $(OBJDIR)/repl-bn.bn.o $
+@@ -168,7 +169,7 @@ endif
  
  LIBS=-lm
  ifndef CONFIG_WIN32
Index: patches/patch-qjsc_c
===================================================================
RCS file: /cvs/ports/lang/quickjs/patches/patch-qjsc_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-qjsc_c
--- patches/patch-qjsc_c        21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ patches/patch-qjsc_c        21 Feb 2020 17:29:36 -0000
@@ -2,14 +2,19 @@ $OpenBSD: patch-qjsc_c,v 1.1.1.1 2019/12
 
 Remove -ldl
 
+Add -latomic if the ports Makefile passes -DLINK_ATOMIC
+
 Index: qjsc.c
 --- qjsc.c.orig
 +++ qjsc.c
-@@ -450,7 +450,6 @@ static int output_executable(const char *out_filename,
+@@ -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) {
Index: patches/patch-quickjs_c
===================================================================
RCS file: /cvs/ports/lang/quickjs/patches/patch-quickjs_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-quickjs_c
--- patches/patch-quickjs_c     21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ patches/patch-quickjs_c     21 Feb 2020 17:29:36 -0000
@@ -3,7 +3,7 @@ $OpenBSD: patch-quickjs_c,v 1.1.1.1 2019
 Index: quickjs.c
 --- quickjs.c.orig
 +++ quickjs.c
-@@ -1349,7 +1349,7 @@ static inline size_t js_def_malloc_usable_size(void *p
+@@ -1550,7 +1550,7 @@ static inline size_t js_def_malloc_usable_size(void *p
      return malloc_usable_size(ptr);
  #else
      /* change this to `return 0;` if compilation fails */
@@ -12,7 +12,7 @@ Index: quickjs.c
  #endif
  }
  
-@@ -1423,7 +1423,7 @@ static const JSMallocFunctions def_malloc_funcs = {
+@@ -1624,7 +1624,7 @@ static const JSMallocFunctions def_malloc_funcs = {
      (size_t (*)(const void *))malloc_usable_size,
  #else
      /* change this to `NULL,` if compilation fails */
Index: patches/patch-quickjs_h
===================================================================
RCS file: /cvs/ports/lang/quickjs/patches/patch-quickjs_h,v
retrieving revision 1.1
diff -u -p -r1.1 patch-quickjs_h
--- patches/patch-quickjs_h     15 Jan 2020 14:30:50 -0000      1.1
+++ patches/patch-quickjs_h     21 Feb 2020 17:29:36 -0000
@@ -1,16 +0,0 @@
-$OpenBSD: patch-quickjs_h,v 1.1 2020/01/15 14:30:50 jca Exp $
-
-Use more generic test for 64 bits platform.
-
-Index: quickjs.h
---- quickjs.h.orig
-+++ quickjs.h
-@@ -53,7 +53,7 @@ typedef struct JSClass JSClass;
- typedef uint32_t JSClassID;
- typedef uint32_t JSAtom;
- 
--#if defined(__x86_64__) || defined(__aarch64__)
-+#if defined(__LP64__)
- #define JS_PTR64
- #define JS_PTR64_DEF(a) a
- #else
Index: patches/patch-tests_test_builtin_js
===================================================================
RCS file: /cvs/ports/lang/quickjs/patches/patch-tests_test_builtin_js,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-tests_test_builtin_js
--- patches/patch-tests_test_builtin_js 21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ patches/patch-tests_test_builtin_js 21 Feb 2020 17:29:36 -0000
@@ -3,12 +3,14 @@ $OpenBSD: patch-tests_test_builtin_js,v 
 Disable tests that fail on OpenBSD.
 More info: 
https://github.com/NetBSD/pkgsrc/blob/trunk/lang/quickjs/patches/patch-tests_test__builtin.js
 
+Fix a test on big-endian platforms.
+
 Index: tests/test_builtin.js
 --- tests/test_builtin.js.orig
 +++ tests/test_builtin.js
-@@ -304,12 +304,12 @@ function test_number()
-     assert(parseFloat("123.2"), 123.2);
-     assert(parseFloat("123.2e3"), 123200);
+@@ -307,12 +307,12 @@ function test_number()
+     assert(Number.isNaN(Number("-")));
+     assert(Number.isNaN(Number("\x00a")));
  
 -    assert((25).toExponential(0), "3e+1");
 -    assert((-25).toExponential(0), "-3e+1");
@@ -25,3 +27,15 @@ Index: tests/test_builtin.js
  }
  
  function test_eval2()
+@@ -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);
+ 
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/lang/quickjs/pkg/PLIST,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 PLIST
--- pkg/PLIST   21 Dec 2019 14:24:03 -0000      1.1.1.1
+++ pkg/PLIST   21 Feb 2020 17:29:36 -0000
@@ -1,7 +1,5 @@
 @comment $OpenBSD: PLIST,v 1.1.1.1 2019/12/21 14:24:03 bcallah Exp $
 @bin bin/qjs
-@bin bin/qjsbn
-@bin bin/qjsbnc
 @bin bin/qjsc
 bin/qjscalc
 include/quickjs/
@@ -9,4 +7,3 @@ include/quickjs/quickjs-libc.h
 include/quickjs/quickjs.h
 lib/quickjs/
 @static-lib lib/quickjs/libquickjs.a
-@static-lib lib/quickjs/libquickjs.bn.a

Reply via email to