Skip to content

Add compatibility with LLVM 20.1#1993

Merged
lgritz merged 2 commits into
AcademySoftwareFoundation:mainfrom
svenstaro:llvm20-compat
Jun 16, 2025
Merged

Add compatibility with LLVM 20.1#1993
lgritz merged 2 commits into
AcademySoftwareFoundation:mainfrom
svenstaro:llvm20-compat

Conversation

@svenstaro

@svenstaro svenstaro commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Description

This adds LLVM 20 compatibility. The changes are thankfully quite concise.

Fixes #1963.

Tests

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 5, 2025

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: svenstaro / name: Sven-Hendrik Haase (c53e766)
  • ✅ login: lgritz / name: Larry Gritz (07d53bc)

Signed-off-by: Sven-Hendrik Haase <svenstaro@gmail.com>
@lgritz

lgritz commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Is that really all it takes to get fully LLVM 20 enabled? How did you test it?

I tried your patch on my end using the llvm 20 from Homebrew, and I'm still getting errors like

/Users/lg/code/osl/osl.lg/src/liboslexec/llvm_util.cpp:3659:53: error: 'getDeclaration' is deprecated: Use getOrInsertDeclaration instead [-Werror,-Wdeprecated-declarations]
            llvm::Function* func = llvm::Intrinsic::getDeclaration(
                                                    ^~~~~~~~~~~~~~
                                                    getOrInsertDeclaration

@robertkirkman

Copy link
Copy Markdown

Thank you, this patch does work for me on Termux (a subset of Android 7.0), but I do also see the warning mentioned by lgritz.

/data/data/com.termux/files/home/.termux-build/openshadinglanguage/src/src/liboslexec/llvm_util.cpp:3659:53: warning: 'getDeclaration' is deprecated: Use getOrInsertDeclaration instead [-Wdeprecated-declarations]
 3659 |             llvm::Function* func = llvm::Intrinsic::getDeclaration(
      |                                                     ^~~~~~~~~~~~~~
      |                                                     getOrInsertDeclaration
/data/data/com.termux/files/usr/include/llvm/IR/Intrinsics.h:100:3: note: 'getDeclaration' has been explicitly marked deprecated here
  100 |   LLVM_DEPRECATED("Use getOrInsertDeclaration instead",
      |   ^
/data/data/com.termux/files/usr/include/llvm/Support/Compiler.h:234:50: note: expanded from macro 'LLVM_DEPRECATED'
  234 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
      |                                                  ^

It might be just luck, or subtle variations between LLVM platforms, that applying this patch allows the build to complete for some people but not others, because, even though svenstaro might be using -DSTOP_ON_WARNING=OFF (observed here), in my case -DSTOP_ON_WARNING=OFF does not seem necessary to build successfully. It is possible that additional changes might be necessary before all LLVM platforms, including Homebrew/MacOS, are supported by this PR.

@svenstaro

Copy link
Copy Markdown
Contributor Author

Is that really all it takes to get fully LLVM 20 enabled? How did you test it?

I built and used blender against it.

I tried your patch on my end using the llvm 20 from Homebrew, and I'm still getting errors like

/Users/lg/code/osl/osl.lg/src/liboslexec/llvm_util.cpp:3659:53: error: 'getDeclaration' is deprecated: Use getOrInsertDeclaration instead [-Werror,-Wdeprecated-declarations]
            llvm::Function* func = llvm::Intrinsic::getDeclaration(
                                                    ^~~~~~~~~~~~~~
                                                    getOrInsertDeclaration

You can try to build without -Werror. I didn't fix all the deprecation warnings as I wasn't sure that effect it would have on other LLVM versions. I wanted to keep my patch minimal.

@lgritz

lgritz commented Jun 7, 2025

Copy link
Copy Markdown
Collaborator

I believe I have a fix. @svenstaro do you mind if I push an update to your fork to complete this PR?

@svenstaro

Copy link
Copy Markdown
Contributor Author

Please go right ahead.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz

lgritz commented Jun 7, 2025

Copy link
Copy Markdown
Collaborator

With the additional changes I just made, it all seems to build and work properly when tested on my Mac with llvm20 from Homebrew.

@lgritz

lgritz commented Jun 9, 2025

Copy link
Copy Markdown
Collaborator

@svenstaro Please let me know if the changes I pushed look ok to you. We don't like to push to somebody else's PR and then merge it with their name attached if we aren't sure that they fully agree with the changes.

@lgritz

lgritz commented Jun 12, 2025

Copy link
Copy Markdown
Collaborator

I will merge this (including my amendment) over the weekend if I don't hear any objections from @svenstaro or anyone else by then.

@fpsunflower fpsunflower left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@svenstaro

Copy link
Copy Markdown
Contributor Author

Seems to work alright here.

@lgritz
lgritz merged commit 8599942 into AcademySoftwareFoundation:main Jun 16, 2025
24 of 25 checks passed
lgritz added a commit to lgritz/OpenShadingLanguage that referenced this pull request Jul 2, 2025
This adds LLVM 20 compatibility. 
Fixes AcademySoftwareFoundation#1963.

Signed-off-by: Sven-Hendrik Haase <svenstaro@gmail.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
@lgritz lgritz added build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration. llvm Needs LLVM knowledge labels Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration. llvm Needs LLVM knowledge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLVM 20 compatibility

4 participants