mratsim / constantine

Constantine: modular, high-performance, zero-dependency cryptography stack for verifiable computation, proof systems and blockchain protocols.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Disabling intel assembly causes undefined symbols

benbierens opened this issue · comments

Seen in project codex-storage/nim-codex.
We set use_asm_syntax_intel=false for compatibility with secp256k1. This causes undefined symbols 'u' and 'x'. We are working around it by disabling assembly entirely.
image

I can't reproduce in branch gcc-asm which default for testing to LTO = false and AT&T assembly:

proc releaseBuildOptions(useLTO = false): string =
let compiler = if existsEnv"CC": " --cc:" & getEnv"CC"
else: ""
let (useAsmIfAble, force32) = getEnvVars()
let envASM = if not useAsmIfAble: " -d:CTT_ASM=false "
else: ""
let env32 = if force32: " -d:CTT_32 "
else: ""
let lto = if useLTO: " --passC:-flto=auto --passL:-flto=auto "
else: ""
let lto_syntax = if useLTO: " -d:UseAsmSyntaxIntel=true "
else: " -d:UseAsmSyntaxIntel=false "

CI job: https://github.com/mratsim/constantine/actions/runs/6990069731/job/19019218914

Furthermore your screenshot mentions line 303 of limbs_asm_modular_x86 but that file only has 282 lines:

func negmod_asm*(r: var Limbs, a, M: Limbs) =
## Constant-time modular negation
negmod_gen(r, a, M)

Even going back to when this file was created in April 2022, line 303 was behind when isMainModule and so wouldn't create an error:

func negmod_asm*(r: var Limbs, a, m: Limbs) =
## Constant-time modular negation
negmod_gen(r, a, m)
# Sanity checks
# ----------------------------------------------------------
when isMainModule:
import ../../config/type_bigint, algorithm, strutils
proc mainAdd() =
var a = [SecretWord 0xE3DF60E8F6D0AF9A'u64, SecretWord 0x7B2665C2258A7625'u64, SecretWord 0x68FC9A1D0977C8E0'u64, SecretWord 0xF3DC61ED7DE76883'u64]
var b = [SecretWord 0x78E9C2EF58BB6B78'u64, SecretWord 0x547F65BD19014254'u64, SecretWord 0x556A115819EAD4B5'u64, SecretWord 0x8CA844A546935DC3'u64]
var m = [SecretWord 0xFFFFFFFF00000001'u64, SecretWord 0x0000000000000000'u64, SecretWord 0x00000000FFFFFFFF'u64, SecretWord 0xFFFFFFFFFFFFFFFF'u64]
var s = "0x5cc923d94f8c1b11cfa5cb7f3e8bb879be66ab7423629d968084a692c47ac647"
a.reverse()
b.reverse()
m.reverse()