Skip to content

Commit edb0a54

Browse files
authored
Merge branch 'main' into fix/111854
2 parents 4b19638 + 590b1e3 commit edb0a54

File tree

24 files changed

+142
-53
lines changed

24 files changed

+142
-53
lines changed

clang/docs/RealtimeSanitizer.rst

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ A **partial** list of flags RealtimeSanitizer respects:
183183
- ``true``
184184
- boolean
185185
- If set, use the symbolizer to turn virtual addresses to file/line locations. If false, can greatly speed up the error reporting.
186+
* - ``suppressions``
187+
- ""
188+
- path
189+
- If set to a valid suppressions file, will suppress issue reporting. See details in "Disabling", below.
186190

187191

188192
Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
@@ -194,12 +198,43 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
194198
misspelled_flag
195199
...
196200
197-
Disabling
198-
---------
201+
Disabling and suppressing
202+
-------------------------
199203

200-
In some circumstances, you may want to suppress error reporting in a specific scope.
204+
There are multiple ways to disable error reporting when using RealtimeSanitizer.
201205

202-
In C++, this is achieved via ``__rtsan::ScopedDisabler``. Within the scope where the ``ScopedDisabler`` object is instantiated, all sanitizer error reports are suppressed. This suppression applies to the current scope as well as all invoked functions, including any functions called transitively.
206+
In general, ``ScopedDisabler`` should be preferred, as it is the most performant.
207+
208+
.. list-table:: Suppression methods
209+
:widths: 30 15 15 10 70
210+
:header-rows: 1
211+
212+
* - Method
213+
- Specified at?
214+
- Scope
215+
- Run-time cost
216+
- Description
217+
* - ``ScopedDisabler``
218+
- Compile-time
219+
- Stack
220+
- Very low
221+
- Violations are ignored for the lifetime of the ``ScopedDisabler`` object.
222+
* - ``function-name-matches`` suppression
223+
- Run-time
224+
- Single function
225+
- Medium
226+
- Suppresses intercepted and ``[[clang::blocking]]`` function calls by name.
227+
* - ``call-stack-contains`` suppression
228+
- Run-time
229+
- Stack
230+
- High
231+
- Suppresses any stack trace contaning the specified pattern.
232+
233+
234+
``ScopedDisabler``
235+
##################
236+
237+
At compile time, RealtimeSanitizer may be disabled using ``__rtsan::ScopedDisabler``. RTSan ignores any errors originating within the ``ScopedDisabler`` instance variable scope.
203238

204239
.. code-block:: c++
205240

@@ -233,6 +268,31 @@ In C, you can use the ``__rtsan_disable()`` and ``rtsan_enable()`` functions to
233268

234269
Each call to ``__rtsan_disable()`` must be paired with a subsequent call to ``__rtsan_enable()`` to restore normal sanitizer functionality. If a corresponding ``rtsan_enable()`` call is not made, the behavior is undefined.
235270

271+
Suppression file
272+
################
273+
274+
At run-time, suppressions may be specified using a suppressions file passed in ``RTSAN_OPTIONS``. Run-time suppression may be useful if the source cannot be changed.
275+
276+
.. code-block:: console
277+
278+
> cat suppressions.supp
279+
call-stack-contains:MallocViolation
280+
call-stack-contains:std::*vector
281+
function-name-matches:free
282+
function-name-matches:CustomMarkedBlocking*
283+
> RTSAN_OPTIONS="suppressions=suppressions.supp" ./a.out
284+
...
285+
286+
Suppressions specified in this file are one of two flavors.
287+
288+
``function-name-matches`` suppresses reporting of any intercepted library call, or function marked ``[[clang::blocking]]`` by name. If, for instance, you know that ``malloc`` is real-time safe on your system, you can disable the check for it via ``function-name-matches:malloc``.
289+
290+
``call-stack-contains`` suppresses reporting of errors in any stack that contains a string matching the pattern specified. For example, suppressing error reporting of any non-real-time-safe behavior in ``std::vector`` may be specified ``call-stack-contains:std::*vector``. You must include symbols in your build for this method to be effective, unsymbolicated stack traces cannot be matched. ``call-stack-contains`` has the highest run-time cost of any method of suppression.
291+
292+
Patterns may be exact matches or are "regex-light" patterns, containing special characters such as ``^$*``.
293+
294+
The number of potential errors suppressed via this method may be seen on exit when using the ``print_stats_on_exit`` flag.
295+
236296
Compile-time sanitizer detection
237297
--------------------------------
238298

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,15 @@ NetBSD Support
691691
WebAssembly Support
692692
^^^^^^^^^^^^^^^^^^^
693693

