Skip to content

Fix building under clang-22#5064

Merged
neobrain merged 1 commit intoFEX-Emu:mainfrom
zeyi2:fix-clang-22-building
Feb 26, 2026
Merged

Fix building under clang-22#5064
neobrain merged 1 commit intoFEX-Emu:mainfrom
zeyi2:fix-clang-22-building

Conversation

@zeyi2
Copy link
Copy Markdown
Contributor

@zeyi2 zeyi2 commented Nov 18, 2025

Closes #5032

@zeyi2 zeyi2 marked this pull request as draft November 18, 2025 13:01
@zeyi2 zeyi2 force-pushed the fix-clang-22-building branch from b1e749d to 414f739 Compare November 19, 2025 01:21
@zeyi2 zeyi2 marked this pull request as ready for review November 23, 2025 05:13
@neobrain
Copy link
Copy Markdown
Member

Thanks for picking this up!

I hadn't realized LLVM 22 isn't actually released yet. What platform are you running that you noticed the build failure?

Probably makes sense to wait with merging until upstream puts out a proper release, since I remember LLVM 21 had a lot of back and forth with API changes during development.

@zeyi2
Copy link
Copy Markdown
Contributor Author

zeyi2 commented Nov 24, 2025

What platform are you running that you noticed the build failure?

I'm running FEX on Ubuntu 24.04, AArch64.

Probably makes sense to wait with merging until upstream puts out a proper release

That sounds good to me. I'm totally fine with waiting. and I'm happy to take care of any other API breaking changes in the meantime :)

@zeyi2
Copy link
Copy Markdown
Contributor Author

zeyi2 commented Feb 24, 2026

Clang-22 is released, I'll test whether current patch can compile later :)

@neobrain
Copy link
Copy Markdown
Member

Clang-22 is released, I'll test whether current patch can compile later :)

Great, thanks again for keeping an eye on this!

Did you enable unit tests locally? I gave the patch a quick spin using the nix build, and it's failing to build in those:

fex> /nix/store/dxiykirqrdjjlj99czm2f0nza11hij1a-clang-wrapper-22.1.0-rc3/bin/clang++ -DARCHITECTURE_arm64=1 -DCLANG_RESOURCE_DIR=\"/nix/store/dxiykirqrdjjlj99czm2f0nza11hij1a-clang-wrapper-22.1.0-rc3/resource-root\" -DFEX_HAS_PRESERVE_ALL_ATTR=1 -DFEX_PRESERVE_ALL_ATTR="__attribute__((preserve_all))" -DFMT_SHARED -DGLOBAL_DATA_DIRECTORY=\"/nix/store/a5kbqqzmfwzv2qmqgm228xi7vbxxlcx4-fex-2601/share/fex-emu/\" -I/build/source/build/unittests/ThunkLibs -I/build/source/unittests/ThunkLibs -I/build/source/External/robin-map/include -I/build/source/External/tiny-json -I/build/source/Source -I/build/source/build/Source -I/build/source/ThunkLibs/Generator -isystem /build/source/External/vixl/src -O3 -DNDEBUG -fomit-frame-pointer -std=gnu++20 -flto=thin -fPIE   -Wno-trigraphs -fdiagnostics-color=always -fcolor-diagnostics -Wno-deprecated-enum-enum-conversion -Wall -U_GLIBCXX_DEBUG -MD -MT unittests/ThunkLibs/CMakeFiles/thunkgentest.dir/abi.cpp.o -MF unittests/ThunkLibs/CMakeFiles/thunkgentest.dir/abi.cpp.o.d -o unittests/ThunkLibs/CMakeFiles/thunkgentest.dir/abi.cpp.o -c /build/source/unittests/ThunkLibs/abi.cpp
fex> /build/source/unittests/ThunkLibs/abi.cpp:120:14: error: no matching member function for call to 'createDiagnostics'
fex>   120 |     Compiler.createDiagnostics(Compiler.getVirtualFileSystem(), diag_consumer, false);
fex>       |     ~~~~~~~~~^~~~~~~~~~~~~~~~~
fex> /nix/store/lq075ikigy91jzll8sa42lw2c0v30k9w-clang-22.1.0-rc3-dev/include/clang/Frontend/CompilerInstance.h:721:3: note: candidate function not viable: no known conversion from 'clang::DiagnosticConsumer *' to 'DiagnosticOptions &' for 2nd argument
fex>   721 |   createDiagnostics(llvm::vfs::FileSystem &VFS, DiagnosticOptions &Opts,
fex>       |   ^                                             ~~~~~~~~~~~~~~~~~~~~~~~
fex> /nix/store/lq075ikigy91jzll8sa42lw2c0v30k9w-clang-22.1.0-rc3-dev/include/clang/Frontend/CompilerInstance.h:696:8: note: candidate function not viable: requires at most 2 arguments, but 3 were provided
fex>   696 |   void createDiagnostics(DiagnosticConsumer *Client = nullptr,
fex>       |        ^                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fex>   697 |                          bool ShouldOwnClient = true);
fex>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
fex> /build/source/unittests/ThunkLibs/abi.cpp:127:34: error: too many arguments to function call, expected 0, have 1
fex>   127 |     Compiler.createSourceManager(*files);
fex>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~
fex> /nix/store/lq075ikigy91jzll8sa42lw2c0v30k9w-clang-22.1.0-rc3-dev/include/clang/Frontend/CompilerInstance.h:730:8: note: 'createSourceManager' declared here
fex>   730 |   void createSourceManager();
fex>       |        ^
fex> 2 errors generated.

@zeyi2
Copy link
Copy Markdown
Contributor Author

zeyi2 commented Feb 25, 2026

Did you enable unit tests locally?

Sorry that I didn't enable it, I'll push a new commit when I fix the unittests build.

@zeyi2 zeyi2 force-pushed the fix-clang-22-building branch from 414f739 to 48680d6 Compare February 26, 2026 11:55
@zeyi2
Copy link
Copy Markdown
Contributor Author

zeyi2 commented Feb 26, 2026

Hi, I've updated the patch and verified that the unittests and lib-thunking can all build as expected under clang-22.

I ran the unittests locally and observed some failures, primarily in x32. (I suspect they may be due to my local environment setup rather than the build fix itself).

I also used clang-format to ensure that the formatting is nice by running: git clang-format HEAD~1 --binary=/usr/bin/clang-format

Would you please take another look at this when you have time? Thanks in advance :)

Copy link
Copy Markdown
Member

@neobrain neobrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! It now builds fine for me. For reference, I tested compiling against LLVM 19, 21, and 22.

Thanks yet again :)

@neobrain neobrain merged commit 3c517f5 into FEX-Emu:main Feb 26, 2026
15 of 16 checks passed
@zeyi2 zeyi2 deleted the fix-clang-22-building branch February 26, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with clang >= 22

2 participants