bellard / quickjs

Public repository of the QuickJS Javascript Engine.
https://bellard.org/quickjs
Other
8.34k stars 867 forks source link

Some 32-bit archs require explicit liking to `libatomic`, otherwise build fails: Undefined symbols: "___atomic_compare_exchange_8", "___atomic_fetch_xor_8" etc. #321

Open barracuda156 opened 3 months ago

barracuda156 commented 3 months ago
/opt/local/bin/gcc-mp-13 -g -o run-test262 .obj/run-test262.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lm -ldl -lpthread 
ar rcs libquickjs.a .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o
Undefined symbols:
  "___atomic_compare_exchange_8", referenced from:
Undefined symbols:
  "___atomic_compare_exchange_8", referenced from:
      _js_atomics_op in quickjs.o
      _js_atomics_op in quickjs.o
  "___atomic_fetch_xor_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_fetch_xor_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_fetch_add_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_fetch_add_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_load_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_load_8", referenced from:
  "___atomic_store_8", referenced from:
      _js_atomics_op in quickjs.o
      _js_atomics_store in quickjs.o
  "___atomic_fetch_sub_8", referenced from:
  "___atomic_store_8", referenced from:
      _js_atomics_op in quickjs.o
      _js_atomics_store in quickjs.o
  "_clock_gettime", referenced from:
  "___atomic_fetch_sub_8", referenced from:
      _js_atomics_wait in quickjs.o
      _js_atomics_op in quickjs.o
      _js_os_setTimeout in quickjs-libc.o
      _js_os_poll in quickjs-libc.o
  "___atomic_fetch_or_8", referenced from:
      _js_atomics_op in quickjs.o
  "_clock_gettime", referenced from:
      _js_agent_monotonicNow in run-test262.o
      _run_test_dir_list in run-test262.o
      _run_test_dir_list in run-test262.o
      _js_atomics_wait in quickjs.o
  "___atomic_fetch_and_8", referenced from:
      _js_os_setTimeout in quickjs-libc.o
      _js_os_poll in quickjs-libc.o
      _js_atomics_op in quickjs.o
  "___atomic_fetch_or_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_exchange_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_fetch_and_8", referenced from:
      _js_atomics_op in quickjs.o
  "___atomic_exchange_8", referenced from:
      _js_atomics_op in quickjs.o
ld: symbol(s) not found
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
make: *** [run-test262] Error 1
make: *** Waiting for unfinished jobs....
barracuda156 commented 3 months ago

@bellard I give up on this, makefile is designed in such a way that whichever attempts to link to the needed libs fail. We need a) libatomic with 32-bit archs and GCC and b) MacportsLegacySupport (for _clock_gettime). Normally simply passing -latomic to the linker via ldflags and the same for -lMacportsLegacySupport works perfectly fine.

It does not here.

--->  Building quickjs
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-b5e62895c619d4ffc75c9d822c8d85f1ece77e5b" && /usr/bin/make -j6 -w all 
make: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-b5e62895c619d4ffc75c9d822c8d85f1ece77e5b'
mkdir -p .obj .obj/examples .obj/tests
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/quickjs.check.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CHECK_JSVALUE -c -o .obj/quickjs.check.o quickjs.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/qjs.check.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CHECK_JSVALUE -c -o .obj/qjs.check.o qjs.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/qjs.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/qjs.o qjs.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/qjsc.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CC=\"/opt/local/bin/gcc-mp-13\" -DCONFIG_PREFIX=\"/opt/local\" -O2 -c -o .obj/qjsc.o qjsc.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/quickjs.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/quickjs.o quickjs.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/libregexp.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libregexp.o libregexp.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/libunicode.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libunicode.o libunicode.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/cutils.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/cutils.o cutils.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/quickjs-libc.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/quickjs-libc.o quickjs-libc.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/libbf.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libbf.o libbf.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/run-test262.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/run-test262.o run-test262.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/fib.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/examples/fib.o examples/fib.c
In function 'js_def_malloc_usable_size',
    inlined from 'js_def_malloc' at quickjs.c:1708:23:
quickjs.c:1680:12: warning: 'ptr' may be used uninitialized [-Wmaybe-uninitialized]
 1680 |     return malloc_size(ptr);
      |            ^~~~~~~~~~~~~~~~
In file included from quickjs.c:36:
/usr/include/malloc/malloc.h: In function 'js_def_malloc':
/usr/include/malloc/malloc.h:90:15: note: by argument 1 of type 'const void *' to 'malloc_size' declared here
   90 | extern size_t malloc_size(const void *ptr);
      |               ^~~~~~~~~~~
