mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-09 12:35:51 +00:00
2b3195518d
Main goal is to update the nim-codex CI workflow to use the [`msys2/setup-msys2@v2`][setmsys2] GitHub Action, as used by the [nimbus-eth2 workflow][ne2w] per changes made to it several months ago. The `msys2/setup-msys2@v2` action has been used by other Status-org projects prior to this commit, e.g. nim-leopard, nim-datastore, nim-status. A fix is included for the failing macOS builds, related to [actions/virtual-environments#5819][ave5819]. See [L151][L151]. All builds [succeed][succeed] (with build arch-targets verified as far as possible via `ldd`, `otool`, `ntldd`), including `linux-i386` and `windows-i386`, though the `i386` builds are presently disabled (commented out). The `i386` builds can be enabled simply by uncommenting: ``` # - os: linux # cpu: i386 ... # - os: windows # cpu: i386 ``` The resulting `.github/workflows/ci.yml` is a "remix" of the current workflows for nimbus-eth2 and nim-codex (i.e. prior to this commit) along with techniques learned from developing workflows for other Status-org repos. Some comments and code-reorg help to clarify/explain what's done in the `Derive environment variables` step. `-d:limitStackUsage` has been adopted for `linux-amd64` builds from [nimbus-eth2's workflow][ne2wL155] and [related code][ne2config] has been copied into `config.nims` `-d:limitStackUsage` can easily be dropped if it's not desirable for Codex. Build targets use `-latest` for `runs-on`, i.e. `macos-latest`, `ubuntu-latest`, `windows-latest`. Through a combination of local testing and iterative pushes to GitHub, the workflow's embedded Bash scripts have been revised to include only the necessary steps for all builds to succeed, including `linux-i386` and `windows-i386`. The GitHub Actions workflow `.github/workflows/codecov.yml` has been removed, while coverage data generation/upload steps have been added to `.github/workflows/ci.yml` as the final steps conditional on `if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' && matrix.nim_branch == matrix.cov_branch`. A redundant `--passC:'-m32 -mno-adx'` is used for `linux-i386` builds; the redundant flags do not affect the build, but can be helpful when eyeballing GitHub Actions builds with increased compile-time verbosity. Some variable expansions used in `github/workflows/ci.yml` could result in compilation failures if related paths include whitespace. It's not a problem for this commit but could be a problem for a user copy-pasting from the workflow; solving that problem is left as an exercise for the reader. [setmsys2]: https://github.com/msys2/setup-msys2#readme [ne2w]: https://github.com/status-im/nimbus-eth2/blob/stable/.github/workflows/ci.yml [ave5819]: https://github.com/actions/virtual-environments/pull/5819 [L151]: https://github.com/status-im/nim-codex/blob/ci/msys2/.github/workflows/ci.yml#L151 [succeed]: https://github.com/status-im/nim-codex/actions/runs/2606854455 [ne2wL155]: https://github.com/status-im/nimbus-eth2/blob/stable/.github/workflows/ci.yml#L155-L159 [ne2config]: https://github.com/status-im/nimbus-eth2/blob/stable/config.nims#L43-L49
97 lines
4.1 KiB
Nim
97 lines
4.1 KiB
Nim
import std/os
|
|
|
|
if defined(release):
|
|
switch("nimcache", joinPath(currentSourcePath.parentDir, "nimcache/release/$projectName"))
|
|
else:
|
|
switch("nimcache", joinPath(currentSourcePath.parentDir, "nimcache/debug/$projectName"))
|
|
|
|
if defined(limitStackUsage):
|
|
# This limits stack usage of each individual function to 1MB - the option is
|
|
# available on some GCC versions but not all - run with `-d:limitStackUsage`
|
|
# and look for .su files in "./build/", "./nimcache/" or $TMPDIR that list the
|
|
# stack size of each function.
|
|
switch("passC", "-fstack-usage -Werror=stack-usage=1048576")
|
|
switch("passL", "-fstack-usage -Werror=stack-usage=1048576")
|
|
|
|
if defined(windows):
|
|
# https://github.com/nim-lang/Nim/pull/19891
|
|
switch("define", "nimRawSetjmp")
|
|
|
|
# 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")
|
|
|
|
# The dynamic Chronicles output currently prevents us from using colors on Windows
|
|
# because these require direct manipulations of the stdout File object.
|
|
switch("define", "chronicles_colors=off")
|
|
|
|
# This helps especially for 32-bit x86, which sans SSE2 and newer instructions
|
|
# requires quite roundabout code generation for cryptography, and other 64-bit
|
|
# and larger arithmetic use cases, along with register starvation issues. When
|
|
# engineering a more portable binary release, this should be tweaked but still
|
|
# use at least -msse2 or -msse3.
|
|
|
|
if defined(disableMarchNative):
|
|
if defined(i386) or defined(amd64):
|
|
switch("passC", "-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-a14")
|
|
# TODO: newer Clang >=15.0 can: https://github.com/llvm/llvm-project/commit/fcca10c69aaab539962d10fcc59a5f074b73b0de
|
|
else:
|
|
switch("passC", "-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-avx512vl")
|
|
|
|
--tlsEmulation:off
|
|
--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
|
|
|
|
switch("define", "withoutPCRE")
|
|
|
|
# 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):
|
|
# add debugging symbols and original files and line numbers
|
|
--debugger:native
|
|
if not (defined(windows) and defined(i386)) and not defined(disable_libbacktrace):
|
|
# light-weight stack traces using libbacktrace and libunwind
|
|
--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")
|
|
|
|
switch("define", "libp2p_pki_schemes=secp256k1")
|
|
#TODO this infects everything in this folder, ideally it would only
|
|
# apply to codex.nim, but since codex.nims is used for other purpose
|
|
# we can't use it. And codex.cfg doesn't work
|
|
switch("define", "chronicles_sinks=textlines[dynamic],json[dynamic]")
|
|
|
|
# begin Nimble config (version 1)
|
|
when system.fileExists("nimble.paths"):
|
|
include "nimble.paths"
|
|
# end Nimble config
|