Bug 1824365 - On x86_64, clang detects the wrong gcc directory
Summary: On x86_64, clang detects the wrong gcc directory
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: clang
Version: 33
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-16 02:38 UTC by Hin-Tak Leung
Modified: 2020-11-12 03:06 UTC (History)
7 users (show)

Fixed In Version: clang-11.0.0-2.fc33
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1749971
Environment:
Last Closed: 2020-11-12 03:06:17 UTC
Type: Bug


Attachments (Terms of Use)

Description Hin-Tak Leung 2020-04-16 02:38:22 UTC
Have exact same problem on fedora 31, as it was in bug 1749971 on fedora 30 - and surprised that the fixed was not carried over.

Versions:
$ rpm -q gcc-x86_64-linux-gnu
gcc-x86_64-linux-gnu-9.2.1-1.fc31.x86_64
$ rpm -q clang
clang-9.0.1-2.fc31.x86_64



+++ This bug was initially created as a clone of Bug #1749971 +++

Description of problem:

    When clang is supposed to natively link a C program, it picks the gcc installation in /usr/lib/gcc/x86_64-linux-gnu/9 instead of the one in /usr/lib/gcc/x86_64-redhat-linux/9 and fails with "/usr/bin/ld: cannot find -lgcc_s" instead of producing a native executable.

Version-Release number of selected component (if applicable):

    clang-8.0.0-1.fc30.x86_64

    with the following two packages installed

    gcc-9.2.1-1.fc30.x86_64
    gcc-x86_64-linux-gnu-9.1.1-1.fc30.x86_64

How reproducible:

    100%

Steps to Reproduce:
1. dnf -y install clang
2. clang -o basic-main basic-main.c # this works
3. dnf -y install gcc-x86_64-linux-gnu
4. clang -o basic-main basic-main.c # this fails

Actual results:

    /usr/bin/ld: cannot find -lgcc_s
    clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

Expected results:

    No error message, and an executable file to run natively.

Additional info:

### The basic C code example file basic-main.c ###

    #include <stdio.h>

    int main(void)
    {
      printf("basic main program\n");
      return 0;
    }

### The error case with "clang -v -o basic-main basic-main.c" ###

clang version 8.0.0 (Fedora 8.0.0-1.fc30)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name basic-main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib64/clang/8.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/8.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/ndim/clang-and-gcc-bug -ferror-limit 19 -fmessage-length 118 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/basic-main-606e4c.o -x c basic-main.c -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib64/clang/8.0.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o basic-main /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/basic-main-606e4c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/9/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../lib64/crtn.o
/usr/bin/ld: cannot find -lgcc_s
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

### The success case with "clang -v -o basic-main basic-main.c" ###

clang version 8.0.0 (Fedora 8.0.0-1.fc30)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-8" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name basic-main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib64/clang/8.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/8.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/ndim/clang-and-gcc-bug -ferror-limit 19 -fmessage-length 118 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/basic-main-aabab6.o -x c basic-main.c -faddrsig
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib64/clang/8.0.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o basic-main /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/9/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-redhat-linux/9 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/basic-main-aabab6.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-redhat-linux/9/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crtn.o

--- Additional comment from Tom Stellard on 2019-09-07 04:21:39 UTC ---

Pull request: https://src.fedoraproject.org/rpms/clang/pull-request/40

--- Additional comment from Fedora Update System on 2019-09-26 00:10:33 UTC ---

FEDORA-2019-30920cc6e1 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-30920cc6e1

--- Additional comment from Fedora Update System on 2019-09-27 02:18:48 UTC ---

clang-8.0.0-3.fc30, llvm-test-suite-8.0.0-3.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-30920cc6e1

--- Additional comment from Fedora Update System on 2019-10-04 21:24:09 UTC ---

clang-8.0.0-3.fc30, llvm-test-suite-8.0.0-3.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 1 Hin-Tak Leung 2020-04-16 02:42:16 UTC
In addition, c++ include path is also screwed up:

$ clang++ -v  oclang/test.cpp
clang version 9.0.1 (Fedora 9.0.1-2.fc31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-redhat-linux/9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib64/clang/9.0.1 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-unknown-linux-gnu/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/Hin-Tak/git-others/osxcross-up -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o /tmp/test-f742da.o -x c++ oclang/test.cpp
clang -cc1 version 9.0.1 based upon LLVM 9.0.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-unknown-linux-gnu/c++/9"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9
 /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward
 /usr/local/include
 /usr/lib64/clang/9.0.1/include
 /usr/include
End of search list.
In file included from oclang/test.cpp:1:
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iostream:38:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>
         ^~~~~~~~~~~~~~~~~~
1 error generated.

Comment 2 Hin-Tak Leung 2020-04-16 02:43:27 UTC
The fc30 fix needs to go into fc31 (and possibly fc32, etc too).

Comment 3 Fedora Update System 2020-09-14 08:47:22 UTC
FEDORA-2020-3a2812cd4d has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-3a2812cd4d

Comment 4 Fedora Update System 2020-09-14 14:09:51 UTC
FEDORA-2020-3a2812cd4d has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-3a2812cd4d`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-3a2812cd4d

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2020-10-31 02:01:40 UTC
FEDORA-2020-3a2812cd4d has been pushed to the Fedora 31 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Ben Cotton 2020-11-03 16:36:39 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Hans Ulrich Niedermann 2020-11-06 15:04:29 UTC
Just verified the bug persists on Fedora 33 with the following package versions:

    clang-11.0.0-1.fc33.x86_64
    gcc-x86_64-linux-gnu-10.2.1-3.fc33.x86_64

Comment 8 Fedora Update System 2020-11-09 14:34:01 UTC
FEDORA-2020-7987e5f6e1 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-7987e5f6e1

Comment 9 serge_sans_paille 2020-11-09 14:37:10 UTC
Hans, can you confirm https://bodhi.fedoraproject.org/updates/FEDORA-2020-7987e5f6e1 fixes the issue?

Comment 10 Hans Ulrich Niedermann 2020-11-10 16:09:49 UTC
(In reply to serge_sans_paille from comment #9)
> Hans, can you confirm
> https://bodhi.fedoraproject.org/updates/FEDORA-2020-7987e5f6e1 fixes the
> issue?

Serge, yes, that fixes the issue (and for some reason, I cannot give it a thumbs up in the bodhi web interface).

BTW, should I pre-file the same issue for F34, as we can apparently expect it to re-occur? :-)

Comment 11 Fedora Update System 2020-11-12 03:06:17 UTC
FEDORA-2020-7987e5f6e1 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.


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