/opt/local/bin/gcc-mp-13 -g -o qjsc .obj/qjsc.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lMacportsLegacySupport -lm -ldl -lpthread -latomic
/opt/local/bin/gcc-mp-13 -g -o run-test262 .obj/run-test262.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lMacportsLegacySupport -lm -ldl -lpthread -latomic
ar rcs libquickjs.a .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o
./qjsc -c -o repl.c -m repl.js
./qjsc -fbignum -c -o qjscalc.c qjscalc.js
./qjsc -e -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -fno-module-loader -fno-bigint -o hello.c examples/hello.js
./qjsc -e -M examples/fib.so,fib -m -o test_fib.c examples/test_fib.js
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/hello.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/hello.o hello.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/repl.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/repl.o repl.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/qjscalc.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/qjscalc.o qjscalc.c
/opt/local/bin/gcc-mp-13 -I/opt/local/include/LegacySupport -Wl,-lMacportsLegacySupport -g -Wall -MMD -MF .obj/test_fib.o.d -Wno-array-bounds -Wno-format-truncation -Wl,-latomic -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/test_fib.o test_fib.c
./qjsc -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -m -o examples/hello_module examples/hello_module.js
/opt/local/bin/gcc-mp-13 -g -o examples/hello .obj/hello.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lMacportsLegacySupport -lm -ldl -lpthread -latomic
/opt/local/bin/gcc-mp-13 -g -o examples/test_fib .obj/test_fib.o .obj/examples/fib.o libquickjs.a -lMacportsLegacySupport -lm -ldl -lpthread -latomic
/opt/local/bin/gcc-mp-13 -g  -o qjs .obj/qjs.o .obj/repl.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o .obj/qjscalc.o -lMacportsLegacySupport -lm -ldl -lpthread -latomic
Undefined symbols:
  "___atomic_compare_exchange_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_fetch_xor_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_fetch_add_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_load_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_store_8", referenced from:
      _js_atomics_store in libquickjs.a(quickjs.o)
  "___atomic_fetch_sub_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "_clock_gettime", referenced from:
      _js_atomics_wait in libquickjs.a(quickjs.o)
      _js_os_setTimeout in libquickjs.a(quickjs-libc.o)
      _js_os_poll in libquickjs.a(quickjs-libc.o)
  "___atomic_fetch_or_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_fetch_and_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
  "___atomic_exchange_8", referenced from:
      _js_atomics_op in libquickjs.a(quickjs.o)
ld: symbol(s) not found
collect2: error: ld returned 1 exit status

I tried various ways, everything fails here. Could you help?

andrjohns commented 3 months ago

Use the EXTRA_LIBS environment variable to add libraries:

EXTRA_LIBS="-latomic" make qjs
barracuda156 commented 3 months ago

@andrjohns I am sure I tried that, but I will try again and share a log if it fails.

barracuda156 commented 3 months ago

@andrjohns It still fails. I tried to keep changes to the minimum, so only fixed the compiler choice, since makefile forces clang or no-name gcc (which picks the wrong one), and this build had LTO enabled (which is useless on ppc, AFAIK, but compiling with it should work).

