Coder Social home page Coder Social logo

编译时报错:除以0 about yacl HOT 14 CLOSED

links-zhang avatar links-zhang commented on September 21, 2024
编译时报错:除以0

from yacl.

Comments (14)

anakinxc avatar anakinxc commented on September 21, 2024

Hi @Francis-zlh

能提供一下具体的 repro steps 吗

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

links@links-virtual-machine:~/yacl/yacl-main$ bazel build //... -c opt
Starting local Bazel server and connecting to it...
INFO: Analyzed 218 targets (110 packages loaded, 9500 targets configured).
INFO: Found 218 targets...
ERROR: /home/links/yacl/yacl-main/yacl/crypto/utils/BUILD.bazel:19:16: Compiling yacl/crypto/utils/rand.cc failed: (Exit 1): gcc failed: error executing command (from target //yacl/crypto/utils:rand) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 46 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from ./yacl/crypto/utils/rand.h:27,
from yacl/crypto/utils/rand.cc:15:
./yacl/base/dynamic_bitset.h: In instantiation of 'constexpr yacl::dynamic_bitset<Block, Allocator>::dynamic_bitset(yacl::dynamic_bitset<Block, Allocator>::size_type, uint128_t, const allocator_type&) [with Block = __int128 unsigned; Allocator = std::allocator<__int128 unsigned>; yacl::dynamic_bitset<Block, Allocator>::size_type = long unsigned int; uint128_t = __int128 unsigned; yacl::dynamic_bitset<Block, Allocator>::allocator_type = std::allocator<__int128 unsigned>]':
yacl/crypto/utils/rand.cc:156:1: required from here
./yacl/base/dynamic_bitset.h:2294:20: error: division by zero is not a constant expression
2294 | constexpr size_t init_val_required_blocks = u128_bits_number/bits_per_block;
| ^~~~~~~~~~~~~~~~~~~~~~~~
INFO: Elapsed time: 20.630s, Critical Path: 13.60s
INFO: 13 processes: 13 internal.
FAILED: Build did NOT complete successfully

我尝试过把static constexpr size_type bits_per_block = std::numeric_limits<block_type>::digits;修改为
static constexpr size_type bits_per_block = 128;之后编译成功,并且tpre_test可以正常运行

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

麻烦提供一下 gcc 版本

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

使用过13.2.0和10.3.0均报错

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

我们目前用的 11.2~11.4,你试一下

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

inks@links-virtual-machine:/yacl/yacl-main$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/11.4.0/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
线程模型:posix
Supported LTO compression algorithms: zlib
gcc 版本 11.4.0 (GCC)
links@links-virtual-machine:
/yacl/yacl-main$ bazel build //... -c opt
INFO: Analyzed 218 targets (0 packages loaded, 0 targets configured).
INFO: Found 218 targets...
ERROR: /home/links/yacl/yacl-main/yacl/crypto/utils/BUILD.bazel:19:16: Compiling yacl/crypto/utils/rand.cc failed: (Exit 1): gcc failed: error executing command (from target //yacl/crypto/utils:rand) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 46 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from ./yacl/crypto/utils/rand.h:27,
from yacl/crypto/utils/rand.cc:15:
./yacl/base/dynamic_bitset.h: In instantiation of 'constexpr yacl::dynamic_bitset<Block, Allocator>::dynamic_bitset(yacl::dynamic_bitset<Block, Allocator>::size_type, uint128_t, const allocator_type&) [with Block = __int128 unsigned; Allocator = std::allocator<__int128 unsigned>; yacl::dynamic_bitset<Block, Allocator>::size_type = long unsigned int; uint128_t = __int128 unsigned; yacl::dynamic_bitset<Block, Allocator>::allocator_type = std::allocator<__int128 unsigned>]':
yacl/crypto/utils/rand.cc:156:1: required from here
./yacl/base/dynamic_bitset.h:2295:20: error: division by zero is not a constant expression
2295 | constexpr size_t init_val_required_blocks = u128_bits_number/bits_per_block;
| ^~~~~~~~~~~~~~~~~~~~~~~~
INFO: Elapsed time: 10.391s, Critical Path: 9.09s
INFO: 13 processes: 13 internal.
FAILED: Build did NOT complete successfully

我更换了gcc11.4以后依然有这个问题😂

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

Interesting, 请问一下你的 OS 信息还有 gcc 是怎么安装的

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

我不太明白OS信息是如何安装的,gcc是通过下载gcc的release后通过下述命令安装
./contrib/download_prerequisites
./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
make
make install

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

这是我GCC下载来源https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-11.4.0

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

就是你 linux 用的是哪个发行版?比如 Ubuntu 22.04, Centos 8 这样

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

ubuntu 20.04

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

请用包管理器来安装 gcc

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11  --slave /usr/bin/cpp cpp /usr/bin/cpp-11;

然后确定一下

gcc -v

返回的是 11

from yacl.

links-zhang avatar links-zhang commented on September 21, 2024

非常感谢您的帮助,现在已经编译成功。
--slave /usr/bin/cpp cpp /usr/bin/cpp-11应该要和其他的命令分开使用,否则会报错
还是gcc的版本的问题,但是不懂为什么release的不行😂
再次感谢您的帮助!

from yacl.

anakinxc avatar anakinxc commented on September 21, 2024

非常感谢您的帮助,现在已经编译成功。 --slave /usr/bin/cpp cpp /usr/bin/cpp-11应该要和其他的命令分开使用,否则会报错 还是gcc的版本的问题,但是不懂为什么release的不行😂 再次感谢您的帮助!

自己编译 gcc 容易缺东西,比如 libstdc++ 之类的

from yacl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.