Bug 1943738

Summary: clang 12 with %{build_cflags} armv7hl: segmentation fault
Product: [Fedora] Fedora Reporter: Jun Aruga <jaruga>
Component: clangAssignee: Tom Stellard <tstellar>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: airlied, evan, robinlee.sysu, sbergman, sguelton, siddharth.kde, tstellar
Target Milestone: ---   
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: 2021-04-10 00:54: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:
Attachments:
Description Flags
root.log
none
build.log none

Description Jun Aruga 2021-03-26 23:55:41 UTC
Description of problem:

The clang 12.0.0-0.7.rc3.fc35 armv7hl has segmentation fault.

On a simple spec file to build with %{build_cflags} flags,

```
cat > test.c <<EOF
int main(void) {
    return 0;
}
EOF

%global toolchain clang
clang test.c -o test %{build_cflags}
```

I see the segmentation fault on armv7hl.

```
+ clang test.c -o test -O2 -flto -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard
clang-12: error: unable to execute command: Segmentation fault (core dumped)
clang-12: error: linker command failed due to signal (use -v to see invocation)
```

Version-Release number of selected component (if applicable):
clang-12.0.0-0.7.rc3.fc35

How reproducible:

I prepared the reproducer here.
https://github.com/junaruga/report-clang-12-with-flags-arm32-error

Steps to Reproduce:
1. git clone https://github.com/junaruga/report-clang-12-with-flags-arm32-error.git
2. cd report-clang-12-with-flags-arm32-error 
3. fedpkg --release rawhide srpm
4. koji build --scratch --nowait rawhide test-1-1.fc35.src.rpm
5. See the result armv7hl https://koji.fedoraproject.org/koji/taskinfo?taskID=64660466 .

Actual results:
clang-12: error: unable to execute command: Segmentation fault (core dumped)

Expected results:
The build finishes without error.

Additional info:

I think adding a simple test to test `%global toolchain clang` + `%{build_cflags}` to %check section in clang.spec could be good to avoid this in the future if `clang.spec` does not have it.

Comment 1 Jun Aruga 2021-03-26 23:58:06 UTC
Created attachment 1766803 [details]
root.log

Comment 2 Jun Aruga 2021-03-26 23:58:31 UTC
Created attachment 1766804 [details]
build.log

Comment 3 Tom Stellard 2021-04-10 00:54:35 UTC

*** This bug has been marked as a duplicate of bug 1918924 ***

Comment 4 Jun Aruga 2021-04-14 04:48:43 UTC
Thanks! I was able to avoid this issue by following this way.
https://bugzilla.redhat.com/show_bug.cgi?id=1918924#c3

I checked the ticket 1918924 when I checked clang's current issues at that time. But I misunderstand I already set `%global _lto_cflags %{nil}` for my spec file.
So, I thought it might be different issue from the ticket.