:notice:build --->  Building quickjs
:debug:build Executing org.macports.build (quickjs)
:debug:build Environment: 
:debug:build CC_PRINT_OPTIONS='YES'
:debug:build CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/.CC_PRINT_OPTIONS'
:debug:build CPATH='/opt/local/include'
:debug:build CPLUS_INCLUDE_PATH='/opt/local/include/LegacySupport'
:debug:build C_INCLUDE_PATH='/opt/local/include/LegacySupport'
:debug:build DEVELOPER_DIR='/Developer'
:debug:build LIBRARY_PATH='/opt/local/lib'
:debug:build MACOSX_DEPLOYMENT_TARGET='10.6'
:debug:build MACPORTS_LEGACY_SUPPORT_CPPFLAGS='-isystem/opt/local/include/LegacySupport'
:debug:build MACPORTS_LEGACY_SUPPORT_ENABLED='1'
:debug:build MACPORTS_LEGACY_SUPPORT_LDFLAGS='-L/opt/local/lib -lMacportsLegacySupport'
:debug:build OBJCPLUS_INCLUDE_PATH='/opt/local/include/LegacySupport'
:debug:build OBJC_INCLUDE_PATH='/opt/local/include/LegacySupport'
:info:build Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-b5e62895c619d4ffc75c9d822c8d85f1ece77e5b" && EXTRA_LIBS="-latomic -lMacportsLegacySupport" /usr/bin/make all 
:debug:build system:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-b5e62895c619d4ffc75c9d822c8d85f1ece77e5b" && EXTRA_LIBS="-latomic -lMacportsLegacySupport" /usr/bin/make all 
:info:build mkdir -p .obj .obj/examples .obj/tests
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/quickjs.check.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CHECK_JSVALUE -c -o .obj/quickjs.check.o quickjs.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/qjs.check.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CHECK_JSVALUE -c -o .obj/qjs.check.o qjs.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/qjs.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/qjs.o qjs.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/qjsc.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -DCONFIG_CC=\"/opt/local/bin/gcc-mp-13\" -DCONFIG_PREFIX=\"/usr/local\" -DCONFIG_LTO -O2 -flto -c -o .obj/qjsc.o qjsc.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/quickjs.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/quickjs.o quickjs.c
:info:build In function 'js_def_malloc_usable_size',
:info:build     inlined from 'js_def_malloc' at quickjs.c:1708:23:
:info:build quickjs.c:1680:12: warning: 'ptr_20' may be used uninitialized [-Wmaybe-uninitialized]
:info:build  1680 |     return malloc_size(ptr);
:info:build       |            ^~~~~~~~~~~~~~~~
:info:build In file included from quickjs.c:36:
:info:build /usr/include/malloc/malloc.h: In function 'js_def_malloc':
:info:build /usr/include/malloc/malloc.h:90:15: note: by argument 1 of type 'const void *' to 'malloc_size' declared here
:info:build    90 | extern size_t malloc_size(const void *ptr);
:info:build       |               ^~~~~~~~~~~
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/libregexp.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/libregexp.o libregexp.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/libunicode.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/libunicode.o libunicode.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/cutils.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/cutils.o cutils.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/quickjs-libc.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/quickjs-libc.o quickjs-libc.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/libbf.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/libbf.o libbf.c
:info:build /opt/local/bin/gcc-mp-13 -g -flto -o qjsc .obj/qjsc.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lm -ldl -lpthread -latomic -lMacportsLegacySupport
:info:build lto-wrapper: warning: using serial compilation of 17 LTRANS jobs
:info:build lto-wrapper: note: see the '-flto' option documentation for more information
:info:build ./qjsc -c -o repl.c -m repl.js
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/repl.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/repl.o repl.c
:info:build ./qjsc -fbignum -c -o qjscalc.c qjscalc.js
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/qjscalc.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/qjscalc.o qjscalc.c
:info:build /opt/local/bin/gcc-mp-13 -g -flto -rdynamic -o qjs .obj/qjs.o .obj/repl.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o .obj/qjscalc.o -lm -ldl -lpthread -latomic -lMacportsLegacySupport
:info:build gcc-mp-13: note: rdynamic is not supported
:info:build lto-wrapper: warning: using serial compilation of 17 LTRANS jobs
:info:build lto-wrapper: note: see the '-flto' option documentation for more information
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/run-test262.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/run-test262.o run-test262.c
:info:build /opt/local/bin/gcc-mp-13 -g -flto -o run-test262 .obj/run-test262.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lm -ldl -lpthread -latomic -lMacportsLegacySupport
:info:build lto-wrapper: warning: using serial compilation of 17 LTRANS jobs
:info:build lto-wrapper: note: see the '-flto' option documentation for more information
:info:build ln -sf qjs qjscalc
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/quickjs.nolto.o quickjs.c
:info:build In function 'js_def_malloc_usable_size',
:info:build     inlined from 'js_def_malloc' at quickjs.c:1708:23:
:info:build quickjs.c:1680:12: warning: 'ptr' may be used uninitialized [-Wmaybe-uninitialized]
:info:build  1680 |     return malloc_size(ptr);
:info:build       |            ^~~~~~~~~~~~~~~~
:info:build In file included from quickjs.c:36:
:info:build /usr/include/malloc/malloc.h: In function 'js_def_malloc':
:info:build /usr/include/malloc/malloc.h:90:15: note: by argument 1 of type 'const void *' to 'malloc_size' declared here
:info:build    90 | extern size_t malloc_size(const void *ptr);
:info:build       |               ^~~~~~~~~~~
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libregexp.nolto.o libregexp.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libunicode.nolto.o libunicode.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/cutils.nolto.o cutils.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/quickjs-libc.nolto.o quickjs-libc.c
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -c -o .obj/libbf.nolto.o libbf.c
:info:build /opt/local/bin/gcc-ar-mp-13 rcs libquickjs.a .obj/quickjs.nolto.o .obj/libregexp.nolto.o .obj/libunicode.nolto.o .obj/cutils.nolto.o .obj/quickjs-libc.nolto.o .obj/libbf.nolto.o
:info:build /opt/local/bin/gcc-ar-mp-13 rcs libquickjs.lto.a .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o
:info:build ./qjsc -e -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -fno-module-loader -fno-bigint -o hello.c examples/hello.js
:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/hello.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/hello.o hello.c
:info:build /opt/local/bin/gcc-mp-13 -g -flto -o examples/hello .obj/hello.o .obj/quickjs.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o .obj/libbf.o -lm -ldl -lpthread -latomic -lMacportsLegacySupport
:info:build lto-wrapper: warning: using serial compilation of 16 LTRANS jobs
:info:build lto-wrapper: note: see the '-flto' option documentation for more information
:info:build ./qjsc -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -m -o examples/hello_module examples/hello_module.js
:info:build Undefined symbols:
:info:build   "___atomic_compare_exchange_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_fetch_xor_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_fetch_add_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_load_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_store_8", referenced from:
:info:build       _js_atomics_store in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_fetch_sub_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "_clock_gettime", referenced from:
:info:build       _js_atomics_wait in libquickjs.lto.a(quickjs.o)
:info:build       _js_os_setTimeout in libquickjs.lto.a(quickjs-libc.o)
:info:build       _js_os_poll in libquickjs.lto.a(quickjs-libc.o)
:info:build   "___atomic_fetch_or_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_fetch_and_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build   "___atomic_exchange_8", referenced from:
:info:build       _js_atomics_op in libquickjs.lto.a(quickjs.o)
:info:build ld: symbol(s) not found
:info:build collect2: error: ld returned 1 exit status
:info:build make: *** [examples/hello_module] Error 1

