Skip to content

Commit c9ebf7b

Browse files
author
ripley
committed
update for Apple clang
git-svn-id: https://svn.r-project.org/R/trunk@87487 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 6df8c84 commit c9ebf7b

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

doc/manual/R-exts.texi

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9921,6 +9921,11 @@ problems in the system software and not the package nor @R{}. A couple
99219921
of reports have been of `heap-use-after-free' errors in the X11
99229922
libraries called from Tcl/Tk.
99239923

9924+
Apple provide a version of the address sanitizer in recent versions of
9925+
its C/C++ compiler. This will proably give messages about
9926+
`malloc: nano zone abandoned' which are innocuous and can be suppressed
9927+
by setting environmant variable @env{MallocNanoZone} to @code{0}.
9928+
@c https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space
99249929

99259930
@c 1-item menu: kept to avoid spurious warning from makeinfo 6.8/7.0
99269931
@menu
@@ -9942,7 +9947,7 @@ variable
99429947
ASAN_OPTIONS='detect_leaks=1'
99439948
@end example
99449949
@noindent
9945-
However, this was made the default as from @command{clang} 3.5 and
9950+
However, this was made the default as from LLVM @command{clang} 3.5 and
99469951
@command{gcc} 5.1.0.
99479952

99489953
When @abbr{LSan} is enabled, leaks give the process a failure error status (by
@@ -9958,6 +9963,9 @@ checking use
99589963
setenv ASAN_OPTIONS 'alloc_dealloc_mismatch=0:detect_leaks=0:detect_odr_violation=0'
99599964
@end example
99609965

9966+
The leak sanitizer is not part of @abbr{ASan} in the Apple
9967+
@command{clang} implementation.
9968+
99619969
@abbr{LSan} also has a `stand-alone' mode where it is compiled in using
99629970
@option{-fsanitize=leak} and avoids the run-time overhead of @abbr{ASan}.
99639971

@@ -10098,8 +10106,8 @@ For more details on the topic see
1009810106
It may or may not be possible to build @R{} itself with
1009910107
@option{-fsanitize=undefined}: problems have in the past been seen with
1010010108
@abbr{OpenMP}-using code with @command{gcc} but there has been success
10101-
with @command{clang} up to version 16.. However, problems have been
10102-
seen with @command{clang} 17 and later, including missing entry points
10109+
with LLVM @command{clang} up to version 16.. However, problems have been
10110+
seen with LLVM @command{clang} 17 and later, including missing entry points
1010310111
and @R{} builds hanging. What has succeeded is to use @abbr{UBSAN} just for
1010410112
the package under test (and not in combination with @abbr{ASAN}). To do so,
1010510113
check with an unaltered @R{}, using a custom @file{Makevars} file
@@ -10125,16 +10133,29 @@ provided @code{UBSAN_DIR} is added to the runtime library path (as shown
1012510133
or using @env{LD_LIBRARY_PATH}). @strong{N.B.}: The details, especially
1012610134
the paths used, have changed several times recently.
1012710135

10136+
Apple provides a version of the undefined behaviour sanitizer in recent
10137+
versions of its C/C++ compiler. @R{} was built with Apple
10138+
@command{clang} 16 with @file{config.site} containing
10139+
@noindent
10140+
@example
10141+
CC="clang -fsanitize=address,undefined"
10142+
CXX="clang++ -fsanitize=address,undefined"
10143+
@end example
10144+
@noindent
10145+
and passed its checks.
10146+
1012810147
@node Other analyses with `clang'
1012910148
@subsection Other analyses with `clang'
1013010149

10131-
Recent versions of @command{clang} on @cputype{x86_64} Linux have
10132-
`@I{ThreadSanitizer}' (@uref{https://github.com/google/sanitizers/wiki#threadsanitizer}),
10133-
a `data race detector for C/C++ programs', and `@I{MemorySanitizer}'
10150+
Recent versions of LLVM @command{clang} on Linux have
10151+
`@I{ThreadSanitizer}'
10152+
(@uref{https://github.com/google/sanitizers/wiki#threadsanitizer}), a
10153+
`data race detector for C/C++ programs', and `@I{MemorySanitizer}'
1013410154
(@uref{https://clang.llvm.org/docs/MemorySanitizer.html},
10135-
@uref{https://github.com/google/sanitizers})
10136-
for the detection of uninitialized memory. Both are based on and
10137-
provide similar functionality to tools in @command{valgrind}.
10155+
@uref{https://github.com/google/sanitizers}) for the detection of
10156+
uninitialized memory. Both are based on and provide similar
10157+
functionality to tools in @command{valgrind}. The @I{ThreadSanitizer}
10158+
is also available for Apple @command{clang} on macOS.
1013810159

1013910160
@command{clang} has a `Static Analyzer' which can be run on the source
1014010161
files during compilation: see @uref{https://clang-analyzer.llvm.org/}.

0 commit comments

Comments
 (0)