Code Monkey home page Code Monkey logo

cbqn's Introduction

A BQN implementation in C

CBQN-specific documentationsource code overview

Running

  1. make
    • Third-party packages and other ways to run BQN are listed here
    • Add FFI=0 if your system doesn't have libffi
    • Use gmake on BSD
    • Add REPLXX=0 if C++ is unavailable (will remove line editing/coloring/name completion in the REPL)
    • Run sudo make install afterwards to install into /usr/local/bin/bqn (a PREFIX=/some/path argument will install to /some/path/bin/bqn); sudo make uninstall to uninstall
    • make clean to get to a clean build state
  2. ./BQN somefile.bqn to execute a file, or ./BQN for a REPL

Configuration options

The default configuration enables REPLXX & Singeli, and, if not done before, implicitly runs make for-build to build a CBQN for running build/src/build.bqn and compiling Singeli.

Builds with more performance

(TL;DR: use make o3n for local builds on x86-64, but make is fine on other architectures)

The default target (make o3) will target optimizations for the current architecture, but not any further extensions the specific CPU may have.

Thus, performance can be significantly improved by targeting the specific CPU via make o3n (with the usual drawback of -march=native of it not producing a binary portable to other CPUs of the same architecture).

On x86-64, a native build will, if available, enable usage of AVX2 (i.e. ability to use 256-bit SIMD vectors instead of 128-bit ones, among other things), and BMI2. But, on aarch64, NEON is always available, so a native build won't give significant benefits.

To produce a binary utilizing AVX2 not specific to any processor, it's possible to do make has=avx2. (has=avx2,bmi2 for targeting both AVX2 & BMI2)

Additionally, on AMD Zen 1 & Zen 2, make o3n has=slow-pdep will further improve certain builtins (Zen 1/2 support BMI2, but their implementation of pdep/pext is so slow that not using it for certain operations is very beneficial).

CBQN currently does not utilize AVX-512 or SVE, or have any SIMD optimizations specific to any architectures other than x86-64 and aarch64.

For native builds, targeted extensions are determined by /proc/cpuinfo (or sysctl machdep.cpu on macOS) and C macros defined as a result of -march=native.

Build flags

