AztecProtocol / aztec-packages

Apache License 2.0
195 stars 206 forks source link

Building BB fails with `fatal error: inline assembly requires more registers than available` #8343

Open koxu1996 opened 2 months ago

koxu1996 commented 2 months ago

NOTE: This might be related to #8341, as I had to remove assert that failed to compile.

I am building BB with:

cd ./aztec-packages/barretenberg/cpp/
cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert
cmake --build --preset default --target bb

It fails on ASM:

FAILED: src/barretenberg/eccvm/CMakeFiles/eccvm_objects.dir/eccvm_verifier.cpp.o
/usr/bin/clang++ -DNO_OMP_MULTITHREADING -DNO_TBB -I/home/andrew/aztec/aztec-packages/barretenberg/cpp/src -I/home/andrew/aztec/aztec-packages/barretenberg/cpp/build/_deps/msgpack-c/src/msgpack-c/include -I/home/andrew/aztec/aztec-packages/barretenberg/cpp/build/_deps/tracy-src/public -std=gnu++20 -fbracket-depth=1024 -O3 -march=skylake -pthread -Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wfatal-errors -fcolor-diagnostics -fconstexpr-steps=100000000 -Wno-vla-cxx-extension -MD -MT src/barretenberg/eccvm/CMakeFiles/eccvm_objects.dir/eccvm_verifier.cpp.o -MF src/barretenberg/eccvm/CMakeFiles/eccvm_objects.dir/eccvm_verifier.cpp.o.d -o src/barretenberg/eccvm/CMakeFiles/eccvm_objects.dir/eccvm_verifier.cpp.o -c /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp:1:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/eccvm/./eccvm_verifier.hpp:2:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp:2:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp:2:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp:3:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp:11:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp:3:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/./runtime_states.hpp:3:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp:2:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/../bn254/fq.hpp:6:
In file included from /home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/../bn254/../../fields/field.hpp:10:
/home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/../bn254/../../fields/./field_impl_x64.hpp:29:13: fatal error: inline assembly requires more registers than available
   29 |     __asm__(MUL("0(%0)", "8(%0)", "16(%0)", "24(%0)", "%1")
      |             ^
/home/andrew/aztec/aztec-packages/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/../bn254/../../fields/./asm_macros.hpp:654:9: note: expanded from macro 'MUL'
  654 |         "movq " a1 ", %%rdx                        \n\t" /* load a[0] into %rdx                                     */  \
      |         ^
1 error generated.
koxu1996 commented 2 months ago

As a temporary workaround I disabled ASM:

diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json
index da2154687a..8337e12488 100644
--- a/barretenberg/cpp/CMakePresets.json
+++ b/barretenberg/cpp/CMakePresets.json
@@ -18,7 +18,8 @@
         "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
       },
       "cacheVariables": {
-        "TARGET_ARCH": "skylake"
+        "TARGET_ARCH": "skylake",
+        "DISABLE_ASM": "ON"
       }
     },
     {