On Fri, 21 Feb 2020 12:53:20 -0500
George Koehler <kern...@gmail.com> wrote:

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

Someone pointed me at how devel/llvm uses bsd.arch.port.mk and
PROPERTIES.  I fixed lang/quickjs/Makefile to be almost the same; see
the chunk after MAKE_FLAGS in the diff below.  "pkg_info -S quickjs"
now includes @gcc-8.3.0p4 on macppc and omits gcc on amd64, as I want.

This version of the diff is ok gkoehler@

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 20:23:51 -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}
 
@@ -26,9 +25,19 @@ COMPILER =   base-clang ports-gcc
 USE_GMAKE =    Yes
 MAKE_FLAGS =   CC="${CC}"
 
+.include <bsd.port.arch.mk>
+
+# Tell qjsc to run ports-gcc
+.if !${PROPERTIES:Mclang}
+CC =           egcc
+RUN_DEPENDS =  lang/gcc/${MODGCC4_VERSION}
+.endif
+
 # Fix "undefined reference to `__atomic_store_8'"
+# Pass -DLINK_ATOMIC to patch_qjsc_c
 .if ${MACHINE_ARCH:Mpowerpc} || ${MACHINE_ARCH:Mhppa}
 WANTLIB +=     atomic
+CFLAGS +=      -DLINK_ATOMIC
 MAKE_FLAGS +=  LDFLAGS="${LDFLAGS} -latomic"
 .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 20:23:51 -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 20:23:51 -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 20:23:51 -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 20:23:51 -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 20:23:51 -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 20:23:51 -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 20:23:51 -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