Skip to content

Allow building LLVM 13 with newer compilers#8028

Closed
samestep wants to merge 1 commit intomasterfrom
llvm-include-cstdint
Closed

Allow building LLVM 13 with newer compilers#8028
samestep wants to merge 1 commit intomasterfrom
llvm-include-cstdint

Conversation

@samestep
Copy link
Contributor

@samestep samestep commented Aug 1, 2025

Currently external/build-llvm.sh works with GCC 11 which we use in CI, but does not work with GCC 13 or newer:

In file included from /home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/lib/Support/Signals.cpp:14:
/home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/include/llvm/Support/Signals.h:119:24: error: unknown type name 'uintptr_t'; did you mean '__intptr_t'?
  119 |   void CleanupOnSignal(uintptr_t Context);
      |                        ^~~~~~~~~
      |                        __intptr_t

And also does not work with any version of Clang that I've tried, including Clang 12 and Clang 13 (although I don't quite understand why Clang 13 wouldn't be able to build itself):

In file included from /home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/lib/Support/Signals.cpp:14:
/home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/include/llvm/Support/Signals.h:119:8: error: variable or field 'CleanupOnSignal' declared void
  119 |   void CleanupOnSignal(uintptr_t Context);
      |        ^~~~~~~~~~~~~~~
/home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/include/llvm/Support/Signals.h:119:24: error: 'uintptr_t' was not declared in this scope
  119 |   void CleanupOnSignal(uintptr_t Context);
      |                        ^~~~~~~~~
/home/saestep/github/shader-slang/slang/build/slang-llvm_src/llvm/include/llvm/Support/Signals.h:18:1: note: 'uintptr_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   17 | #include <string>
  +++ |+#include <cstdint>
   18 |

This is because GCC 13 started requiring explicit #include <cstdint>, which was not added to llvm/include/llvm/Support/Signals.h until llvm/llvm-project@ff1681d a few months after the llvmorg-13.0.1 tag.

This PR allows LLVM 13 to be built with Clang, and with newer versions of GCC, by implicitly including <cstdint>.

@samestep samestep requested a review from a team as a code owner August 1, 2025 16:21
@samestep samestep added the pr: non-breaking PRs without breaking changes label Aug 1, 2025
Comment on lines +138 to +139
# Allow building with newer compilers
-DCMAKE_CXX_FLAGS="-include cstdint"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we add this line somewhere in the source code rather than in cmake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkwak-work you mean, in the LLVM source code?

@jkwak-work
Copy link
Collaborator

jkwak-work commented Aug 1, 2025

It seems like this issue was addressed a while ago

Maybe we should use a newer version of LLVM?

Claude Code told me the following,

● Based on my research, the minimal LLVM version bump needed to fix the uintptr_t/cstdint issue is llvmorg-14.0.5.

Here's what I found:

The Issue

  • LLVM 13.0.1 (currently used by Slang) has missing #include headers
  • This causes compilation failures with newer compilers like GCC 13 and newer Clang versions
  • The error manifests as 'uintptr_t' was not declared in this scope and similar issues

The Fix

  • Commits: ff1681d and 5e9be93 added the missing #include headers
  • Target Version: These fixes were targeted for LLVM 14.0.5 milestone
  • Release Date: LLVM 14.0.5 was released on June 11, 2022

Recommendation

Update the Slang build script from:
branch=llvmorg-13.0.1
to:
branch=llvmorg-14.0.5

This is the closest version to 13.0.1 that includes the GCC 13 compatibility fixes. LLVM 14.0.5 was specifically a bug-fix release that maintained API/ABI compatibility with 14.0.0,
making it a safer upgrade path than jumping to a much newer major version.

This approach is much cleaner than the CMake workaround in PR #8028 and addresses the root cause rather than just patching the symptoms.

@samestep
Copy link
Contributor Author

samestep commented Aug 1, 2025

@jkwak-work yes, I already linked to llvm/llvm-project@ff1681d in my PR description above.

I have no problem with upgrading our LLVM dependency, but I don't know what that would break in Slang, so I didn't try it.

@samestep
Copy link
Contributor Author

samestep commented Aug 1, 2025

@jkwak-work I see a couple other instances of LLVM 13 mentioned in our codebase:

Would this mean we'd need to update our dependencies on glslang and SPIR-V Tools too?

@samestep
Copy link
Contributor Author

samestep commented Aug 1, 2025

Also, would updating LLVM constitute a breaking change or a non-breaking change?

@samestep
Copy link
Contributor Author

samestep commented Aug 1, 2025

I opened #8031 with an attempt to upgrade from LLVM 13 to LLVM 14; seems to work after some minor changes.

@csyonghe
Copy link
Collaborator

csyonghe commented Aug 1, 2025

Nothing should break for an LLVM update. We use LLVM at a very coarse granularity.

@samestep
Copy link
Contributor Author

samestep commented Aug 1, 2025

Makes sense.

I wasn't sure what LLVM version we actually want to upgrade to, so I just made PRs for all of them, so we can choose whichever we prefer:

@csyonghe
Copy link
Collaborator

csyonghe commented Aug 7, 2025

Closing this PR, since we have decided to upgrade to LLVM 14.6 PR which won't have this problem.

@csyonghe csyonghe closed this Aug 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 7, 2025
Full set of mutually exclusive choices for upgrading LLVM:

- #8031 (you are here)
- #8035
- #8036
- #8034
- #8038
- #8039
- #8033

Alternative to #8028. Required some minor changes due to these upstream
commits:

- llvm/llvm-project@e463b69
- llvm/llvm-project@89b5706
szihs pushed a commit to szihs/slang that referenced this pull request Aug 19, 2025
Full set of mutually exclusive choices for upgrading LLVM:

- shader-slang#8031 (you are here)
- shader-slang#8035
- shader-slang#8036
- shader-slang#8034
- shader-slang#8038
- shader-slang#8039
- shader-slang#8033

Alternative to shader-slang#8028. Required some minor changes due to these upstream
commits:

- llvm/llvm-project@e463b69
- llvm/llvm-project@89b5706
@samestep samestep mentioned this pull request Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants