mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-08-26 07:51:09 +00:00
* feat: let Nimble dependents build liblogosdelivery Nimble installs only a package's namesake directory, so a dependent got logos_delivery/ alone: enough to compile Nim against this package, not enough to build the C library, whose entry point and headers live in library/. installDirs ships that, and migrations/, which the postgres driver reaches by relative import. The build recipe moves into library/build_lib.nims so it ships too, and a dependent builds the library the same way we do instead of copying a flag list. buildLibrary now delegates to it. The move is behaviour-preserving: buildLibrary's `params` was never referenced by either exec string, so the chronicles and warning flags the platform tasks pass have always been discarded, and they still are. Making them honest would move shipped artifacts from INFO to TRACE logging, which is a separate decision. cBindingsDir is derived from the library directory rather than the cwd, so the generated header lands beside the liblogosdelivery.h that includes it wherever the package is checked out. Needed by status-go, which consumes logos-delivery through Nimble (status-im/status-app#19907, logos-messaging/pm#380). * feat: let Nimble dependents build liblogosdelivery Nimble installs only a package's namesake directory, so a dependent received logos_delivery/ alone: enough to compile Nim against this package, not enough to build the C library, whose entry point and headers live in library/. tools/ is needed too, because logos_delivery imports tools/confutils. The single host-platform task saves every consumer dispatching on the OS itself; the per-platform tasks stay for callers that want a specific one. * feat: DISABLE_RLN builds the library without zerokit RLN was not optional: 41 foreign functions are declared with importc and no dynlib, so they must resolve at link time even where RLN is never used, dragging in zerokit, cargo and the submodule. Guarding the twenty modules that reach for rln with `when` would leave one side uncompiled and rotting. This compiles link-time stand-ins for exactly those 41 symbols instead: one conditional file, both configurations building the same Nim. A config that enables RLN on such a build is rejected by setupProtocols through the normal constructor error path, so the stubs are unreachable tripwires rather than the failure mode. Without that check a documented preset — twn sets rlnRelay: true — reached them and aborted the host process with no error callback. config.nims stops force-linking rln.lib on Windows, where the switch was unconditional and handed the linker a library that was never built. The define is scoped to the liblogosdelivery target, so `make DISABLE_RLN=true all` cannot compile the stubs into wakunode2, which still links the real librln. Verified on linux: no librln in ldd, all 41 symbols defined by the stubs and none left undefined, the 16 logosdelivery_* and 37 waku_* entry points intact, and no cargo invocation. status-go links and starts a node against it, and a twn (RLN-enabled) config fails with "the configuration enables RLN relay, but this build has -d:disable_rln".
147 lines
5.9 KiB
Nim
147 lines
5.9 KiB
Nim
import os
|
|
|
|
if defined(release):
|
|
switch("nimcache", "nimcache/release/$projectName")
|
|
else:
|
|
switch("nimcache", "nimcache/debug/$projectName")
|
|
|
|
if defined(windows):
|
|
if not defined(disable_rln):
|
|
switch("passL", "rln.lib")
|
|
switch("define", "postgres=false")
|
|
|
|
# disable timestamps in Windows PE headers - https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries
|
|
switch("passL", "-Wl,--no-insert-timestamp")
|
|
# increase stack size
|
|
switch("passL", "-Wl,--stack,8388608")
|
|
# https://github.com/nim-lang/Nim/issues/4057
|
|
--tlsEmulation:
|
|
off
|
|
if defined(i386):
|
|
# set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag so we can use PAE, if enabled, and access more than 2 GiB of RAM
|
|
switch("passL", "-Wl,--large-address-aware")
|
|
|
|
# https://github.com/status-im/nimbus-eth2/blob/stable/docs/cpu_features.md#ssse3-supplemental-sse3
|
|
# suggests that SHA256 hashing with SSSE3 is 20% faster than without SSSE3, so
|
|
# given its near-ubiquity in the x86 installed base, it renders a distribution
|
|
# build more viable on an overall broader range of hardware.
|
|
#
|
|
if defined(disableMarchNative):
|
|
if defined(i386) or defined(amd64):
|
|
if defined(macosx):
|
|
# macOS Catalina is EOL as of 2022-09
|
|
# https://support.apple.com/kb/sp833
|
|
# "macOS Big Sur - Technical Specifications" lists current oldest
|
|
# supported models: MacBook (2015 or later), MacBook Air (2013 or later),
|
|
# MacBook Pro (Late 2013 or later), Mac mini (2014 or later), iMac (2014
|
|
# or later), iMac Pro (2017 or later), Mac Pro (2013 or later).
|
|
#
|
|
# These all have Haswell or newer CPUs.
|
|
#
|
|
# This ensures AVX2, AES-NI, PCLMUL, BMI1, and BMI2 instruction set support.
|
|
switch("passC", "-march=haswell -mtune=generic")
|
|
switch("passL", "-march=haswell -mtune=generic")
|
|
else:
|
|
if defined(marchOptimized):
|
|
# -march=broadwell: https://github.com/status-im/nimbus-eth2/blob/stable/docs/cpu_features.md#bmi2--adx
|
|
# Changed to x86-64-v2 for broader support
|
|
switch("passC", "-march=x86-64-v2 -mtune=generic")
|
|
switch("passL", "-march=x86-64-v2 -mtune=generic")
|
|
else:
|
|
switch("passC", "-mssse3")
|
|
switch("passL", "-mssse3")
|
|
elif defined(macosx) and defined(arm64):
|
|
# Apple's Clang can't handle "-march=native" on M1: https://github.com/status-im/nimbus-eth2/issues/2758
|
|
switch("passC", "-mcpu=apple-m1")
|
|
switch("passL", "-mcpu=apple-m1")
|
|
else:
|
|
if not defined(android):
|
|
switch("passC", "-march=native")
|
|
switch("passL", "-march=native")
|
|
if defined(windows):
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
|
|
# ("-fno-asynchronous-unwind-tables" breaks Nim's exception raising, sometimes)
|
|
switch("passC", "-mno-avx512f")
|
|
switch("passL", "-mno-avx512f")
|
|
|
|
when defined(macosx):
|
|
# TEMPORARY (added 2026-06-19) — remove once nim-chronos is fixed/bumped upstream.
|
|
#
|
|
# macOS / Apple Clang 16+ promotes -Wincompatible-function-pointer-types to a
|
|
# DEFAULT error (not gated behind -Werror). It fires on a dependency↔dependency
|
|
# call in nim-chronos — none of our code is involved:
|
|
# chronos/streams/tlsstream.nim:718 ctx.setdest(itemAppend, ...)
|
|
# chronos declares the PEM callback `itemAppend(ctx, pbytes: pointer, nbytes)`
|
|
# while bearssl's `br_pem_decoder_setdest` expects `pbytes: const void*`. The
|
|
# callback only READS the buffer (copyMem from pbytes), so the missing `const`
|
|
# is benign — we demote the diagnostic back to a warning instead of failing.
|
|
#
|
|
# Why it appeared now (not a change on our side): the `const` was introduced in
|
|
# nim-bearssl v0.2.9, published 2026-06-19 11:22 UTC. CI does not honor the
|
|
# locked bearssl (nimble.lock pins 0.2.8) and fresh-resolves to latest, so any
|
|
# run after 11:22 UTC picks up 0.2.9 and hits this. Earlier-running PRs that
|
|
# resolved 0.2.8 are green only by timing; re-running them now reproduces it.
|
|
#
|
|
# Proper fix: chronos should declare `itemAppend`'s `pbytes` as `const pointer`.
|
|
switch("passC", "-Wno-error=incompatible-function-pointer-types")
|
|
|
|
--threads:
|
|
on
|
|
--opt:
|
|
speed
|
|
|
|
--excessiveStackTrace:
|
|
on
|
|
# enable metric collection
|
|
--define:
|
|
metrics
|
|
# for heap-usage-by-instance-type metrics and object base-type strings
|
|
--define:
|
|
nimTypeNames
|
|
|
|
# the default open files limit is too low on macOS (512), breaking the
|
|
# "--debugger:native" build. It can be increased with `ulimit -n 1024`.
|
|
if not defined(macosx) and not defined(android):
|
|
# add debugging symbols and original files and line numbers
|
|
--debugger:
|
|
native
|
|
when defined(enable_libbacktrace):
|
|
# light-weight stack traces using libbacktrace and libunwind
|
|
# opt-in: pass -d:enable_libbacktrace (requires libbacktrace in project deps)
|
|
--define:
|
|
nimStackTraceOverride
|
|
switch("import", "libbacktrace")
|
|
|
|
--define:
|
|
nimOldCaseObjects
|
|
# https://github.com/status-im/nim-confutils/issues/9
|
|
|
|
# `switch("warning[CaseTransition]", "off")` fails with "Error: invalid command line option: '--warning[CaseTransition]'"
|
|
switch("warning", "CaseTransition:off")
|
|
|
|
# The compiler doth protest too much, methinks, about all these cases where it can't
|
|
# do its (N)RVO pass: https://github.com/nim-lang/RFCs/issues/230
|
|
switch("warning", "ObservableStores:off")
|
|
|
|
# Too many false positives for "Warning: method has lock level <unknown>, but another method has 0 [LockLevel]"
|
|
switch("warning", "LockLevel:off")
|
|
|
|
if defined(android):
|
|
var clang = getEnv("ANDROID_COMPILER")
|
|
var ndk_home = getEnv("ANDROID_TOOLCHAIN_DIR")
|
|
var sysroot = ndk_home & "/sysroot"
|
|
var cincludes = sysroot & "/usr/include/" & getEnv("ANDROID_ARCH")
|
|
|
|
switch("clang.path", ndk_home & "/bin")
|
|
switch("clang.exe", clang)
|
|
switch("clang.linkerexe", clang)
|
|
switch("passC", "--sysroot=" & sysRoot)
|
|
switch("passL", "--sysroot=" & sysRoot)
|
|
switch("cincludes", sysRoot & "/usr/include/")
|
|
|
|
# begin Nimble config (version 2)
|
|
--noNimblePath
|
|
when withDir(thisDir(), system.fileExists("nimble.paths")):
|
|
include "nimble.paths"
|
|
# end Nimble config
|