Flags are passed, linking does not work.

My earlier attempts were without LTO and flags added via patching makefile – but anyway, result is the same, neither works.

andrjohns commented 3 months ago

Don't run make all if it causes issues, just build the targets you need (e.g. libquickjs.a qjs qjsc)

saghul commented 3 months ago

In case it helps you may want to give the friendly fork a try: https://github.com/quickjs-ng/quickjs we switched the buildsystem to CMake, which should take care of this problem automagically.

barracuda156 commented 3 months ago

@saghul CMake should work, yeah. There was can even add a proper test for libatomic requirement so that no more manual patching will be needed.

barracuda156 commented 3 months ago

@saghul Builds nicely with CMake, the only minor error being:

In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:43:
In function 'js__malloc_usable_size',
    inlined from 'js_def_malloc' at /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:1706:23:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.h:481:12: error: 'ptr' may be used uninitialized [-Werror=maybe-uninitialized]

So passing -Wno-maybe-uninitialized to cflags and needed linker flags, build works.

barracuda156 commented 3 months ago

It does not seem to have a proper test target, but running manually it seems to do something :) Not sure what to make of this table:

36-25% /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/test_conv 
      variant     u32toa       i32toa       u64toa       i64toa
     snprintf   307.98ns     338.28ns     1248.06ns     1276.19ns  
     blockmov    82.86ns      88.16ns     745.20ns     754.17ns  
      reverse    87.09ns      96.48ns     746.62ns     754.25ns  
  length_expr    84.08ns      91.77ns     749.64ns     757.23ns  
  length_loop    81.50ns      88.84ns     747.59ns     755.94ns  
        shift    84.64ns      91.45ns     236.14ns     241.80ns  
   pair_1pass    46.34ns      54.31ns     130.59ns     139.66ns  
  variant rx  u32toa_radix i32toa_radix u64toa_radix i64toa_radix
 snprintf avg   298.91ns     320.70ns     641.18ns     664.15ns  
  reverse avg    96.74ns     103.83ns     725.15ns     731.69ns  
div_table avg    53.24ns      61.83ns     116.81ns     125.83ns  
   length avg    69.54ns      77.16ns     593.87ns     601.41ns  
 dispatch avg   267.88ns     274.20ns     661.64ns     668.31ns
saghul commented 3 months ago

There is a Makefile with a make test target. Also the 262 suite.

saghul commented 3 months ago

@saghul Builds nicely with CMake, the only minor error being:

In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:43:
In function 'js__malloc_usable_size',
    inlined from 'js_def_malloc' at /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:1706:23:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.h:481:12: error: 'ptr' may be used uninitialized [-Werror=maybe-uninitialized]

So passing -Wno-maybe-uninitialized to cflags and needed linker flags, build works.

What compiler flags are you using? Thar looks like a false positive. Here is the offending function:

static void *js_def_malloc(JSMallocState *s, size_t size)
{
    void *ptr;

    /* Do not allocate zero bytes: behavior is platform dependent */
    assert(size != 0);

    /* When malloc_limit is 0 (unlimited), malloc_limit - 1 will be SIZE_MAX. */
    if (unlikely(s->malloc_size + size > s->malloc_limit - 1))
        return NULL;

    ptr = malloc(size);
    if (!ptr)
        return NULL;

    s->malloc_count++;
    s->malloc_size += js__malloc_usable_size(ptr) + MALLOC_OVERHEAD;
    return ptr;
}

ptr is initialized.

barracuda156 commented 3 months ago

@saghul Maybe header for malloc not included? (On mobile now, can’t check.)

I did not add any special flags. -Werror added from quickjs side, MacPorts passes standard flags like build arch, -Os and deployment target.

saghul commented 3 months ago

Should be there. Can you please the compiler version and the verbose build output please?

andrjohns commented 3 months ago

@barracuda156 you had a similar warning in your earlier logs:

:info:build /opt/local/bin/gcc-mp-13 -g -Wall -MMD -MF .obj/quickjs.o.d -Wno-array-bounds -Wno-format-truncation -D_GNU_SOURCE -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -O2 -flto -c -o .obj/quickjs.o quickjs.c
:info:build In function 'js_def_malloc_usable_size',
:info:build     inlined from 'js_def_malloc' at quickjs.c:1708:23:
:info:build quickjs.c:1680:12: warning: 'ptr_20' may be used uninitialized [-Wmaybe-uninitialized]
:info:build  1680 |     return malloc_size(ptr);
:info:build       |            ^~~~~~~~~~~~~~~~
:info:build In file included from quickjs.c:36:
:info:build /usr/include/malloc/malloc.h: In function 'js_def_malloc':
:info:build /usr/include/malloc/malloc.h:90:15: note: by argument 1 of type 'const void *' to 'malloc_size' declared here
:info:build    90 | extern size_t malloc_size(const void *ptr);
:info:build       |               ^~~~~~~~~~~

It looks like while your compiler is in /opt/local/bin/, the toolchain headers are being included from /usr/include instead

barracuda156 commented 3 months ago

@andrjohns Thank you, I will check that. It should certainly not happen, but if CMakeLists override flags which MacPorts pass, that will cause trouble (and perhaps should be fixed generally, it is a wrong behavior).

barracuda156 commented 3 months ago

@saghul What are the plans by the way, merge two forks back or keep separate? Since the original repo is still maintained, I cannot perhaps switch the port to another one. If the projects are to be considered co-existing, I can make a new port and declare a conflict, so a user can choose which version he prefers.

chqrlie commented 3 months ago

It does not seem to have a proper test target, but running manually it seems to do something :) Not sure what to make of this table:

36-25% /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/test_conv 
      variant     u32toa       i32toa       u64toa       i64toa
     snprintf   307.98ns     338.28ns     1248.06ns     1276.19ns  
     blockmov    82.86ns      88.16ns     745.20ns     754.17ns  
      reverse    87.09ns      96.48ns     746.62ns     754.25ns  
  length_expr    84.08ns      91.77ns     749.64ns     757.23ns  
  length_loop    81.50ns      88.84ns     747.59ns     755.94ns  
        shift    84.64ns      91.45ns     236.14ns     241.80ns  
   pair_1pass    46.34ns      54.31ns     130.59ns     139.66ns  
  variant rx  u32toa_radix i32toa_radix u64toa_radix i64toa_radix
 snprintf avg   298.91ns     320.70ns     641.18ns     664.15ns  
  reverse avg    96.74ns     103.83ns     725.15ns     731.69ns  
div_table avg    53.24ns      61.83ns     116.81ns     125.83ns  
   length avg    69.54ns      77.16ns     593.87ns     601.41ns  
 dispatch avg   267.88ns     274.20ns     661.64ns     668.31ns

test_conv is a utility to benchmark various methods to convert integers to strings. It should not be built by default, only for benchmarking purposes. Adding a CI target for various architectures would be useful to check that the method used in quickjs is among the most efficient. The current methods are shift for base 10 and length for radix conversions. pair_1pass and div_table use more memory.

The output you posted is disturbing. What machine did ou use? I get much faster timings on macOS with my Macbook Air, even running on battery:

      variant     u32toa       i32toa       u64toa       i64toa
     snprintf    62.14ns      67.53ns      72.44ns      80.70ns
        naive    11.23ns      13.05ns      20.25ns      22.14ns
     blockmov     9.27ns      10.81ns      15.00ns      16.50ns
      reverse     9.33ns      11.22ns      17.41ns      18.73ns
  length_expr     9.11ns      10.95ns      14.58ns      17.03ns
  length_loop     9.69ns      11.84ns      15.17ns      17.55ns
        shift     7.58ns      10.14ns      13.38ns      16.89ns
         pair     6.45ns      10.20ns      12.39ns      16.62ns
   pair_1pass     5.30ns      11.55ns       8.33ns      14.14ns
  variant rx  u32toa_radix i32toa_radix u64toa_radix i64toa_radix
 snprintf avg    60.61ns      68.04ns      69.19ns      76.00ns
    naive avg    16.30ns      18.46ns      26.78ns      26.18ns
  reverse avg    11.87ns      14.54ns      25.58ns      26.03ns
div_table avg    14.34ns      18.05ns      19.82ns      23.08ns
   length avg    10.61ns      14.70ns      18.51ns      21.53ns
 dispatch avg     9.39ns      13.28ns      16.80ns      19.18ns
chqrlie commented 3 months ago

@saghul What are the plans by the way, merge two forks back or keep separate? Since the original repo is still maintained, I cannot perhaps switch the port to another one. If the projects are to be considered co-existing, I can make a new port and declare a conflict, so a user can choose which version he prefers.

@barracuda156: The plan is to merge both forks sometime later this year. I am maintaining the original repository and also contribute to the ng fork. I have been slow to backport many patches because of business related duties, but I have set aside most of July and August to catch up on this goal.

barracuda156 commented 3 months ago