notui=1 - display build progress in a plain-text format
version=... - specify the version to report in --version (default is commit hash)
nogit=1 - error if something attempts to use git CC=... - choose a different C compiler (default is clang, or cc if unavailable; CBQN is more tuned for clang, but gcc also works)
CXX=... - choose a different C++ compiler; needed only for REPLXX (default is c++)
OUTPUT=path/to/somewhere - change output location; for emcc-o3 it will be the destination folder for BQN.js and BQN.wasm, for everything else - the filename
target_arch=(x86-64|aarch64|generic) - target architecture. Inferred from uname by default. Used for deciding target optimizations.
target_os=(linux|bsd|macos|windows) - target OS. Inferred from uname by default. Used for determining default output names and slight configuration changes.
j=8 - override the default parallel job count (default is the output of nproc)
has=... - assume specified architecture extensions/properties (x86-64-only). Takes a comma-separated list which, beyond what is architecturally guaranteed, infer additional extensions as noted which hold on existing hardware (at least as of the time of writing):

  • pclmul (implies SSE4.2)
  • avx2 (implies pclmul, POPCNT, BMI1)
  • bmi2 (implies pclmul, AVX1)
  • slow-pdep (specifies Zen 1 & Zen 2's slow pdep/pext)

REPLXX=0 - disable REPLXX singeli=0 - disable usage of Singeli
FFI=0 - disable •FFI, thus not depending on libffi
usz=64 - support arrays with length over 232

f=... - add extra C compiler flags for CBQN file compilation
lf=... - add extra linking flags (LDFLAGS is a synonym)
CCFLAGS=... - add flags for all CC/CXX/linking invocations
REPLXX_FLAGS=... - override replxx build flags (default is -std=c++11 -Os)
CXXFLAGS=... - add additional CXX flags

Alternatively, build/build (aka build.bqn) can be invoked manually, though note that it has slightly different argument naming (see build/build --help) and doesn't have predefined build types (i.e. make o3ng is done as build/build replxx singeli native g)

More build types

  • make o3 - the default build
  • make o3g - effectively make o3 f=-g (custom f=... can still be added on)
  • make c - make o3 but without -O3
  • make shared-o3 - produce a shared library libcbqn.so/libcbqn.dylib/cbqn.dll
  • make shared-c - like make c but for a shared library
  • make emcc-o3 - build with Emscripten emcc
  • make wasi-o3 - build targeting WASI
  • make wasi-reactor-o3 - build producing a WASI Reactor
  • make debug - unoptimized build with extra assertion checks (also includes -g)
  • make static-bin - build a statically linked executable (for a fully standalone binary, try make static-bin CC=musl-gcc REPLXX=0)
  • make static-lib - build a static library archive

All of the above will go through build.bqn. If that causes problems, make o3-makeonly or make c-makeonly can be used. These still enable REPLXX by default, but do not support Singeli. Furthermore, these targets don't support some of the build flags that the others do.

Limitations

  • The current default is to use unsigned 32-bit integers for array lengths, limiting array size to about 2^32 elements. This can be switched to 64-bit via usz=64, but will have limited effect as some builtins don't have implementations for indices larger than 32-bit (search functions, , /𝕩, /⁼𝕩 & similar). Additionally, some things may fail even before 2^31 and may even crash CBQN.

  • Throwing & catching errors will leak memory: the garbage collector has no way to scan for objects on the C stack, and checks for objects with an incorrect reference count (comparing to the expected from other heap objects / GC roots) to estimate that. Error catching is implemented as a longjmp, thus making the GC permanently think those are still on the C stack. Between REPL lines, a full GC can run (as then there's a guarantee of no BQN code being mid-execution), but that doesn't apply to any other context.

  • Freeing highly nested objects will crash: object freeing is done recursively, and there is nothing preventing arbitrarily-nested objects.

Requirements

CBQN requires either gcc or clang as the C compiler (by default it attempts clang as things are primarily optimized for clang, but, if unavailable, it'll fall back to cc; override with CC=your-cc), and, optionally, libffi for •FFI and C++ (requires ≥C++11; defaults to c++, override with CXX=your-c++) for replxx.

There aren't hard requirements for versions of any of those, but nevertheless here are some configurations that CBQN is tested on by dzaima:

x86-64 (Linux):
  gcc 9.5; gcc 12.1.0; clang 10.0.0; clang 17-trunk
  libffi 3.4.2
  cpu microarchitecture: Haswell
  replxx: g++ 12.1.0
x86 (Linux):
  clang 17-trunk; CBQN is known to break on gcc x86 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416
  running on the above x86-64 system, compiled with CCFLAGS=-m32
AArch64 ARMv8-A (within Termux on Android 8):
  using a `lf=-landroid-spawn` make arg after `pkg install libandroid-spawn` to get •SH to work
  clang 16.0.6
  libffi 3.4.4 (structs were broken as of 3.4.3)
  replxx: clang++ 16.0.6

Additionally, CBQN is known to compile as-is on macOS. Windows builds can be made by cross-compilation (Docker setup).

The build will attempt to use pkg-config to find libffi, uname to determine target_arch & target_os, and nproc for parallel job count, with defaults if unavailable (-lffi for linking libffi (+ -ldl on non-BSD), target_arch=generic, target_os=linux, j=4; these can of course also be specified manually).

Furthermore, git is used to determine the version to present for --version (override with version=...), and to update submodules.

Submodules are used for Singeli, replxx, and precompiled bytecode. To avoid automatic usage of git, link local copies to build/singeliLocal, build/replxxLocal, and build/bytecodeLocal.

Precompiled bytecode

CBQN uses the self-hosted BQN compiler & some parts of the runtime, and therefore needs to be bootstrapped. By default, the CBQN will use precompiled bytecode.

In order to build everything from source, you can:

option 1: use another BQN implementation

  1. dzaima/BQN is a BQN implementation that is completely implemented in Java (clone it & run ./build)
  2. clone mlochbaum/BQN
  3. mkdir -p build/bytecodeLocal/gen
  4. other-bqn-impl ./build/genRuntime path/to/mlochbaum/BQN build/bytecodeLocal
    In the case of the Java impl, java -jar path/to/dzaima/BQN/BQN.jar ./build/genRuntime path/to/mlochbaum/BQN build/bytecodeLocal

option 2: use the bootstrap compilers

  1. clone mlochbaum/BQN
  2. mkdir -p build/bytecodeLocal/gen && make for-bootstrap && ./BQN build/bootstrap.bqn path/to/mlochbaum/BQN

Note that, after either of those, the compiled bytecode may become desynchronized if you later update CBQN without also rebuilding the bytecode. Usage of the submodule can be restored by removing build/bytecodeLocal.

Cross-compilation

You must manually set up a cross-compilation environment. It's possible to pass flags to all CC/CXX/linking invocations via CCFLAGS=..., and LDFLAGS=... to pass ones to the linking step specifically (more configuration options above).

A target_arch=(x86-64|aarch64|generic) make argument must be present (generic will work always, but a more specific argument will enable significant optimizations), as otherwise it'll choose based on uname.

Furthermore, all build targets (except -makeonly ones) will need a non-cross-compiled version of CBQN at build time to run build.bqn and Singeli. For those, a make for-build will need to be ran before the primary build, configured to not cross-compile. (this step only needs a C compiler (default is CC=cc here), and doesn't need libffi, nor a C++ compiler).

Licensing

First, some exceptions to the general licensing:

Additionally, REPLXX (optional, included by default) has its own licensing at build/replxxSubmodule/LICENSE.md.

Everything else (i.e. all files except src/builtins/sortTemplate.h, src/utils/ryu.c, and everything in src/utils/ryu/) may be treated as under any of the following licenses, as if they had the respective notice:

Copyright (C) 2021-2023 dzaima and contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
Copyright (C) 2021-2023 dzaima and contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

cbqn's People

Contributors

actalley avatar andersontorres avatar ap29600 avatar charlesrocket avatar dancek avatar detegr avatar dlozeve avatar dzaima avatar jshholland avatar mlochbaum avatar paulapatience avatar selaere avatar sternenseemann avatar vylsaz avatar yiyus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cbqn's Issues

Failing Tests

Hello,

I've nearly completed packaging cbqn for GNU Guix (with a 5 step bootstrapping process including dbqn and singeli), but a few tests are failing in my build. I've attached the log, starting at the first error, below.

Some possibly relevant information:

  • I used clang, per Your recommendation.
  • Full bootstrap process is dbqn → cbqn sans tests and singeli with bqn sources compiled with dbqn → cbqn with singeli and full tests.
  • I can just skip the failing tests if needed, but they need to be reported here before the package will be accepted.

Are these tests expected to fail, or am I doing something wrong?

4
ValueError: Undefined system constant ?file
tests ? ?FLines ?wdpath?file.At path?"/test/cases/prim.bqn"
                       ^^^^^                               
Stack:
1:
#!/gnu/store/5wdp6gknchng4kr2h45ra57divjsn4fx-dbqn-0.2.1/bin/dbqn
?????????????????????????????????????????????????????????????????
tests ? ?FLines ?wdpath?file.At path?"/test/cases/prim.bqn"
                       ^^^^^                               
Exception in thread "main" BQN.errors.ValueError: Undefined system constant ?file
        at BQN.tools.SysVals.getDyn(SysVals.java:132)
        at BQN.Scope.get(Scope.java:134)
        at BQN.Scope.getC(Scope.java:148)
        at BQN.Comp.exec(Comp.java:127)
        at BQN.Comp$SingleComp.exec(Comp.java:678)
        at BQN.Sys.execFile(Sys.java:169)
        at BQN.Main.main(Main.java:115)
AS
AA
166008223392
166008238182
? "Ab" "Ai8" "Ai16" "Ai32" "Af64" "Ah" "Af" "Si8" "Si16" "Si32" "Sf64" "Sh" "Sf" "AbInc" "Ai8Inc" "Ai16Inc" "Ai32Inc" "Af64Inc" "AhInc" "AfInc" "Si8Inc" "Si16Inc" "Si32Inc" "Sf64Inc" "ShInc" "SfInc" ?
? "Ai8" "Ai16" "Ai32" "Af64" "Ah" "Af" "Si8" "Si16" "Si32" "Sf64" "Sh" "Sf" "Ai8Inc" "Ai16Inc" "Ai32Inc" "Af64Inc" "AhInc" "AfInc" "Si8Inc" "Si16Inc" "Si32Inc" "Sf64Inc" "ShInc" "SfInc" ?
? "Ai16" "Ai32" "Af64" "Ah" "Af" "Si16" "Si32" "Sf64" "Sh" "Sf" "Ai16Inc" "Ai32Inc" "Af64Inc" "AhInc" "AfInc" "Si16Inc" "Si32Inc" "Sf64Inc" "ShInc" "SfInc" ?
? "Ai32" "Af64" "Ah" "Af" "Si32" "Sf64" "Sh" "Sf" "Ai32Inc" "Af64Inc" "AhInc" "AfInc" "Si32Inc" "Sf64Inc" "ShInc" "SfInc" ?
? "Af64" "Ah" "Af" "Sf64" "Sh" "Sf" "Af64Inc" "AhInc" "AfInc" "Sf64Inc" "ShInc" "SfInc" ?
? "Ac8" "Ac16" "Ac32" "Ah" "Af" "Sc8" "Sc16" "Sc32" "Sh" "Sf" "Ac8Inc" "Ac16Inc" "Ac32Inc" "AhInc" "AfInc" "Sc8Inc" "Sc16Inc" "Sc32Inc" "ShInc" "SfInc" ?
? "Ac16" "Ac32" "Ah" "Af" "Sc16" "Sc32" "Sh" "Sf" "Ac16Inc" "Ac32Inc" "AhInc" "AfInc" "Sc16Inc" "Sc32Inc" "ShInc" "SfInc" ?
? "Ac32" "Ah" "Af" "Sc32" "Sh" "Sf" "Ac32Inc" "AhInc" "AfInc" "Sc32Inc" "ShInc" "SfInc" ?
? "Ah" "Af" "Sh" "Sf" "AhInc" "AfInc" "ShInc" "SfInc" ?
? "Ah" "Af" "Sh" "Sf" "AhInc" "AfInc" "ShInc" "SfInc" ?
Fraction of matching variation count to ListVariations: 0.9985000000000001 (expected: ~0.999)
166008246641
Fail:
Exp: 0011000111100100010100001101011110010000000111011000010111001001 0111111001011001111011000100001011010010111011001010010110000111 0100001111010101011100010011101010100010111111111111110000100100 1000010010111000111101000101011110111010101000011000000110000000 0000001011010001011100000110001111011010010100110000100001011110 0110111011100010101111110000110101101010000011001110011111001110 01011011101100001111001001100000111000110111001110000
Got: 0011000111100100010100001101011110010000000111011000010101100110 0001100001100101010110011000100011011011101000100111101101010101 0000101100000010001101000111010110101011010110010000100000100100 1000010010111000111101000101011110111010101000011000000110000000 0000001011010001011100000110001111011010010100110000100001011110 0110111011100010101111110000110101101010000011001110011111001110 01011011101100001111001001100000111000110111001110000
Inputs:
r:   0011000111100100010100001101011110010000000111011000010101100110 0001100001100101010110011000100011011011101000100111101101010101 0000101100000010001101000111010110101011010110010000100000100100 1000010010111000111101000101011110111010101000011000000110000000 0000001011010001011100000110001111011010010100110000100001011110 0110111011100010101111110000110101101010000011001110011111001110 01011011101100001111001001100000111000110111001110000
rs:  52
x:   0001001010111100010001100011110111110111010110101000010101111100 0101010111010000010001010011101110111110110011101101011111011011 1101011001011101100101010011101000010100011110000000110100101101 0111100010001110101110010010111111001011001111011000100001011010 0101110110010100101100001110100001111010101011100010011101010100 0101111111111111101011111000110011110001111100110001010110000000 10001101101110001011010001000000110011000111010110011
xs:  207
l:   130
Error: Assertion error
./test/random.bqn:18:
  rByteVals {! "i8arr" ? TY ???}? ?10 # ? is dumb for now, but when it realizes that n?0 is a bitarr this'll need changing
             ^
./test/random.bqn:18:
  rByteVals {! "i8arr" ? TY ???}? ?10 # ? is dumb for now, but when it realizes that n?0 is a bitarr this'll need changing
            ^^^^^^^^^^^^^^^^^^^^^
166008246634
make: Entering directory '/tmp/guix-build-cbqn-0-1.88f6585.drv-0/source/test/ffi'
cc -O3 -g -c -fpic ffiTest.c -o ffiTest.o
cc -shared -olib.so ffiTest.o
Error: Unknown system function ?ffi
make: *** [makefile:15: testLib] Error 1
make: Leaving directory '/tmp/guix-build-cbqn-0-1.88f6585.drv-0/source/test/ffi'

Can't build shared library on Linux

Don't know why. make works (producing ./BQN).

2 ❯ make shared-o3

automatically-built bootstrap CBQN doesn't behave as expected; run 'make for-build' with necessary configuration manually
make[1]: *** [makefile:50: to-bqn-build] Error 1
make: *** [makefile:85: shared-o3] Error 2

❯ ./BQN build/src/build.bqn
Error: Native compiler: Can't tokenize \u5f / 95

tried Option 2 of bootstraping. didn't work either

JIT fails to request memory on WSL2 Ubuntu 20.04

On WSL2, Ubuntu 20.04, x86/64 architecture, free -h showing 19Gi available.
git clone https://github.com/dzaima/CBQN.git
cd CBQN
make
it seems to get pretty far - in the output, I see "Using precompiled bytecode..."
it ends with "load.c" followed by the error:
CBQN encountered a fatal error: Failed to allocate memory for JIT 200 times; stopping trying
automatically-built bootstrap CBQN doesn't behave as expected; run 'make for-build' with necessary configuration manually

I would be happy to make for-build manually, but I'm having trouble figuring out what configuration to use. Any help would be greatly appreciated!

Building without precompiled bytecode

Is there a way to build CBQN without relying on the precompiled bytecode in the bytecode branch?

I would like to package BQN for GNU Guix, but to do it must be built without any precompiled binaries.

OSX installation issue

Based on docs from the main BQN page and this repo, I can't seem to run what's built:

$ make # builds with a couple warnings
$ rlwrap ./BQN
Error: JIT: Refusing to run with CBQN code outside of the 32-bit address range
2: source unknown
1: source unknown
0: source unknown

Difference between Output and Returned Values

Hello,

Is there a way to differentiate between values sent to stdout via a BQN program (using Show or similar) and values returned to the user at the REPL? If not, could such a functionality be added as a flag or similar?

I am most of the way through implementing Org Babel support for BQN, but my current workaround for capturing output breaks if the final command given in a block is an output that contains a newline, because CBQN will repeat the last return value at the REPL.

This is fine and makes sense, but if it could be suppressed with a special flag or marked as being a value instead of output in some way, then implementing the difference between output and value in Org Babel (and similar systems that might only care about one or the other) would be made much easier.

20220815T210345 screenshot

Relicense to dual-licensed LGPLv3 & MPL2

To ease usage of CBQN as a library, it'd be nice to relicense to something that unambiguously allows such without requiring that the caller is GPLv3-licensed (GPLv3 by itself being rather ambiguous to whether that's needed on static and/or dynamic linking).

The proposal here is to relicense to dual-licensed LGPLv3-only (GNU Lesser General Public License v3.0) & MPL2 (Mozilla Public License Version 2.0); LGPLv3 allows dynamic linking (but still is questionable on static linking), and MPL2 further relaxes things (allowing static linking).

The idea with having both is that a user could choose the one that's easier to integrate (which'd be LGPLv3 if such-licensed libraries are already in use, and otherwise MPL2).

Both licenses still require the source code to be receivable by anyone that has received a compiled form of CBQN (i.e. copyleft). Of note is that MPL2 doesn't have anti-tivoization.

LGPLv3 implicitly includes being relicensable to GPLv3, so it could be said that this would also be triple-licensing to GPLv3, LGPLv3, and MPL2. That is, after this change CBQN could still be packaged as GPLv3 if so desired, not requiring any changes in existing distributions.

@mlochbaum @Detegr @yiyus @paulapatience @actalley If you are fine with your respective contributed code to be relicensed to MPL2&LGPLv3, add a ":+1:" reaction to this issue or something; otherwise, discuss

makefile tries to use clang on Linux

Got error "bash: clang: command not found" after running make o3 on Ubuntu 20.04 LTS.
Change the default CC = clang to CC = gcc then it works.

Segmentation fault on Pick primitive

Hello,
I received a segmentation fault when trying to parse an csv file
Here is an example of my code

l ← •file.Lines "./data.csv"
m←l=',' ⋄ p ← ((¬m)/¨l)⊔˜¨(¬m)/¨+`¨m ⋄ h ← ⥊>1↑p ⋄ t ← >1↓p
z ← 0≠≠¨˘t
•Show 3⊸⊑˘z

with output

[1]    31977 segmentation fault  bqn main.bqn

I've added an example csv file here:
https://gist.github.com/anthonyquizon/8954108913b6dda3a3e6498b8822aadf

My bqn interpreter is compiled with the debug flag 'ie. make debug' using the latest code in the master branch.

Here is the where lldb stops
Screenshot 2024-02-27 at 4 05 31 pm

Here is my bqn --version output

CBQN on commit 8c18fddd5483c5fba658f24674b004e4444bf72d
built with FFI, singeli aarch64, replxx, optimizations disabled, debugging checks enabled (DEBUG)

I'm running on an iMac with M3 chip using Sonoma 14.1.1

If I remove h ← ⥊>1↑p from the above code I get this error message:

Bad used range for 0x101079680: 8..144, allocation size 128, usable 64

I initially tried on the version in nix with is 0.4.0 and got a similar issue.

Mention packaging in GNU Guix

Hello,

CBQN is now packaged for GNU Guix.

It might be worthwhile to add a note saying as much to README.md, to spread awareness that manual compilation is unnecessary if a user wants to use CBQN.

If a user has GNU Guix installed, they only need to run the following command to install and then use CBQN, eliminating all other setup needed by the user: guix install cbqn. It is currently tested on x86_64 and confirmed working (by me and our CI backends), but not for aarch64 due to an issue with a dependency of librsvg (gdk-pixbuf-query-loaders) failing to build properly (outside of my control and experience).

There is a badge that can be utilized if You prefer; it looks like this: Packaged in GNU Guix If You'd like to use it, feel free to add it as a file to Your repo so it doesn't move around; It is licensed under GPLv3/FDLv1.3, which is compatible with this project.

error: static declaration of 'gc_visitRoots' follows non-static declaration

got this error after running make o3 on Ubuntu 20.04 LTS:

In file included from src/core/../opt/mm_buddy.c:1,
from src/core/mm.c:6:
src/core/../opt/gc.c:54:13: error: static declaration of 'gc_visitRoots' follows non-static declaration
54 | static void gc_visitRoots() {
| ^~~~~~~~~~~~~
In file included from src/core/../core.h:2,
from src/core/mm.c:1:
src/core/../h.h:275:6: note: previous declaration of 'gc_visitRoots' was here
275 | void gc_visitRoots(void);
| ^~~~~~~~~~~~~

remove the static on line 54 then it works.

Blocks in REPL

Are blocks only supposed to exist in files? For some reason, I get an error when I try to execute something like the following (which comes from the BQN documentation in my CBQN repl:

updown ← {
up5
downup
updown
}

If so, this also means that for things like https://github.com/museoa/bqn-mode executing the buffer You are working on is impossible if it contains a block, as it would pass the buffer as a string to the running REPL rather than saving the file and loading it into CBQN.

Error: Couldn't read file "./test/this.bqn"

The above is the output for all of the *.sh-based tests echoes the above Error: Couldn't read file "./test/this.bqn". Is this file supposed to exist at this point, or is another file meant to be tested?

Segfault while attempting to apply a constant as a function under modifiers

The following program causes a segfault in cbqn: @´˘ 2‿2⥊↕4.

Full repro with version info:

$ cbqn --version
CBQN on commit 23737cc4580c995aac76a8a5bae4ca39492968fd
built with FFI, singeli x86-64 avx2, replxx
$ cbqn -p '@´˘ 2‿2⥊↕4'
[1]    5027 segmentation fault  cbqn -p '@´˘ 2‿2⥊↕4'

Other numbers and characters also trigger the segfault, but not .

Oddly neither Fold nor Cells on their own trigger the segfault; instead producing expected values. Is there some kind of peephole optimization that doesn't convert the constant to a function correctly?

font question

Do you have a recommended font for running this locally in urxvt? 🙏

OSX build meet error.

ld: unknown option: --dynamic-list=include/syms
clang: error: linker command failed with exit code 1 (use -v to see invocation)

when make ffi=0 , it's ok

Release tags do not include libraries

The zip and tar.gz files for CBQNs tags do not include cbqnBytecode, replxx, or Singeli.
Running make from these archives results in an error since these archives are not git repos and don't include these libraries:

fatal: not a git repository (or any of the parent directories): .git

Mltiple errors while installing

Hello, I'm new to BQN and I'd like to get started by downloading it onto my PC and start coding. I tried following the instructions provided, but I couldn't make it work

System: Ubuntu 20 Desktop
clang: No clang on os
Note: I have it SUDOed

Question: Is folder structure relevant?

Tried: sudo make REPLXX=1 CC=cc

with the following response (Long code warning):

builtins/arithd.c
builtins/cmp.c
builtins/arithm.c
builtins/sfns.c
builtins/squeeze.c
builtins/select.c
src/builtins/sfns.c: In function ‘shape_c2’:
src/builtins/sfns.c:165:19: warning: ‘unkInd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  165 |         } else if (unkInd == n_reverse) {
      |                   ^
builtins/sort.c
In file included from src/builtins/sort.c:12:
src/builtins/grade.h: In function ‘gradeUp_c2’:
src/builtins/grade.h:302:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
  302 |         for (u64 i=0; i<xia; i++) rp[i]=wia; goto done;
      |         ^~~
src/builtins/grade.h:302:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
  302 |         for (u64 i=0; i<xia; i++) rp[i]=wia; goto done;
      |                                              ^~~~
In file included from src/builtins/../core.h:3,
                 from src/builtins/sort.c:1:
src/builtins/../h.h:532:18: error: a label can only be part of a statement and a declaration is not a statement
  532 | #define SGetU(X) Arr* X##_arrU = a(X); AS2B X##_getU = TIv(X##_arrU,getU);
      |                  ^~~
src/builtins/grade.h:327:5: note: in expansion of macro ‘SGetU’
  327 |     SGetU(x)
      |     ^~~~~
src/builtins/../h.h:532:40: error: expected expression before ‘AS2B’
  532 | #define SGetU(X) Arr* X##_arrU = a(X); AS2B X##_getU = TIv(X##_arrU,getU);
      |                                        ^~~~
src/builtins/grade.h:327:5: note: in expansion of macro ‘SGetU’
  327 |     SGetU(x)
      |     ^~~~~
src/builtins/grade.h:341:18: warning: implicit declaration of function ‘x_getU’ [-Wimplicit-function-declaration]
  341 |       B c = GetU(x,i);
      |                  ^
src/builtins/../h.h:534:19: note: in definition of macro ‘GetU’
  534 | #define GetU(X,N) X##_getU(X##_arrU,N)
      |                   ^
src/builtins/grade.h:341:18: error: invalid initializer
  341 |       B c = GetU(x,i);
      |                  ^
src/builtins/../h.h:534:19: note: in definition of macro ‘GetU’
  534 | #define GetU(X,N) X##_getU(X##_arrU,N)
      |                   ^
In file included from src/builtins/sort.c:14:
src/builtins/grade.h: In function ‘gradeDown_c2’:
src/builtins/grade.h:302:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
  302 |         for (u64 i=0; i<xia; i++) rp[i]=wia; goto done;
      |         ^~~
src/builtins/grade.h:302:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
  302 |         for (u64 i=0; i<xia; i++) rp[i]=wia; goto done;
      |                                              ^~~~
In file included from src/builtins/../core.h:3,
                 from src/builtins/sort.c:1:
src/builtins/../h.h:532:18: error: a label can only be part of a statement and a declaration is not a statement
  532 | #define SGetU(X) Arr* X##_arrU = a(X); AS2B X##_getU = TIv(X##_arrU,getU);
      |                  ^~~
src/builtins/grade.h:327:5: note: in expansion of macro ‘SGetU’
  327 |     SGetU(x)
      |     ^~~~~
src/builtins/../h.h:532:40: error: expected expression before ‘AS2B’
  532 | #define SGetU(X) Arr* X##_arrU = a(X); AS2B X##_getU = TIv(X##_arrU,getU);
      |                                        ^~~~
src/builtins/grade.h:327:5: note: in expansion of macro ‘SGetU’
  327 |     SGetU(x)
      |     ^~~~~
src/builtins/grade.h:341:18: error: invalid initializer
  341 |       B c = GetU(x,i);
      |                  ^
src/builtins/../h.h:534:19: note: in definition of macro ‘GetU’
  534 | #define GetU(X,N) X##_getU(X##_arrU,N)
      |                   ^
make[2]: *** [makefile:198: obj/ba9923306553b1fba7f3b00eb32fd8bc/sort.o] Error 1
make[2]: *** Se espera a que terminen otras tareas....
make[1]: *** [makefile:164: run_incremental_0] Error 2
make: *** [makefile:7: o3] Error 2

I also tried: sudo make clean

And received:

spoiler: orden no encontrada = order not found


bash: clang: orden no encontrada
rm -f obj/*/*.o
rm -f obj/*/*.d
rm -f src/gen/customRuntime
rm -rf src/singeli/gen/
bash: clang: orden no encontrada
rm -f obj/presingeli/*.o
rm -f obj/presingeli/*.d

Any advice?

undefined reference to `_pdep_u64'

Compile failed using make o3n
[CPU]: Intel(R) Core(TM) i7-10700F
[OS]: WSL2 (Ubuntu jammy)
[Kernel]: Linux version 5.15.90.1-microsoft-standard-WSL2
[CC]: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 / Ubuntu clang version 14.0.0-1ubuntu1
[Error]:
src/utils/bits.c:155:47: warning: implicit declaration of function '_pdep_u64' is invalid in C99 [-Wimplicit-function-declaration]
for (ux i=0; i<am; i++) { (u64)rp = _pdep_u64(rbuu64(xp, icount), msk0); rp++; }
^
src/utils/bits.c:160:23: warning: implicit declaration of function '_pdep_u64' is invalid in C99 [-Wimplicit-function-declaration]
(u64)rp = _pdep_u64(rbuu64(xp, am
count), msk1);
^
src/utils/bits.c:241:47: warning: implicit declaration of function '_pext_u64' is invalid in C99 [-Wimplicit-function-declaration]
for (ux i=0; i<am; i++) { ab_add(&ab, _pext_u64((u64)xp, msk0), count); xp+= 8; }
^
src/utils/bits.c:246:23: warning: implicit declaration of function '_pext_u64' is invalid in C99 [-Wimplicit-function-declaration]
ab_add(&ab, _pext_u64((u64)xp, msk1), POPC(msk1));
^
4 warnings generated.
/usr/bin/ld: build/obj/def_o3n/bits.o: in function zeroPadToCellBits0': bits.c:(.text+0xdbc): undefined reference to _pdep_u64'
/usr/bin/ld: bits.c:(.text+0xe18): undefined reference to _pdep_u64' /usr/bin/ld: build/obj/def_o3n/bits.o: in function narrowWidenedBitArr':
bits.c:(.text+0x1938): undefined reference to _pext_u64' /usr/bin/ld: bits.c:(.text+0x1c44): undefined reference to _pext_u64'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [makefile:255: build/obj/def_o3n/BQN] Error 1
make[1]: *** [makefile:225: run_incremental_0] Error 2
make: *** [makefile:11: o3n] Error 2

Compilation failed with last version

make

builtins/arithm.c
builtins/arithd.c
builtins/cmp.c
builtins/sfns.c
builtins/squeeze.c
builtins/select.c
builtins/slash.c
builtins/group.c
builtins/sort.c
builtins/selfsearch.c
builtins/md1.c
builtins/md2.c
builtins/fns.c
builtins/sysfn.c
builtins/internal.c
builtins/inverse.c
core/tyarr.c
core/harr.c
core/fillarr.c
core/stuff.c
core/derv.c
core/mm.c
core/heap.c
Copying precompiled bytecode from the bytecode branch
git checkout remotes/origin/bytecode src/gen/{compiles,formatter,runtime0,runtime1,src,explain}
fatal: not a git repository (or any of the parent directories): .git

make[2]: *** [makefile:224: src/gen/customRuntime] Error 128
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [makefile:176: run_incremental_0] Error 2
make: *** [makefile:7: o3] Error 2

Release Tagging Question

Right now we are packaging arbitrary commits of CBQN, for the packages that exist. However, it would be a better user experience if there were released versions that were guaranteed to work in a specific way, rather than simply installing a package of 'the latest commit'.

Is there any way we could establish a release tag (and therefore a development version) for CBQN, so that the packaged versions can be sure to coincide with specific updates and features?

Decoupling Singeli from CBQN build

Would it be possible to decouple the singeli source from the source directory of an optimized CBQN build?

I'm specifically looking at https://github.com/dzaima/CBQN/blob/master/makefile#L216, where the Singeli source is pulled into the build directory. If someone were to have Singeli installed as a package, would it be possible to have a makefile variable to point to that instead of assuming the Singeli directory holds the entire build tree for Singeli?

I'm asking as this question was raised in the GNU Guix package update referenced in #45, which can be viewed here. As of right now, the source is included in the optimized build as a source that is grafted into the build directory. It would be more maintainable and user-friendly if we could simply package singeli separately and use that as a dependency of the optimized build, instead of duct taping the sources together as the package definition currently does.

Thoughts?

UX: Packages

It'd be nice to have a packaged CBQN. Not only for direct use, but also so projects like Beacon can be packaged as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.