diff --git a/README.md b/README.md index f44876af..1f8a85c5 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,14 @@ - Target architecture is decided from `uname` - override with `target_arch=...` (valid values being `x86-64`, `aarch64`, `generic`). For native builds, targeted extensions are decided by `/proc/cpuinfo` (or `sysctl machdep.cpu` on macOS), and C macro checks. - Build flags: - - `CC=cc` - choose a different C compiler (default is `clang`) - - `CXX=c++` - choose a different C++ compiler (default is `c++`) + - `CC=...` - choose a different C compiler (default is `clang`) + - `CXX=...` - choose a different C++ compiler (default is `c++`) - `f=...` - add extra C compiler flags for CBQN file compilation - - `lf=...` - add extra linker flags - - `CCFLAGS=...` - add flags for all CC/CXX/linker invocations - - `REPLXX=0`/`REPLXX=1` - enable/disable replxx (default depends on target and may change in the future) + - `lf=...` - add extra linking flags + - `CCFLAGS=...` - add flags for all CC/CXX/linking invocations + - `REPLXX=0`/`REPLXX=1` - enable/disable replxx (default depends on the target and may change in the future) - `REPLXX_FLAGS=...` - override replxx build flags (default is `-std=c++11 -Os`) + - `CXXFLAGS=...` - add additional CXX flags - `FFI=0` - disable libffi usage - `j=8` to override the default parallel job count - `OUTPUT=path/to/somewhere` - change output location; for `emcc-o3` it will be the destination folder of `BQN.js` and `BQN.wasm`, for everything else - the filename @@ -101,6 +102,14 @@ Git submodules are used for Singeli, replxx, and bytecode. Thus, CBQN won't buil Thus, you must either clone the repo (submodules will be automatically initialized/updated as needed), or use local copies of the submodules by linking/copying local versions to `build/singeliLocal`, `build/replxxLocal`, and `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](#configuration-options)). + +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 the default is to choose based on `uname`. + +Furthermore, most build targets will need a non-cross-compiled version of CBQN at build time to run Singeli and/or the build system. 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). + ## License Most files here are copyright (c) 2021-2023 dzaima & others, [GNU GPLv3 only](licenses/LICENSE-GPLv3). diff --git a/build/src/build.bqn b/build/src/build.bqn index c9b6b248..4e5c0d29 100755 --- a/build/src/build.bqn +++ b/build/src/build.bqn @@ -33,7 +33,8 @@ opts ← ⟨ ⟨0, "OUTPUT", "", "Output location; defaults to ./BQN for regular builds"⟩ ⟨2, "f", ⟨⟩, "C flags for CBQN files"⟩ - ⟨2, "CCFLAGS", ⟨⟩, "flags for all C compiler & linker invocations"⟩ + ⟨2, "CCFLAGS", ⟨⟩, "flags for all CC/CXX invocations (both object file & linking)"⟩ + ⟨2, "CXXFLAGS",⟨⟩, "flags for C++ object file creation invocations"⟩ ⟨2, "lf", ⟨⟩, "linker flags"⟩ ⟨2, "sf", ⟨⟩, "Singeli flags"⟩ ⟨2, "LDFLAGS", ⟨⟩, @⟩ @@ -303,6 +304,7 @@ po ← { # parsed options REPLXXc ⇐ { 𝕊: args ← ⟨cxx, "-DREPLXX_STATIC=1", "-I"∾replxxDir∾"/include"⟩ args∾↩ GetOpt "REPLXX_FLAGS" + args∾↩ GetOpt "CXXFLAGS" args∾↩ ( ¬pie) / ⟨"-fno-pie"⟩ args∾↩ GetOpt "CCFLAGS" args∾↩ (pie ∧ ¬shared) / ⟨"-fPIE"⟩ diff --git a/makefile b/makefile index c7065b47..d67b1454 100644 --- a/makefile +++ b/makefile @@ -51,7 +51,7 @@ ifeq ($(origin clean),command line) endif @build/build from-makefile CC="$(CC)" CXX="$(CXX)" PIE="$(ENABLE_PIE)" OUTPUT="$(OUTPUT)" j="$(j)" \ verbose="$(verbose)" notui="$(i_notui)" v="$(version)" \ - f="$(f)" lf="$(lf)" CCFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" REPLXX_FLAGS="$(REPLXX_FLAGS)" \ + f="$(f)" lf="$(lf)" CCFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" REPLXX_FLAGS="$(REPLXX_FLAGS)" CXXFLAGS="$(CXXFLAGS)" \ LD_LIBS="$(LD_LIBS)" NO_LDL="$(NO_LDL)" no_fPIC="$(no_fPIC)" \ c="$(build_c)" debug="$(debug)" $(i_build_opts) $(build_opts) \ os="$(target_os)" arch="$(target_arch)" has="$(has)" \ @@ -229,7 +229,7 @@ ifeq ($(custom),) else @[ -x "$$(command -v sha256sum)" ] && hashInput="sha256sum"; \ [ -x "$$(command -v shasum)" ] && hashInput="shasum -a 256"; \ - printf "%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s" "${i_CC}" "${ALL_CC_FLAGS}" "${ALL_LD_FLAGS}" "${REPLXX}" "${REPLXX_FLAGS}" "${i_CXX}" "${BYTECODE_DIR}" "${REPLXX_DIR}" "${SINGELI_DIR}" | $$hashInput | grep -oE '[0-9a-z]{64}' | head -c32 + printf "%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s\0%s" "${i_CC}" "${ALL_CC_FLAGS}" "${ALL_LD_FLAGS}" "${REPLXX}" "${REPLXX_FLAGS}" "${CXXFLAGS}" "${i_CXX}" "${BYTECODE_DIR}" "${REPLXX_DIR}" "${SINGELI_DIR}" | $$hashInput | grep -oE '[0-9a-z]{64}' | head -c32 endif else @printf "%s" "$(force_build_dir)" @@ -388,7 +388,7 @@ REPLXX_FLAGS = -std=c++11 -Os ALL_CC_FLAGS += -DUSE_REPLXX -I$(REPLXX_DIR)/include $(i_CC_PIE) -CXX_INC = $(i_CXX) $(CCFLAGS) $(REPLXX_FLAGS) -DREPLXX_STATIC=1 -I$(REPLXX_DIR)/include -MMD -MP -MF +CXX_INC = $(i_CXX) $(CCFLAGS) $(REPLXX_FLAGS) $(CXXFLAGS) -DREPLXX_STATIC=1 -I$(REPLXX_DIR)/include -MMD -MP -MF replxx_obj: ${addprefix ${bd}/, ConvertUTF.cpp.o wcwidth.cpp.o conversion.cxx.o escape.cxx.o history.cxx.o prompt.cxx.o replxx.cxx.o replxx_impl.cxx.o terminal.cxx.o util.cxx.o windows.cxx.o} ${bd}/%.o: $(REPLXX_DIR)/src/% @echo $<