Bug 2239046

Summary: Output of clang++ -print-search-dirs is different on clang 17, breaks Firefox build
Product: [Fedora] Fedora Reporter: Adam Williamson (Red Hat non-Fedora) <awilliam>
Component: clangAssignee: Tom Stellard <tstellar>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 39CC: airlied, jchecahi, kkleine, npopov, sbergman, sergesanspaille, siddharth.kde, stransky, tbaeder, tstellar, tuliom
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-15 17:22:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Williamson (Red Hat non-Fedora) 2023-09-14 23:49:10 UTC
With clang 16, the libraries line in the output of `clang++ -print-search-dirs` is:

libraries: =/usr/lib64/clang/16:/usr/bin/../lib/gcc/x86_64-redhat-linux/13:/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../lib64:/lib/../lib64:/usr/lib/../lib64:/lib:/usr/lib

The output on 17 is:

libraries: =/usr/bin/../lib/clang/17:/usr/bin/../lib/clang/17/lib/x86_64-redhat-linux-gnu:/usr/bin/../lib/gcc/x86_64-redhat-linux/13:/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../lib64:/lib/../lib64:/usr/lib/../lib64:/lib:/usr/lib

split out, those look like this:

16
--

/usr/lib64/clang/16
/usr/bin/../lib/gcc/x86_64-redhat-linux/13
/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../lib64
/lib/../lib64
/usr/lib/../lib64
/lib
/usr/lib

17
--

/usr/bin/../lib/clang/17
/usr/bin/../lib/clang/17/lib/x86_64-redhat-linux-gnu
/usr/bin/../lib/gcc/x86_64-redhat-linux/13
/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../lib64
/lib/../lib64
/usr/lib/../lib64
/lib
/usr/lib

so in 17 there's one "extra" entry - the second - and the first entry has changed from /usr/lib64/clang/(version) to /usr/bin/../lib/clang/(version) (on x86_64). The other entries seem the same.

This breaks the build of Firefox, so it's kind of a big problem. I can hack around it in Firefox, but wanted to report it in case it's a bug.

Reproducible: Always

Steps to Reproduce:
1. Run clang++ -print-search-dirs
2. Observe the output
Actual Results:  
See above.

Expected Results:  
See above.

Comment 1 Adam Williamson (Red Hat non-Fedora) 2023-09-14 23:58:46 UTC
Firefox bug - https://bugzilla.redhat.com/show_bug.cgi?id=2239047 . I'm testing if I can work around the issue ATM.

Comment 2 Tom Stellard 2023-09-15 03:49:14 UTC
This is change was made on purpose: https://fedoraproject.org/wiki/Changes/LLVM-17#Detailed_Description

Firefox should not be using `clang++ -print-search-dirs` to find the location of libclang.so.  This option outputs the compiler search paths which have nothing to do with the location of this library.  The fact that it was working before was a coincidence.  Isn't there a standard process for finding a specific library on the system?  I know cmake an autoconf can do this.

Comment 3 Adam Williamson (Red Hat non-Fedora) 2023-09-15 05:19:51 UTC
Firefox has its own build system. If you think it shouldn't be doing this, we can report it upstream.

Comment 4 Tom Stellard 2023-09-15 05:55:38 UTC
(In reply to Adam Williamson from comment #3)
> Firefox has its own build system. If you think it shouldn't be doing this,
> we can report it upstream.

Yeah, I think reporting an upstream bug is a good idea.

Comment 5 Martin Stransky 2023-09-15 06:39:33 UTC
Filed as https://bugzilla.mozilla.org/show_bug.cgi?id=1853280
Thanks.

Comment 6 Adam Williamson (Red Hat non-Fedora) 2023-09-15 17:22:39 UTC
OK, so with that reported, it doesn't look like there's really anything else to do here. Thanks folks.