Skip to content

Ts/44325 clang update#2

Open
alexrhein wants to merge 2 commits intomasterfrom
ts/44325_clang_update
Open

Ts/44325 clang update#2
alexrhein wants to merge 2 commits intomasterfrom
ts/44325_clang_update

Conversation

@alexrhein
Copy link
Copy Markdown

No description provided.

* Format: llvm<LLVM_VERSION>-swig<SWIG_VERSION>-<BUILD_DATE>
* Update this when rebuilding with a new LLVM, SWIG, or JNI code change.
*/
public static final String VERSION = "llvm21.1.8-swig4.4.1-20260327";
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This ensures that crash log files contain the exact version of the jar file that crashed.

try {
SWIGTYPE_p_CXTranslationUnitImpl translationUnit = Clang.clang_parseTranslationUnit(index,
files[0].getFilename(), null, 0, files, files.length, ClangJNI.CXTranslationUnit_KeepGoing_get());
files[0].getFilename(), null, files, files.length, ClangJNI.CXTranslationUnit_KeepGoing_get());
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The null here is for the String[] command_line_args parameter. In the new SWIG binding, when you pass null for a String[], the typemap generates a
NULL pointer and sets the length to 0 automatically on the C side. So there's no need to pass the count separately — the SWIG typemap handles both
the pointer and length from the single String[] argument.

@alexrhein alexrhein force-pushed the ts/44325_clang_update branch from 84de9ca to 9ff9676 Compare March 30, 2026 04:46
Major upgrade of the clang JNI bindings from LLVM 9.0.1 (2019) to
LLVM 21.1.8 (2025). This fixes a SIGSEGV crash in libclang that
occurred when analyzing certain C++ files in Teamscale (TS-44325).

Changes to the JNI bindings:
- Regenerated SWIG bindings for LLVM 21.1.8 (generated/)
- Added String[] typemap for clang_parseTranslationUnit, allowing
  compiler flags (e.g., -x c++) to be passed from Java
- Added clang_parseTranslationUnit2_wrap for better error reporting
- Removed clang-tidy support (unused by Teamscale)
- Fixed NULL file crash in getSpellingLocationPropertiesImpl and
  getExpansionLocationPropertiesImpl for built-in/synthesized locations
- Fixed visitor callback exception safety: use CXChildVisit_Break
  instead of C++ exceptions to avoid corrupting clang's internal state
- Applied -fexceptions only to JNI source files, not globally
- Embedded version string in native library temp directory name

Build infrastructure:
- Rewrote BUILD.md with full cross-platform build workflow
- Added BUILD-TIMES.md for tracking build durations
- build-linux.sh now supports both Linux and macOS (auto-detects)
- build-linux.sh prints build time after compilation
- Native libraries are transferred between machines via git LFS during
  the build, then removed in a squash commit to keep LFS storage small
- Removed build-mac.md and build-windows.md (superseded by BUILD.md)

Testing:
- Added ClangJniTest with 25 integration tests covering parsing, type
  resolution, typedef chains, operator detection, templates, lambdas,
  OpenMP pragmas, and repeated parse/dispose cycles
- Moved test classes to test/ directory (not included in JAR)
- Added Main.java as JAR entry point for standalone AST debugging

Native libraries included in clang-jni.jar:
- libclang-linux.so (x86_64)
- libclang-mac.dylib (arm64)
- libclang-win.dll (x86_64)
@alexrhein alexrhein force-pushed the ts/44325_clang_update branch from c975770 to 639266b Compare March 30, 2026 05:05
|----------|--------|-------------|-------------------------------------|------|
| Windows | Intel Xeon @ 2.20 GHz, 2 cores / 4 threads, 16 GB RAM, Windows Server 2022 Datacenter | 20.1.8 | ~2h 45m (full build with `--parallel`) | 2026-03-19 |
| Linux | *(please fill in after building)* | | | |
| macOS | *(please fill in after building)* | | | |
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The linux and mac sessions did not see that they should track the timing info.
Afterwards, I made this more visible and explicit.

But the windows build (win2) was the slowest one anyway, so that is the most important information.

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.

1 participant