Bug 2238728 - Firefox fails to build due to missing /usr/lib64/libclang.so symlink in clang-devel
Summary: Firefox fails to build due to missing /usr/lib64/libclang.so symlink in clang...
Keywords:
Status: CLOSED DUPLICATE of bug 2239047
Alias: None
Product: Fedora
Classification: Fedora
Component: clang
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-09-13 11:56 UTC by Martin Stransky
Modified: 2023-09-20 19:09 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-09-20 13:45:03 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Martin Stransky 2023-09-13 11:56:27 UTC
Firefox newly fails to build due to missing /usr/lib64/libclang.so symlink in clang-devel on Fedora 39/40. Fedora 38/37 is ok. Previous Firefox builds are also ok.

Affected builds:
https://koji.fedoraproject.org/koji/buildinfo?buildID=2288772
https://koji.fedoraproject.org/koji/buildinfo?buildID=2288774

Reproducible: Always

Comment 1 Tulio Magno Quites Machado Filho 2023-09-13 12:46:50 UTC
This might have another root cause.
This is what I'm getting:

$ podman run -it --rm fedora:rawhide bash
# dnf install -y clang-devel
...
# ll /usr/lib64/libclang.so
lrwxrwxrwx. 1 root root 14 Aug 23 00:00 /usr/lib64/libclang.so -> libclang.so.17
# rpm -q clang-devel
clang-devel-17.0.0~rc3-1.fc40.x86_64

Looking at the last rust build on rawhide, it used clang-libs-16.0.6-3.fc39.
I expected that building with rust would be using clang16-libs instead.

rust-1.72.0-1.fc40.x86_64 does require libLLVM-16.so()(64bit), but I don't see which package is providing this in these Firefox builds.
How can this happen?

Comment 2 Tulio Magno Quites Machado Filho 2023-09-13 12:50:42 UTC
(In reply to Tulio Magno Quites Machado Filho from comment #1)
> rust-1.72.0-1.fc40.x86_64 does require libLLVM-16.so()(64bit), but I don't
> see which package is providing this in these Firefox builds.
> How can this happen?

One should not confuse libclang with libLLVM. :o)

Is this being caused by mixing clang 17 with a rust built with clang 16?

Comment 3 Martin Stransky 2023-09-13 14:31:17 UTC
Can it be caused by latest clang-17.0.0 updates? Because previous Firefox 117.0 build from 2023-08-30 are okay.

Comment 4 Tulio Magno Quites Machado Filho 2023-09-13 15:43:53 UTC
I managed to get how Firefox is looking for libclang:

INFO: checking for libclang for bindgen... 
DEBUG: Executing: `/usr/bin/clang++ -print-search-dirs`
DEBUG: Trying "libclang.so" in "/usr/bin/../lib"
DEBUG: Trying "libclang.so.*" in "/usr/bin/../lib"
INFO: not found
ERROR: Could not find libclang to generate rust bindings for C/C++. Please install the necessary packages, run `mach bootstrap`, or use --with-libclang-path to give the path containing it.

Which means it's aborting without checking all the paths because the output is:

# /usr/bin/clang++ -print-search-dirs
programs: =/usr/bin:/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/bin
libraries: =/usr/bin/../lib/clang/17:/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

Comment 5 Josh Stone 2023-09-13 16:50:34 UTC
The Rust build only uses clang to compile its bundled wasi-libc. That shouldn't have any effect on Rust dependents.

It could be a problem if a proc-macro mixed clang-17 with rust+llvm16, since they would be loaded in the same process, but it seems your build problems are happening well before anything like that.

Comment 6 Martin Stransky 2023-09-14 06:54:44 UTC
I tried local build in VM Fedora 39 and /usr/bin/clang++ doesn't start but throws:

/lib64/libclang-cpp.so.17: undefined symbol llvm::opt::ArgList::hasFlagNoClaim(llvm::opt::OptSpecifier,...)

So it fails at 'checking for clang for bindgen... /usr/bin/clang++' stage.
But /usr/lib64/libclang.so symlink is present.

Comment 7 Martin Stransky 2023-09-14 07:07:16 UTC
Okay, updated F39 and clang++ issue looks solved. But Firefox still fails to pick up libclang.

Comment 8 Martin Stransky 2023-09-14 08:04:26 UTC
(In reply to Tulio Magno Quites Machado Filho from comment #4)
> I managed to get how Firefox is looking for libclang:
> 
> INFO: checking for libclang for bindgen... 
> DEBUG: Executing: `/usr/bin/clang++ -print-search-dirs`
> DEBUG: Trying "libclang.so" in "/usr/bin/../lib"
> DEBUG: Trying "libclang.so.*" in "/usr/bin/../lib"
> INFO: not found
> ERROR: Could not find libclang to generate rust bindings for C/C++. Please
> install the necessary packages, run `mach bootstrap`, or use
> --with-libclang-path to give the path containing it.
> 
> Which means it's aborting without checking all the paths because the output
> is:
> 
> # /usr/bin/clang++ -print-search-dirs
> programs:
> =/usr/bin:/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-
> redhat-linux/bin
> libraries:
> =/usr/bin/../lib/clang/17:/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

I don't see '/usr/bin/../lib' path in the '/usr/bin/clang++ -print-search-dirs' output at all which means Firefox gets the library list from different source.

Comment 9 Martin Stransky 2023-09-14 08:37:15 UTC
Tulio Magno Quites Machado Filho how did you manage to get the DEBUG output from Firefox build?
Thanks.

Comment 10 Tulio Magno Quites Machado Filho 2023-09-14 12:40:27 UTC
(In reply to Martin Stransky from comment #9)
> Tulio Magno Quites Machado Filho how did you manage to get the DEBUG output
> from Firefox build?

First I tried to build it using mock, i.e.:

$ mock -r fedora-rawhide-x86_64 --rebuild firefox-117.0.1-1.fc40.src.rpm

Then I found the following log: /var/lib/mock/fedora-rawhide-x86_64/root/builddir/build/BUILD/firefox-117.0.1/objdir/instrumented/config.log

Comment 11 Tom Stellard 2023-09-15 03:50:46 UTC
I think this is a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=2239047

See my response in https://bugzilla.redhat.com/show_bug.cgi?id=2239046#c2.

Comment 12 Tulio Magno Quites Machado Filho 2023-09-20 13:45:03 UTC

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

Comment 13 Adam Williamson (Red Hat non-Fedora) 2023-09-20 19:09:14 UTC
Aha - I didn't realize you were all struggling down the same furrow over here when I fixed it :) I did look for existing bug reports before I started digging, but I was looking for *firefox* bugs not *clang* bugs. D'oh.

Anyhow, you were most of the way there - the problem *was* the output of `/usr/bin/clang++ -print-search-dirs` changing. `bindgen.configure` does some parsing on the output to generate its list of candidates, which is why the debug output doesn't exactly match the clang++ output. It parses `/usr/bin/../lib/clang/17` into `/usr/bin/../lib` and tries that; the other items in the output all get discarded because they don't match what it's looking for (it looks for items ending in clang/(anumber) and strips those elements out, basically).

The practical way to fix this was just to bypass all this stuff and pass --with-libclang-path=%{_libdir} and *tell* the build process where to find the library. Per the clang devs, all this detection logic is wrong anyway.


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