Skip to content

Commit dc3069d

Browse files
committed
[NFC][hwasan][Fuchsia] Instead wrap contents of InitLoadedGlobals with if constexpr (!SANITIZER_FUCHSIA)
This prevents spamming the build log with unused InitLoadedGlobals when building fuchsia runtimes. Differential Revision: https://reviews.llvm.org/D150737
1 parent 0e66105 commit dc3069d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

compiler-rt/lib/hwasan/hwasan.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,20 @@ static bool InitializeSingleGlobal(const hwasan_global &global) {
290290
}
291291

292292
static void InitLoadedGlobals() {
293-
dl_iterate_phdr(
294-
[](dl_phdr_info *info, size_t /* size */, void * /* data */) -> int {
295-
for (const hwasan_global &global : HwasanGlobalsFor(
296-
info->dlpi_addr, info->dlpi_phdr, info->dlpi_phnum))
297-
InitializeSingleGlobal(global);
298-
return 0;
299-
},
300-
nullptr);
293+
// Fuchsia's libc provides a hook (__sanitizer_module_loaded) that runs on
294+
// the startup path which calls into __hwasan_library_loaded on all
295+
// initially loaded modules, so explicitly registering the globals here
296+
// isn't needed.
297+
if constexpr (!SANITIZER_FUCHSIA) {
298+
dl_iterate_phdr(
299+
[](dl_phdr_info *info, size_t /* size */, void * /* data */) -> int {
300+
for (const hwasan_global &global : HwasanGlobalsFor(
301+
info->dlpi_addr, info->dlpi_phdr, info->dlpi_phnum))
302+
InitializeSingleGlobal(global);
303+
return 0;
304+
},
305+
nullptr);
306+
}
301307
}
302308

303309
// Prepare to run instrumented code on the main thread.
@@ -364,13 +370,7 @@ __attribute__((constructor(0))) void __hwasan_init() {
364370
DisableCoreDumperIfNecessary();
365371

366372
InitInstrumentation();
367-
if constexpr (!SANITIZER_FUCHSIA) {
368-
// Fuchsia's libc provides a hook (__sanitizer_module_loaded) that runs on
369-
// the startup path which calls into __hwasan_library_loaded on all
370-
// initially loaded modules, so explicitly registering the globals here
371-
// isn't needed.
372-
InitLoadedGlobals();
373-
}
373+
InitLoadedGlobals();
374374

375375
// Needs to be called here because flags()->random_tags might not have been
376376
// initialized when InitInstrumentation() was called.

0 commit comments

Comments
 (0)