0

I use the substrate-developer-hub/substrate-node-template version: polkadot-v0.9.26 for practice.

When I run cargo build --release

I got error:
invalid output constraint '=@ccz' in asm : [tag_type] "+r"(tag_type), "=@ccz"(is_literal));

details:

Building [=======================> ] 954/964: librocksdb-sys(build)

The following warnings were emitted during compilation:

warning: snappy/snappy.cc:1033:36: error: invalid output constraint '=@ccz' in asm warning: : [tag_type] "+r"(tag_type), "=@ccz"(is_literal)); warning: ^ warning: 1 error generated.

error: failed to run custom build command for librocksdb-sys v0.6.1+6.28.2

Caused by:

CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,llvm14-builtins-abi,sse,sse2,sse3,ssse3") running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "snappy/" "-I" "." "-Wall" "-std=c++11" "-DNDEBUG=1" "-o" "/Users/anweshnayak/Documents/projects/polkadot/parity/substrate-dev-hub/substrate-node-template/target/release/build/librocksdb-sys-0e318981b983f350/out/snappy/snappy-sinksource.o" "-c" "snappy/snappy-sinksource.cc" running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "snappy/" "-I" "." "-Wall" "-std=c++11" "-DNDEBUG=1" "-o" "/Users/anweshnayak/Documents/projects/polkadot/parity/substrate-dev-hub/substrate-node-template/target/release/build/librocksdb-sys-0e318981b983f350/out/snappy/snappy.o" "-c" "snappy/snappy.cc" running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "snappy/" "-I" "." "-Wall" "-std=c++11" "-DNDEBUG=1" "-o" "/Users/anweshnayak/Documents/projects/polkadot/parity/substrate-dev-hub/substrate-node-template/target/release/build/librocksdb-sys-0e318981b983f350/out/snappy/snappy-c.o" "-c" "snappy/snappy-c.cc" exit status: 0 exit status: 0 cargo:warning=snappy/snappy.cc:1033:36: error: invalid output constraint '=@ccz' in asm cargo:warning= : [tag_type] "+r"(tag_type), "=@ccz"(is_literal)); cargo:warning= ^ cargo:warning=1 error generated. exit status: 1

--- stderr

error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "snappy/" "-I" "." "-Wall" "-std=c++11" "-DNDEBUG=1" "-o" "/Users/anweshnayak/Documents/projects/polkadot/parity/substrate-dev-hub/substrate-node-template/target/release/build/librocksdb-sys-0e318981b983f350/out/snappy/snappy.o" "-c" "snappy/snappy.cc" with args "c++" did not execute successfully (status code exit status: 1).

My MacOS version: 10.15.1

 cmake --version
cmake version 3.24.1

 clang --version
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0

 lldb --version
lldb-1100.0.30.6
Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)

 gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

 g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin


rustup show:

installed toolchains
--------------------

stable-x86_64-apple-darwin (default)
nightly-2021-01-13-x86_64-apple-darwin
nightly-2021-09-08-x86_64-apple-darwin
nightly-x86_64-apple-darwin

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-apple-darwin

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.63.0 (4b91a6ea7 2022-08-08)

Last time when I practised the node-template, I downloaded the node-template, 4.0.0-dev, branch = "polkadot-v0.9.17". It's ok.

3

2 Answers 2

0

I search for half a day. From here and here I got some information.

I find the exact file of librocksdb-sys-0.6.1+6.28.2/snappy/snappy.cc in the help of CLion IDE, which is referenced by the current node-template project, and change the piece of code:

#if defined(__GNUC__) && defined(__x86_64__)    // delete
#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)   // add this line, change the '__GNUC__' to '__GCC_ASM_FLAG_OUTPUTS__'
  // TODO clang misses the fact that the (c & 3) already correctly
  // sets the zero flag.
  asm("and $3, %k[tag_type]\n\t"
      : [tag_type] "+r"(tag_type), "=@ccz"(is_literal));

It seems that librocksdb reference the snappy by the source code. I directly change the code as per the solution here. Then compile the node-template code, it is successful.

Another way is updating clang to version >=12

1
  • 1
    IMHO, it's a bad idea by modifying the source code, which is stored in the ~/.cargo. You might forget that later. And cargo clean can not touch that part. In the Cargo.lock other people will see you are still using that version. But in fact, you are using a different code. I still recommend you to upgrade the macOS/clang. Sep 9, 2022 at 3:20
0

To update c++ command line in Ubuntu 18.04

sudo apt-get install build-essential clang curl git make git clang curl libssl-dev llvm libudev-dev make protobuf-compiler make clang -y
$ c++ --version 

c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.