The output you posted is disturbing. What machine did ou use? I get much faster timings on macOS with my Macbook Air, even running on battery:

@chqrlie Thank you for the explanation. This is a 2005 PowerMac :) It is reasonably fast when the code is optimized for the architecture. I doubt this was ever tests on powerpc or any big-endian platforms.

If something can be improved, I am eager to run builds and tests.

barracuda156 commented 3 months ago

The plan is to merge both forks sometime later this year. I am maintaining the original repository and also contribute to the ng fork. I have been slow to backport many patches because of business related duties, but I have set aside most of July and August to catch up on this goal.

@chqrlie Then perhaps it is not worth introducing a separate port in MacPorts just to delete it in a few months. However, the current makefiles build does not work for me. If CMake support can be added, I can try switching it to CMake in MacPorts, that will probably be fine. Otherwise if you can tell me how to fix linking, I can stay with makefiles build. (To be clear, this is not a typical issue, and perhaps quite unique: I have no idea why linking fails when flags are passed.)

andrjohns commented 3 months ago

Otherwise if you can tell me how to fix linking, I can stay with makefiles build.

You can see in the logs you posted that the linking fails at this step:

:info:build ./qjsc -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -m -o examples/hello_module examples/hello_module.js
:info:build Undefined symbols

Which is the makefile target example for compiling to an executable. This fails because qjsc does not support specifying extra libraries for linking

The simplest workaround is to not run make all, which builds examples and tests, and instead just specify the build targets you want

barracuda156 commented 3 months ago

@andrjohns Regarding the compile error above: it happens with Release build, but not with Debug (everything else being the same). This is Debug build:

