Bug 2127370 - Missing gcc-toolset-12-libatomic-devel package breaks compilation with clang -latomic
Summary: Missing gcc-toolset-12-libatomic-devel package breaks compilation with clang ...
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc-toolset-12
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Marek Polacek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-16 07:21 UTC by Frantisek Sumsal
Modified: 2023-07-18 14:19 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-09-19 15:59:35 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-134145 0 None None None 2022-09-16 07:27:09 UTC

Description Frantisek Sumsal 2022-09-16 07:21:26 UTC
Description of problem:
In current C8S there's no gcc-toolset-12-libatomic-devel package, which seems to break building stuff with clang when using -latomic. There are such packages for older gcc versions:

gcc-toolset-10-libatomic-devel.ppc64le : The GNU Atomic static library
gcc-toolset-11-libatomic-devel.ppc64le : The GNU Atomic static library
gcc-toolset-9-libatomic-devel.ppc64le : The GNU Atomic static library

but the latest C8S clang depends on gcc-toolset-12.

Downgrading clang to clang-14.0.0-1.module_el8.7.0+1142+5343df54.x86_64 seems to help, as it seems to depends on older gcc/gcc-toolset.

I'm not sure which side to blame here, so apologies in advance if I picked the wrong one.

Version-Release number of selected component (if applicable):
gcc-toolset-12-gcc-12.1.1-3.2.el8.x86_64
clang-14.0.6-1.module_el8.7.0+1198+0c3eb6e2.x86_64
libatomic-8.5.0-15.el8.x86_64

How reproducible:
Always

Steps to Reproduce:
# dnf install clang libatomic
# cat >main.c <<EOF
#include <stdint.h>

int main() {
    char i;
    __atomic_exchange_1(&i, 1, 0);
    return 1;
}
EOF
# clang -o main main.c -latomic

Actual results:
## clang-14.0.6-1.module_el8.7.0+1198+0c3eb6e2.x86_64
# clang -o main main.c -latomic
main.c:5:4: warning: implicit declaration of function '__atomic_exchange_1' is invalid in C99 [-Wimplicit-function-declaration]
        __atomic_exchange_1(&i, 1, 0);
        ^
1 warning generated.
/usr/bin/ld: cannot find -latomic
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)


Expected results:
## clang-14.0.0-1.module_el8.7.0+1142+5343df54.x86_64
# clang -o main main.c -latomic
main.c:5:4: warning: implicit declaration of function '__atomic_exchange_1' is invalid in C99 [-Wimplicit-function-declaration]
        __atomic_exchange_1(&i, 1, 0);
        ^
1 warning generated.
# echo $?
0

Additional info:
## clang-14.0.6-1.module_el8.7.0+1198+0c3eb6e2.x86_64
# strace -f -e openat -- clang -o main main.c -latomic |& grep libatomic.so
[pid   267] openat(AT_FDCWD, "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "/lib/../lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "/usr/lib/../lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "/lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "/usr/lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/x86_64-redhat-linux/lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/local/lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//lib64/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/x86_64-redhat-linux/lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/local/lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   267] openat(AT_FDCWD, "//usr/lib/libatomic.so", O_RDONLY) = -1 ENOENT (No such file or directory)

## clang-14.0.0-1.module_el8.7.0+1142+5343df54.x86_64
# strace -f -e openat -- clang -o main main.c -latomic |& grep libatomic.so
[pid   318] openat(AT_FDCWD, "/usr/bin/../lib/gcc/x86_64-redhat-linux/8/libatomic.so", O_RDONLY) = 8
[pid   318] openat(AT_FDCWD, "/usr/bin/../lib/gcc/x86_64-redhat-linux/8/libatomic.so", O_RDONLY) = 9
[pid   318] openat(AT_FDCWD, "/usr/bin/../lib/gcc/x86_64-redhat-linux/8/libatomic.so", O_RDONLY) = 8
[pid   318] openat(AT_FDCWD, "/usr/lib64/libatomic.so.1.2.0", O_RDONLY) = 8

Comment 1 Marek Polacek 2022-09-19 15:59:35 UTC
Thanks for the report.  I didn't stop building gcc-toolset-12-libatomic-devel -- it's still built in Brew:
https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=2081394
and I see it's here as well:
http://download-node-02.eng.bos.redhat.com/nightly/latest-RHEL-8/compose/AppStream/x86_64/os/Packages/
but that's not going to help you, because this ticket is about CentOS.

I've opened <https://issues.redhat.com/browse/CS-1231>; hopefully the CentOS team can address the issue there.

Closing this as CANTFIX because I've already built the package.


Note You need to log in before you can comment on or make changes to this bug.