Bug 2127370

Summary: Missing gcc-toolset-12-libatomic-devel package breaks compilation with clang -latomic
Product: Red Hat Enterprise Linux 8 Reporter: Frantisek Sumsal <fsumsal>
Component: gcc-toolset-12Assignee: Marek Polacek <mpolacek>
Status: CLOSED CANTFIX QA Contact: qe-baseos-tools-bugs
Severity: high Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bstinson, jcaratza, jwboyer
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-19 15:59:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.