--->  Building quickjs
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build" && /usr/bin/make -j6 -w all VERBOSE=ON 
make: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/opt/local/bin/cmake -S/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -B/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/qjs.dir/build.make CMakeFiles/qjs.dir/depend
/usr/bin/make  -f CMakeFiles/test_conv.dir/build.make CMakeFiles/test_conv.dir/depend
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/test_conv.dir/DependInfo.cmake "--color="
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/qjs.dir/DependInfo.cmake "--color="
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/test_conv.dir/build.make CMakeFiles/test_conv.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/qjs.dir/build.make CMakeFiles/qjs.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[  4%] Building C object CMakeFiles/test_conv.dir/tests/test_conv.c.o
/opt/local/bin/gcc-mp-13   -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/test_conv.dir/tests/test_conv.c.o -MF CMakeFiles/test_conv.dir/tests/test_conv.c.o.d -o CMakeFiles/test_conv.dir/tests/test_conv.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/tests/test_conv.c
[  9%] Building C object CMakeFiles/qjs.dir/libbf.c.o
/opt/local/bin/gcc-mp-13 -DDUMP_LEAKS -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs.dir/libbf.c.o -MF CMakeFiles/qjs.dir/libbf.c.o.d -o CMakeFiles/qjs.dir/libbf.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/libbf.c
[ 14%] Building C object CMakeFiles/qjs.dir/cutils.c.o
[ 19%] Building C object CMakeFiles/qjs.dir/libunicode.c.o
[ 23%] Building C object CMakeFiles/qjs.dir/quickjs.c.o
[ 28%] Building C object CMakeFiles/qjs.dir/libregexp.c.o
/opt/local/bin/gcc-mp-13 -DDUMP_LEAKS -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs.dir/quickjs.c.o -MF CMakeFiles/qjs.dir/quickjs.c.o.d -o CMakeFiles/qjs.dir/quickjs.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c
/opt/local/bin/gcc-mp-13 -DDUMP_LEAKS -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs.dir/libunicode.c.o -MF CMakeFiles/qjs.dir/libunicode.c.o.d -o CMakeFiles/qjs.dir/libunicode.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/libunicode.c
/opt/local/bin/gcc-mp-13 -DDUMP_LEAKS -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs.dir/libregexp.c.o -MF CMakeFiles/qjs.dir/libregexp.c.o.d -o CMakeFiles/qjs.dir/libregexp.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/libregexp.c
/opt/local/bin/gcc-mp-13 -DDUMP_LEAKS -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs.dir/cutils.c.o -MF CMakeFiles/qjs.dir/cutils.c.o.d -o CMakeFiles/qjs.dir/cutils.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.c
[ 33%] Linking C executable test_conv
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/test_conv.dir/link.txt --verbose=ON
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport CMakeFiles/test_conv.dir/tests/test_conv.c.o -o test_conv  -Wl,-rpath,/opt/local/lib
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[ 33%] Built target test_conv
[ 38%] Linking C static library libqjs.a
/opt/local/bin/cmake -P CMakeFiles/qjs.dir/cmake_clean_target.cmake
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/qjs.dir/link.txt --verbose=ON
/opt/local/bin/ar qc libqjs.a CMakeFiles/qjs.dir/cutils.c.o CMakeFiles/qjs.dir/libbf.c.o CMakeFiles/qjs.dir/libregexp.c.o CMakeFiles/qjs.dir/libunicode.c.o CMakeFiles/qjs.dir/quickjs.c.o
/opt/local/bin/ranlib libqjs.a
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[ 38%] Built target qjs
/usr/bin/make  -f CMakeFiles/qjsc.dir/build.make CMakeFiles/qjsc.dir/depend
/usr/bin/make  -f CMakeFiles/qjs_exe.dir/build.make CMakeFiles/qjs_exe.dir/depend
/usr/bin/make  -f CMakeFiles/run-test262.dir/build.make CMakeFiles/run-test262.dir/depend
/usr/bin/make  -f CMakeFiles/function_source.dir/build.make CMakeFiles/function_source.dir/depend
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/qjsc.dir/DependInfo.cmake "--color="
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/run-test262.dir/DependInfo.cmake "--color="
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/qjs_exe.dir/DependInfo.cmake "--color="
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles/function_source.dir/DependInfo.cmake "--color="
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/function_source.dir/build.make CMakeFiles/function_source.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/run-test262.dir/build.make CMakeFiles/run-test262.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/qjsc.dir/build.make CMakeFiles/qjsc.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/usr/bin/make  -f CMakeFiles/qjs_exe.dir/build.make CMakeFiles/qjs_exe.dir/build
make[2]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[ 42%] Building C object CMakeFiles/function_source.dir/quickjs-libc.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/function_source.dir/quickjs-libc.c.o -MF CMakeFiles/function_source.dir/quickjs-libc.c.o.d -o CMakeFiles/function_source.dir/quickjs-libc.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs-libc.c
[ 47%] Building C object CMakeFiles/function_source.dir/gen/function_source.c.o
[ 52%] Building C object CMakeFiles/run-test262.dir/run-test262.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/run-test262.dir/run-test262.c.o -MF CMakeFiles/run-test262.dir/run-test262.c.o.d -o CMakeFiles/run-test262.dir/run-test262.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/run-test262.c
[ 57%] Building C object CMakeFiles/run-test262.dir/quickjs-libc.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/function_source.dir/gen/function_source.c.o -MF CMakeFiles/function_source.dir/gen/function_source.c.o.d -o CMakeFiles/function_source.dir/gen/function_source.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/gen/function_source.c
[ 61%] Building C object CMakeFiles/qjsc.dir/qjsc.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjsc.dir/qjsc.c.o -MF CMakeFiles/qjsc.dir/qjsc.c.o.d -o CMakeFiles/qjsc.dir/qjsc.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/qjsc.c
[ 66%] Building C object CMakeFiles/qjs_exe.dir/gen/repl.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/run-test262.dir/quickjs-libc.c.o -MF CMakeFiles/run-test262.dir/quickjs-libc.c.o.d -o CMakeFiles/run-test262.dir/quickjs-libc.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs-libc.c
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -Dqjs_exe_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs_exe.dir/gen/repl.c.o -MF CMakeFiles/qjs_exe.dir/gen/repl.c.o.d -o CMakeFiles/qjs_exe.dir/gen/repl.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/gen/repl.c
[ 71%] Building C object CMakeFiles/qjs_exe.dir/qjs.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -Dqjs_exe_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs_exe.dir/qjs.c.o -MF CMakeFiles/qjs_exe.dir/qjs.c.o.d -o CMakeFiles/qjs_exe.dir/qjs.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/qjs.c
[ 76%] Building C object CMakeFiles/qjs_exe.dir/quickjs-libc.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -Dqjs_exe_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjs_exe.dir/quickjs-libc.c.o -MF CMakeFiles/qjs_exe.dir/quickjs-libc.c.o.d -o CMakeFiles/qjs_exe.dir/quickjs-libc.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs-libc.c
[ 80%] Building C object CMakeFiles/qjsc.dir/quickjs-libc.c.o
/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -O0 -ggdb -fno-omit-frame-pointer -MD -MT CMakeFiles/qjsc.dir/quickjs-libc.c.o -MF CMakeFiles/qjsc.dir/quickjs-libc.c.o.d -o CMakeFiles/qjsc.dir/quickjs-libc.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs-libc.c
[ 85%] Linking C executable run-test262
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/run-test262.dir/link.txt --verbose=ON
[ 90%] Linking C executable function_source
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/function_source.dir/link.txt --verbose=ON
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport "CMakeFiles/run-test262.dir/quickjs-libc.c.o" "CMakeFiles/run-test262.dir/run-test262.c.o" -o run-test262  -Wl,-rpath,/opt/local/lib libqjs.a -lm
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport CMakeFiles/function_source.dir/gen/function_source.c.o "CMakeFiles/function_source.dir/quickjs-libc.c.o" -o function_source  -Wl,-rpath,/opt/local/lib libqjs.a -lm
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[ 95%] Linking C executable qjs
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/qjs_exe.dir/link.txt --verbose=ON
[100%] Linking C executable qjsc
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/qjsc.dir/link.txt --verbose=ON
[100%] Built target function_source
[100%] Built target run-test262
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport CMakeFiles/qjs_exe.dir/gen/repl.c.o CMakeFiles/qjs_exe.dir/qjs.c.o "CMakeFiles/qjs_exe.dir/quickjs-libc.c.o" -o qjs  -Wl,-rpath,/opt/local/lib libqjs.a -lm
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -g -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport CMakeFiles/qjsc.dir/qjsc.c.o "CMakeFiles/qjsc.dir/quickjs-libc.c.o" -o qjsc  -Wl,-rpath,/opt/local/lib libqjs.a -lm
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[100%] Built target qjs_exe
[100%] Built target qjsc
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
/opt/local/bin/cmake -E cmake_progress_start /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build/CMakeFiles 0
make: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'

