Closed Bug 1923255 (clang-20) Opened 1 year ago Closed 1 month ago

Update builders to clang 20

Categories

(Firefox Build System :: Toolchains, task)

task

Tracking

(firefox146 wontfix, firefox147 fixed)

RESOLVED FIXED
147 Branch
Tracking Status
firefox146 --- wontfix
firefox147 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

(when it's released)

Depends on: 1923254
Depends on: 1930826
Depends on: 1941477
Depends on: 1941478
Depends on: 1941479
Depends on: 1941480
Depends on: 1941482
Blocks: 1943916
Depends on: 1943879
Depends on: 1949620
Depends on: 1952101
Depends on: 1966557
Depends on: 1967887
Depends on: 1967374
Depends on: 1967896
Depends on: 1977767
Depends on: 1977777
Depends on: 1990437
Depends on: 1992069
Depends on: 1924278

This change adds support for building Firefox with Clang 20, including
critical fixes for the clang-plugin dynamic linking on Windows.

Clang 20 introduced two breaking changes that prevented the clang-plugin
from loading on Windows:

  1. The CLANG_ABI macro was added to Attr classes, causing inline methods
    like classof() and getAnnotation() to generate dllimport references.
    This fails because these methods are defined inline in headers, not
    exported from the DLL.

  2. The extract_symbols.py script became more aggressive in filtering
    symbols, blocking the Registry<PluginASTAction> static data members
    (Head/Tail) that don't match function signature patterns.

The fix consists of three patches for the Clang 20 build:

  • add-plugin-symbols_clang_20.patch: Whitelists the Registry Head/Tail
    symbols in extract_symbols.py to bypass the filtering logic.

  • force-plugin-symbols_clang_20.patch: Uses /INCLUDE linker flags to
    force the Registry add_node() and begin() symbols into clang.exe,
    since they exist in libraries but weren't being linked due to being
    unreferenced.

  • remove-clang-abi-from-attrs_clang_20.patch: Removes the CLANG_ABI
    macro from Attr class generation to prevent dllimport issues with
    inline methods.

Additional changes:

  • Fixed toolchain.configure to accept clang-cl as a valid compiler for
    the WASI target, deriving the clang.exe path when needed. Previously,
    only "clang" was accepted, causing configuration failures on Windows
    where clang-cl is the default.

  • Modified build-clang.py to enable libxml2 for all Windows build stages,
    not just the final stage, ensuring it's available during intermediate
    builds.

  • Fixed moz.build to apply extra_cxxflags even when LLVM_CXXFLAGS is
    empty, ensuring -GR- and -EHsc are always applied on Windows.

To test this locally, check out llvm 20.1.8 alongside firefox, then
build clang by running

MOZ_FETCHES_DIR=../firefox python3 ../firefox/build/build-clang/build-clang.py -c ../firefox/build/build-clang/use-clang-cl-artifact.json -c ../firefox/build/build-clang/win64.json -c ../firefox/build/build-clang/clang-20.json -c ../firefox/build/build-clang/2stages.json

After this, update mozconfig to

export CC=[THE LLVM CHECKOUT DIRECTORY]/build/stage2/clang/bin/clang-cl.exe
ac_add_options --enable-clang-plugin

Assignee: nobody → zondolfin
Status: NEW → ASSIGNED

Hey again Mike,

With some small patches to llvm 20.1.8 it behaves similarly enough to llvm 19 that the plugin works again.

Using patches also allowed me to minimize the changes in build/clang-plugin/moz.build.

Is this useful to you? Should I try to polish this into a submittable change, can you use it in a patch of your own?

Flags: needinfo?(mh+mozilla)

I realize this patch should actually go in 1941482, I'll move it there.

Comment on attachment 9519448 [details]
Bug 1923255 - Enable Clang 20 support for Firefox with Windows plugin fixes r=glandium

Revision D268255 was moved to bug 1941482. Setting attachment 9519448 [details] to obsolete.

Attachment #9519448 - Attachment is obsolete: true
See Also: → 1994108
Depends on: 1994622
Depends on: 1994627
Depends on: 1994904
Assignee: zondolfin → mh+mozilla
Flags: needinfo?(mh+mozilla)
Blocks: rustc-1.90
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch

This was backed out along bug 1948826

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Depends on: 1998852
Status: REOPENED → RESOLVED
Closed: 2 months ago1 month ago
Resolution: --- → FIXED
Regressions: 2000030
Target Milestone: 146 Branch → 147 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: