Giter Site home page Giter Site logo

Comments (4)

fish2bird avatar fish2bird commented on May 7, 2024 2

我用简单的尝试了下, 同样的 configure 参数, gcc9及以前都是直接展开了原子指令, 但是 gcc 10 起使用了函数调用,除非开启 -mno-outline-atomics

https://godbolt.org/z/z8W7z1cqx

不过发现并不需要显式链接静态库, 这应该是我的环境有多个 gcc ,搞混了导致, 也就是这个 BUILD 补丁是不必要的

网上类似问题 cloudius-systems/osv#1129

from flare.

0x804d8000 avatar 0x804d8000 commented on May 7, 2024

这个gcc是自己编译的吗?

印象里atomic的实现方式有两种,一种是直接生成ll/sc,一种是用libatomic(这个性能略差),具体选择哪个可能跟gcc的configure的参数有关。

centos8 aarch64带的gcc我记得应该是不用链接libatomic的。你可以看下你的环境的gcc是不是配置有什么不一样的地方。

from flare.

fish2bird avatar fish2bird commented on May 7, 2024

这个gcc是自己编译的吗?

印象里atomic的实现方式有两种,一种是直接生成ll/sc,一种是用libatomic(这个性能略差),具体选择哪个可能跟gcc的configure的参数有关。

centos8 aarch64带的gcc我记得应该是不用链接libatomic的。你可以看下你的环境的gcc是不是配置有什么不一样的地方。

是自己构建的,环境为 glibc 2.28 请看看是否正常

Using built-in specs.
COLLECT_GCC=/***/gcc-11.3.0/bin/gcc
COLLECT_LTO_WRAPPER=/***/gcc-11.3.0/libexec/gcc/aarch64-redhat-linux/11.3.0/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ./configure --prefix=/***/gcc-11.3.0 --build=aarch64-redhat-linux --enable-threads=posix --enable-multiarch --disable-checking --enable-long-long --disable-multilib --enable-languages=c,c++,fortran --with-mpc=/***/mpc-1.2.1 --with-gmp=/***/gmp-6.2.1 --with-mpfr=/***/mpfr-4.1.0
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.3.0 (GCC)

from flare.

0x804d8000 avatar 0x804d8000 commented on May 7, 2024

看起来没什么明显的问题。

我手上现在没有aarch64的环境,但是有这么一些想法:

  • 可以尝试直接编译一个简单的、使用了std::atomic的代码,看看反汇编是不是直接生成了ldrex/strex或其他的类似的原子指令。是的话则不需要libatomic。我看godbolt上面的arm-gcc是这样的。
  • 可以尝试编译gcc时configure的时候指定--disable-libatomic看看有没有区别。
  • 可以尝试给gcc指定不同的-march看看会不会影响原子操作的codegen,有可能默认target到了某个很老的ISA,让gcc不得不依赖libatomic来实现原子操作。

from flare.

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.