With release, however:

/opt/local/bin/gcc-mp-13 -D_GNU_SOURCE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -std=gnu11 -arch ppc -mmacosx-version-min=10.6 -fvisibility=hidden -Wall -Werror -Wextra -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-format-truncation -funsigned-char -MD -MT CMakeFiles/qjs.dir/cutils.c.o -MF CMakeFiles/qjs.dir/cutils.c.o.d -o CMakeFiles/qjs.dir/cutils.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.c
[ 33%] Linking C executable test_conv
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/test_conv.dir/link.txt --verbose=ON
/opt/local/bin/gcc-mp-13 -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names -latomic -L/opt/local/lib -lMacportsLegacySupport CMakeFiles/test_conv.dir/tests/test_conv.c.o -o test_conv  -Wl,-rpath,/opt/local/lib
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/build'
[ 33%] Built target test_conv
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:43:
In function 'js__malloc_usable_size',
    inlined from 'js_def_malloc' at /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/quickjs.c:1706:23:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.h:481:12: error: 'ptr' may be used uninitialized [-Werror=maybe-uninitialized]
  481 |     return malloc_size(ptr);
      |            ^~~~~~~~~~~~~~~~
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_quickjs/quickjs/work/quickjs-0.5.0/cutils.h:42:
/usr/include/malloc/malloc.h: In function 'js_def_malloc':
/usr/include/malloc/malloc.h:90:15: note: by argument 1 of type 'const void *' to 'malloc_size' declared here
   90 | extern size_t malloc_size(const void *ptr);
      |               ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/qjs.dir/quickjs.c.o] Error 1

Since malloc.h is a system header, it is included from system prefix, nothing wrong with that. I am not sure what specifically makes a difference to cause an error. Optimization level?

barracuda156 commented 3 months ago

Which is the makefile target example for compiling to an executable. This fails because qjsc does not support specifying extra libraries for linking The simplest workaround is to not run make all, which builds examples and tests, and instead just specify the build targets you want

That will be a questionable reason to justify a PR disabling a target: I cannot fix it the linking for it :)

Examples are often skipped, not a big deal as such, but still it makes a better sense actually fix the linking. Looks like I can just patch the file which you have referred?

andrjohns commented 3 months ago

Looks like I can just patch the file which you have referred?

Completely untested, but you could try something like the below to add the EXTRA_LIBS environment variable to the linker call

    *arg++ = "-lm";
    *arg++ = "-ldl";
    *arg++ = "-lpthread";
+   const char* EXTRA_LIBS_ENV = getenv("EXTRA_LIBS");
+   if (EXTRA_LIBS_ENV) {
+        *arg++ = EXTRA_LIBS_ENV;
+   }
    *arg = NULL;
chqrlie commented 3 months ago

Looks like I can just patch the file which you have referred?

Completely untested, but you could try something like the below to add the EXTRA_LIBS environment variable to the linker call

    *arg++ = "-lm";
    *arg++ = "-ldl";
    *arg++ = "-lpthread";
+   const char* EXTRA_LIBS_ENV = getenv("EXTRA_LIBS");
+   if (EXTRA_LIBS_ENV) {
+        *arg++ = EXTRA_LIBS_ENV;
+   }
    *arg = NULL;

I would prefer a solution where qjsc accepts -lxxx command line arguments and pass them to the linker.

barracuda156 commented 3 months ago

I would prefer a solution where qjsc accepts -lxxx command line arguments and pass them to the linker.

This would be preferable indeed.

thresheek commented 1 month ago

The simplest workaround is to not run make all, which builds examples and tests, and instead just specify the build targets you want

This is seemingly problematic for us (NGINX packaging, we bundle quickjs as an engine for our JS VM implementation) as we'd really like to use make install to get the library and headers installed to a proper place. I would like to avoid having to track possible changes for new headers/targets and just use a well-defined and known target to do that.

I guess I can also not usemake install at all, and just do make libquickjs.a and point to the built location through -I/-L, though.