Skip to content

Preliminary support for LLVM 20 RTSan #4924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

liushuyu
Copy link
Contributor

@liushuyu liushuyu commented May 9, 2025

This pull request adds basic RTSan (real-time sanitizer) support for D developers to check if their applications are real-time safe (i.e. suitable to use in a real-time context).

Needs #4911. Fix #4755.

liushuyu and others added 25 commits April 19, 2025 09:57
This is now required by LLVM API starting from LLVM 20
Based on checking the `ldc2 -help` output when using LLVM 20 and 19
on Linux x86_64 (with all targets enabled, incl. experimental SPIRV/
Xtensa). And comparing that against official LDC v1.34 with LLVM 16.
Where the ASan pass now apparently adds a `nosanitize_address` IR module
flag, breaking these tests.
... when using LLVM JITLink on LLVM 20+
... this attribute can be used to mark a function as "blocking" (same
mechanism as Clang's `[[clang::blocking]]` C/C++ attribute.
{
import ldc.attributes;

@weak extern (C) void __rtsan_disable() @nogc nothrow {}
Copy link
Member

Choose a reason for hiding this comment

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

Have a look at module ldc.sanitizers_optionally_linked. I think that's more robust / works on more platforms probably?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@cjappl
Copy link

cjappl commented May 9, 2025

One of the authors of rtsan here, was just linked this PR!

Just shout if you have any questions. Excited to see it go into D

@cjappl
Copy link

cjappl commented May 9, 2025

An overall note before I look any further - it may be simpler to break this up into:

  1. Updating to llvm20
  2. Adding rtsan

Seems like there are two major steps being done in this single PR. Breaking them up would make it easier to review and roll back upon an issue

@liushuyu
Copy link
Contributor Author

Hi, thank you for your review!

An overall note before I look any further - it may be simpler to break this up into:

1. Updating to llvm20

2. Adding rtsan

Seems like there are two major steps being done in this single PR. Breaking them up would make it easier to review and roll back upon an issue

This is also why this is a draft. I am currently waiting on LLVM upstream to fix a LLVM 20 regression that breaks LDC in a very bad way (see #4911). This pull request will be rebased when that LLVM 20 upgrade pull request lands.

... this function is not real-time safe and also not rtsan safe (will
lock-up rtsan's stack scanner)
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.

Add RTSan support
4 participants