694+
The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
695+
and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
696+
and [Non-trapping float-to-int Conversions] language features, which are
697+
[widely implemented in engines].
698+
699+
[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
700+
[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
701+
[widely implemented in engines]: https://webassembly.org/features/
702+
694703
AVR Support
695704
^^^^^^^^^^^
696705

clang/include/clang/Lex/Preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ class Preprocessor {
14901490
/// Mark the file as included.
14911491
/// Returns true if this is the first time the file was included.
14921492
bool markIncluded(FileEntryRef File) {
1493-
HeaderInfo.getFileInfo(File);
1493+
HeaderInfo.getFileInfo(File).IsLocallyIncluded = true;
14941494
return IncludedFiles.insert(File).second;
14951495
}
14961496

clang/lib/Basic/Targets/WebAssembly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ bool WebAssemblyTargetInfo::initFeatureMap(
154154
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
155155
const std::vector<std::string> &FeaturesVec) const {
156156
auto addGenericFeatures = [&]() {
157+
Features["bulk-memory"] = true;
157158
Features["multivalue"] = true;
158159
Features["mutable-globals"] = true;
160+
Features["nontrapping-fptoint"] = true;
159161
Features["reference-types"] = true;
160162
Features["sign-ext"] = true;
161163
};
162164
auto addBleedingEdgeFeatures = [&]() {
163165
addGenericFeatures();
164166
Features["atomics"] = true;
165-
Features["bulk-memory"] = true;
166167
Features["exception-handling"] = true;
167168
Features["extended-const"] = true;
168169
Features["fp16"] = true;
169170
Features["multimemory"] = true;
170-
Features["nontrapping-fptoint"] = true;
171171
Features["tail-call"] = true;
172172
Features["wide-arithmetic"] = true;
173173
setSIMDLevel(Features, RelaxedSIMD, true);

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,6 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
15821582
}
15831583
}
15841584

1585-
FileInfo.IsLocallyIncluded = true;
15861585
IsFirstIncludeOfFile = PP.markIncluded(File);
15871586
return true;
15881587
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,8 +2163,8 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
21632163
continue; // We have no information on this being a header file.
21642164
if (!HFI->isCompilingModuleHeader && HFI->isModuleHeader)
21652165
continue; // Header file info is tracked by the owning module file.
2166-
if (!HFI->isCompilingModuleHeader && !PP->alreadyIncluded(*File))
2167-
continue; // Non-modular header not included is not needed.
2166+
if (!HFI->isCompilingModuleHeader && !HFI->IsLocallyIncluded)
2167+
continue; // Header file info is tracked by the including module file.
21682168

21692169
// Massage the file path into an appropriate form.
21702170
StringRef Filename = File->getName();
@@ -2176,7 +2176,7 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
21762176
SavedStrings.push_back(Filename.data());
21772177
}
21782178

2179-
bool Included = PP->alreadyIncluded(*File);
2179+
bool Included = HFI->IsLocallyIncluded || PP->alreadyIncluded(*File);
21802180

21812181
HeaderFileInfoTrait::key_type Key = {
21822182
Filename, File->getSize(), getTimestampForOutput(*File)

clang/test/Preprocessor/wasm-target-features.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@
163163
// RUN: -target wasm64-unknown-unknown -mcpu=generic \
164164
// RUN: | FileCheck %s -check-prefix=GENERIC-INCLUDE
165165
//
166+
// GENERIC-INCLUDE-DAG: #define __wasm_bulk_memory__ 1{{$}}
166167
// GENERIC-INCLUDE-DAG: #define __wasm_multivalue__ 1{{$}}
167168
// GENERIC-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}}
169+
// GENERIC-INCLUDE-DAG: #define __wasm_nontrapping_fptoint__ 1{{$}}
168170
// GENERIC-INCLUDE-DAG: #define __wasm_reference_types__ 1{{$}}
169171
// GENERIC-INCLUDE-DAG: #define __wasm_sign_ext__ 1{{$}}
170172
//
@@ -176,12 +178,10 @@
176178
// RUN: | FileCheck %s -check-prefix=GENERIC
177179
//
178180
// GENERIC-NOT: #define __wasm_atomics__ 1{{$}}
179-
// GENERIC-NOT: #define __wasm_bulk_memory__ 1{{$}}
180181
// GENERIC-NOT: #define __wasm_exception_handling__ 1{{$}}
181182
// GENERIC-NOT: #define __wasm_extended_const__ 1{{$}}
182183
// GENERIC-NOT: #define __wasm__fp16__ 1{{$}}
183184
// GENERIC-NOT: #define __wasm_multimemory__ 1{{$}}
184-
// GENERIC-NOT: #define __wasm_nontrapping_fptoint__ 1{{$}}
185185
// GENERIC-NOT: #define __wasm_relaxed_simd__ 1{{$}}
186186
// GENERIC-NOT: #define __wasm_simd128__ 1{{$}}
187187
// GENERIC-NOT: #define __wasm_tail_call__ 1{{$}}

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ set(files
497497
__locale_dir/locale_base_api/fuchsia.h
498498
__locale_dir/locale_base_api/ibm.h
499499
__locale_dir/locale_base_api/musl.h
500-
__locale_dir/locale_base_api/newlib.h
501500
__locale_dir/locale_base_api/openbsd.h
502501
__locale_dir/locale_base_api/win32.h
503502
__locale_dir/locale_guard.h

libcxx/include/__locale_dir/locale_base_api.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
# include <__locale_dir/locale_base_api/ibm.h>
1616
#elif defined(__ANDROID__)
1717
# include <__locale_dir/locale_base_api/android.h>
18-
#elif defined(__sun__)
19-
# include <__locale_dir/locale_base_api/solaris.h>
20-
#elif defined(_NEWLIB_VERSION)
21-
# include <__locale_dir/locale_base_api/newlib.h>
2218
#elif defined(__OpenBSD__)
2319
# include <__locale_dir/locale_base_api/openbsd.h>
2420
#elif defined(__Fuchsia__)

libcxx/include/__locale_dir/locale_base_api/newlib.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)