This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI)
ClosedPublic

Authored by tejohnson on Jul 6 2020, 11:57 AM.

Details

Summary

This refactors some common support related to shadow memory setup from
asan and hwasan into sanitizer_common. This should not only reduce code
duplication but also make these facilities available for new compiler-rt
uses (e.g. heap profiling).

In most cases the separate copies of the code were either identical, or
at least functionally identical. A few notes:

In ProtectGap, the asan version checked the address against an upper
bound (kZeroBaseMaxShadowStart, which is (2^18). I have created a copy
of kZeroBaseMaxShadowStart in hwasan_mapping.h, with the same value, as
it isn't clear why that code should not do the same check. If it
shouldn't, I can remove this and guard this check so that it only
happens for asan.

In asan's InitializeShadowMemory, in the dynamic shadow case it was
setting asan_shadow_memory_dynamic_address to 0 (which then sets both
macro SHADOW_OFFSET as well as macro kLowShadowBeg to 0) before calling
FindDynamicShadowStart(). AFAICT this is only needed because
FindDynamicShadowStart utilizes kHighShadowEnd to
get the shadow size, and kHighShadowEnd is a macro invoking
MEM_TO_SHADOW(kHighMemEnd) which in turn invokes:
(((kHighMemEnd) >> SHADOW_SCALE) + (SHADOW_OFFSET))
I.e. it computes the shadow space needed by kHighMemEnd (the shift), and
adds the offset. Since we only want the shadow space here, the earlier
setting of SHADOW_OFFSET to 0 via
asan_shadow_memory_dynamic_address
accomplishes this. In the hwasan version, it simply gets the shadow
space via "MemToShadowSize(kHighMemEnd)", where MemToShadowSize just
does the shift. I've simplified the asan handling to do the same
thing, and therefore was able to remove the setting of the SHADOW_OFFSET
via __asan_shadow_memory_dynamic_address to 0.

Diff Detail

Event Timeline

tejohnson created this revision.Jul 6 2020, 11:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2020, 11:57 AM
Herald added subscribers: Restricted Project, dberris. · View Herald Transcript
tejohnson marked 3 inline comments as done.Jul 6 2020, 12:06 PM

A couple comments and a question below. Also, what is the best way to test this for mac and win? I tried to find some directions for doing some cross-compiler builds of compiler-rt at least, but couldn't find something clear and definitive.

compiler-rt/lib/asan/asan_linux.cpp
122

The code in asan is multiplying the mmap granularity by 8, whereas the hwasan version shifts it by kShadowScale. I wasn't sure if the 8 here is supposed to be equivalent to a left shift by the shadow scale (which is typically 3 in asan), or is specifically hardcoded separately not using SHADOW_SCALE since it could be something other than 3 in some cases (e.g. 5 for myriad, or user set via ASAN_SHADOW_SCALE). Depending on what was intended here, I would keep the hardcoding of "3" passed to my refactored MapDynamicShadow, or change that to SHADOW_SCALE.

compiler-rt/lib/asan/asan_shadow_setup.cpp
102

See patch description on why I removed this code.

compiler-rt/lib/hwasan/hwasan_mapping.h
40

Copied from the same values in asan. See the patch description for more info. Would it be better to keep a single copy of these values in sanitizer_common?

hctim added a subscriber: hctim.Jul 6 2020, 1:46 PM
dmajor added a subscriber: dmajor.Jul 7 2020, 9:38 AM
kcc added a comment.Jul 8 2020, 6:41 PM

No strong opinion on whether this needs to be done.
If you feel strong, and if it will help, sure. (you may indeed have to test on various platforms, or rely on the post-commit bots)
OTOH, the new profiler should not require all of these functions, you can probably get away with a custom-tailored variant of MapDynamicShadow.

(Vitaly, please do the review)

compiler-rt/lib/asan/asan_linux.cpp
122

I frankly don't remember :(

vitalybuka added inline comments.Jul 9 2020, 2:53 AM
compiler-rt/lib/asan/asan_linux.cpp
103

MemToShadowSize(GetHighMemEnd(SHADOW_SCALE))

compiler-rt/lib/hwasan/hwasan.cpp
289

why it's gone?

compiler-rt/lib/sanitizer_common/sanitizer_common.h
123–147

Shadow is specific to only some sanitizers, so I don't like to have it in /sanitizer_common/
Also we have msan/tsan/dfsan with different shadows for which is not clear if we can reuse these functions without exposing more particular sanitizer details. Maybe keeping all shadow code with some redundancy but independent is going to be easier to maintain in long term.

Anyway, if we still go this way, maybe we put code into sanitizer_common/sanitizer_shadow_* files ?

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
204

I think it's going to be cleaner if we replace
uptr mmap_alignment_scale, uptr shadow_base_alignment
with
uptr shadow_scale, uptr min_shadow_base_alignment
and adjust calculations accordingly:
const uptr alignment = max(granularity << shadow_scale, min_shadow_base_alignment)

it should be copied into mac and win, even if they use 0 there, for consistency

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1122

SHADOW_SCALE is undefined here

1131

kHighShadowEnd and kHighMemEnd are undefined here

1132

because if kHighMemEnd here we need to return mapped size on all platforms :(

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
351

shadow_size_bytes is not used

353

CHECK_NE

357

kHighShadowEnd is asan constant
probably space_size should be calculated from shadow_size_bytes
same for mac version

vitalybuka added inline comments.Jul 9 2020, 3:07 AM
compiler-rt/lib/asan/asan_linux.cpp
122

It should be SHADOW_SCALE, myriad works only because it does not use dynamic shadow

tejohnson marked 6 inline comments as done.Jul 9 2020, 1:00 PM
tejohnson added inline comments.
compiler-rt/lib/asan/asan_linux.cpp
103

The MemToShadowSize facility currently only exists in hwasan, let me go ahead and add it to asan as well (I see I accidentally started referencing it in the asan_mac/win code!).

122

Ok thanks, I'll change the code to use that.

compiler-rt/lib/hwasan/hwasan.cpp
289

It is now embedded in the refactored code (similar to the way asan was doing the madvise calls). See ReserveShadowMemoryRange (the refactored one and the original asan one).

compiler-rt/lib/sanitizer_common/sanitizer_common.h
123–147

Also we have msan/tsan/dfsan with different shadows for which is not clear if we can reuse these functions without exposing more particular sanitizer details. Maybe keeping all shadow code with some redundancy but independent is going to be easier to maintain in long term.

I started to look at trying to coalesce some of the other *san shadow setup code with the *asan versions, but decided to punt on that, at least for now. There are a lot of things that looked similar there too, but not as much as in *asan. As I mentioned in my reply on the RFC just now, it seemed like a good idea to at least common the *asan versions since they were structured somewhat different but essentially functionally the same in almost every way, and it seemed confusing to have multiple versions that aren't obviously duplicates but in fact are.

That being said, I could have the new heap profiler duplicate them (at least the parts that I need) if that is much preferred. I don't technically need ProtectGap for the heap profiler, but it seems like a good thing to use at least while debugging the instrumentation code.

Anyway, if we still go this way, maybe we put code into sanitizer_common/sanitizer_shadow_* files ?

I can do that. There is a small amount of shadow setup code already here, I could move that too.

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
204

Sounds good

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1122

For this and other comments on the win/mac version, obviously I didn't do a very careful job of moving this code from asan to sanitizer_common. =( Will work on fixing those and need to find a way to at least compile these codes for those platforms to flush out these issues. If you have any pointers on setting up a cross compile of this code on a linux system please let me know.

vitalybuka added inline comments.Jul 9 2020, 5:39 PM
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1122

I have setup to compile on Win. I can try updated patch and fix it up if necessary.
Unfortunately I have no OSX but it should be possible to find someone on the team.
Still there are other platforms where we can only rely on build bots.

tejohnson marked 2 inline comments as done.Jul 13 2020, 8:59 PM

I have addressed the other comments but not yet moved to any new files (e.g. sanitizer_common/sanitizer_shadow_* as suggested). Will do that as a follow up change so it is easier to see the actual code change diffs between this version and the last. Did you want me to just move the stuff from sanitizer_common.[h,cpp] to new sanitzer_shadow_common.* files, or also out of e.g. sanitizer_win.cpp to sanitizer_shadow_win.cpp, etc?

Also, I did manually force the new functions in sanitizer_win.cpp and sanitizer_mac.cpp to compile to ensure that I fixed all the references, but that's the extent of what I was able to test there so far.

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1131

Where it was using kHighShadowEnd we can just recompute from the new high mem (since at this point the offset was 0 so it is just doing the shift). For kHighMemEnd, it is more difficult since this code is updating the value. I didn't find a way around this besides passing in a reference and updating it if needed.

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
357

Yep, fixed.

tejohnson updated this revision to Diff 277649.Jul 13 2020, 9:00 PM

Address comments

Looks like FUCHSIA is OK and does not call these stuff

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
191

UnmapFromTo and MapDynamicShadow must go into sanitizer_linux_libcdep.cpp as libcdep applies to windows/mac and other

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
356

Max<uptr> and below, or it does not compile on windows
1UL is 32bit here

vitalybuka added inline comments.Jul 15 2020, 5:45 AM
compiler-rt/lib/hwasan/hwasan_mapping.h
43

Why do we need them in the header? I don't see these constants used outside hwasan_linux.
If this is to pass kHighMemEnd into high_mem_end, then we can make it optional
uptr* high_mem_end = null

compiler-rt/lib/sanitizer_common/sanitizer_common.h
126

Could you please keep this one in asan/hwasan for now.
It looks like a random mem-region related code moved here when the rest is still there.

135

and maybe drop default 0 and make out argument the last one?

Also high_mem_end in this interface looks unrelated. Maybe mapped shadow size? Better to land as is and followup later.

tejohnson marked 3 inline comments as done.Jul 15 2020, 5:01 PM
tejohnson added inline comments.
compiler-rt/lib/hwasan/hwasan_mapping.h
43

You are right, the constants kZeroBaseShadowStart and kZeroBaseMaxShadowStart are only used in hwasan_linux.cpp, so I can move them there (I put them here initially since they are in asan_mapping.h there).
For kHighMemEnd etc, I made them extern so that they could be passed tp MapDynamicShadow in hwasan_dynamic_shadow.cpp. While that arg is only needed right now on mac, and hwasan is only supporting linux, does it make sense to be consistent (will hwasan ever support mac)?

compiler-rt/lib/sanitizer_common/sanitizer_common.h
126

ok, there is only one call from each of those, so I can move it back.

135

Also high_mem_end in this interface looks unrelated. Maybe mapped shadow size? Better to land as is and followup later.

I'm not sure I understand the comment about it being unrelated, or what you are asking me to do here? Do you mean just change the parameter name?

tejohnson marked 4 inline comments as done.Jul 15 2020, 6:39 PM
tejohnson added inline comments.
compiler-rt/lib/hwasan/hwasan_mapping.h
43

For now I have moved the kZeroBase* constants to hwasan_linux.h, but left the new externs.

compiler-rt/lib/sanitizer_common/sanitizer_common.h
135

Made the new out parameter last.

tejohnson updated this revision to Diff 278349.Jul 15 2020, 6:40 PM

Address comments

vitalybuka accepted this revision.Jul 15 2020, 7:02 PM

Thank you! LGTM

Windows should work. For the rest we need to rely on bots.

compiler-rt/lib/sanitizer_common/sanitizer_common.h
135

I'm not sure I understand the comment about it being unrelated, or what you are asking me to do here? Do you mean just change the parameter name?

Looking at function interface, it's about shadow. For reader is likely non-intuitive to understand why there is high_mem_end out parameter.
Pure renaming is not going to help. Maybe out parameter with actually mapped side.
Anyway I am not sure what could be a nicer approach for now. So we can keep it as-is and maybe fix later.

btw. it could be nice to write something into high_mem_end, even just 0, on other platforms.

This revision is now accepted and ready to land.Jul 15 2020, 7:02 PM
tejohnson marked an inline comment as done.Jul 15 2020, 7:23 PM

Thank you! LGTM

Windows should work. For the rest we need to rely on bots.

Great thanks - did you still want me to move the shadow functions to some new files (e.g. sanitizer_common/sanitizer_shadow_{linux_libcdep, win, mac}.cpp before committing?

compiler-rt/lib/sanitizer_common/sanitizer_common.h
135

btw. it could be nice to write something into high_mem_end, even just 0, on other platforms.

That would actually break things since we are passing in kHighMemEnd, and don't want it reset if it shouldn't change.

Thank you! LGTM

Windows should work. For the rest we need to rely on bots.

Great thanks - did you still want me to move the shadow functions to some new files (e.g. sanitizer_common/sanitizer_shadow_{linux_libcdep, win, mac}.cpp before committing?

maybe better to land and fix if anything broken, and maybe move later. I guess I don't mind if we keep them as-is.

This revision was automatically updated to reflect the committed changes.

Hi, I think this is breaking our Android bots: https://crbug.com/1106482

FAILED: lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o
/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/clang++ -DHWASAN_WITH_INTERCEPTORS=1 -I/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/.. --target=aarch64-linux-android21 --sysroot=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -fPIC -ffreestanding -MD -MT lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -MF lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o.d -o lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -c /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp:63:3: error: use of undeclared identifier 'UnmapFromTo'

UnmapFromTo(shadow_start + shadow_size, shadow_start + premap_shadow_size);

Hi, I think this is breaking our Android bots: https://crbug.com/1106482

FAILED: lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o
/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/clang++ -DHWASAN_WITH_INTERCEPTORS=1 -I/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/.. --target=aarch64-linux-android21 --sysroot=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -fPIC -ffreestanding -MD -MT lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -MF lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o.d -o lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -c /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp:63:3: error: use of undeclared identifier 'UnmapFromTo'

UnmapFromTo(shadow_start + shadow_size, shadow_start + premap_shadow_size);

Looking...

Hi, I think this is breaking our Android bots: https://crbug.com/1106482

FAILED: lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o
/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/clang++ -DHWASAN_WITH_INTERCEPTORS=1 -I/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/.. --target=aarch64-linux-android21 --sysroot=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -fPIC -ffreestanding -MD -MT lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -MF lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o.d -o lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -c /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp:63:3: error: use of undeclared identifier 'UnmapFromTo'

UnmapFromTo(shadow_start + shadow_size, shadow_start + premap_shadow_size);

Looking...

Have a simple fix, just testing it now.

Hi, I think this is breaking our Android bots: https://crbug.com/1106482

FAILED: lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o
/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/clang++ -DHWASAN_WITH_INTERCEPTORS=1 -I/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/.. --target=aarch64-linux-android21 --sysroot=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -fPIC -ffreestanding -MD -MT lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -MF lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o.d -o lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_dynamic_shadow.cpp.o -c /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp:63:3: error: use of undeclared identifier 'UnmapFromTo'

UnmapFromTo(shadow_start + shadow_size, shadow_start + premap_shadow_size);

Looking...

Have a simple fix, just testing it now.

I just committed a fix at c489ae2a8605761d784171ff7152dfc75ab7c064. Please let me know if you are still having any problems.

Thanks! I'll let them cycle and let you know if anything is still broken.

ro added a subscriber: ro.Jul 17 2020, 12:58 AM

This patch broke the Solaris/sparcv9 buildbot. Patch posted: [[ https://reviews.llvm.org/D84004 | [compiler-rt][asan] Define MemToShadowSize for sparc64 ]].

Most likely Myriad2 is likewise affected.

In D83247#2157632, @ro wrote:

This patch broke the Solaris/sparcv9 buildbot. Patch posted: [[ https://reviews.llvm.org/D84004 | [compiler-rt][asan] Define MemToShadowSize for sparc64 ]].

Most likely Myriad2 is likewise affected.

Thanks for the quick fix. You are right, it looks like a fix is needed for asan_mapping_myriad.h as well (actually I will probably just move the def of this function to a different place in asan_mapping.h to fix all of them). I did not see any bot failures reported to me for either sparc or myriad - is there a myriad bot?

phosek added a subscriber: phosek.Jul 17 2020, 1:25 PM

This broke Fuchsia's toolchain build which is now failing with the following error:

FAILED: /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so 
: && /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/./bin/clang++ --target=x86_64-unknown-fuchsia --sysroot=/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot -fPIC --target=x86_64-unknown-fuchsia -I/b/s/w/ir/k/cipd/sdk/pkg/fdio/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins=../recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins -ffile-prefix-map=/b/s/w/ir/k/llvm-project/= -no-canonical-prefixes -Wall -std=c++14 -Wno-unused-parameter -O2 -g  -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib    -nodefaultlibs -Wl,-z,text -Wl,-z,defs,-z,now,-z,relro -Wl,--version-script,/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/ubsan/clang_rt.ubsan_standalone-dynamic-x86_64.vers -shared -Wl,-soname,libclang_rt.ubsan_standalone.so -o /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector1.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector2.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_errno.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_file.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flag_parser.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libignore.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_s390.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_persistent_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_freebsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_printf.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_bsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_rtems.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_suppressions.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_tls_get_addr.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_thread_registry.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_type_traits.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_termination.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_allocator_checks.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_mac_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sancov_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_libcdep_new.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_win_sections.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_allocator_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stackdepot.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_printer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_sparc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libbacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_markup.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_diag.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_init.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_flags.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_handlers.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_monitor.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_value.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_handlers_cxx.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_diag_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_init_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_signals_standalone.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_mac.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_win.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_type_test.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.x86_64.dir/dummy.cpp.obj -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib  -L/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot/lib /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libunwind.a /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libc++abi.so.1.0 -lc -lzircon -ldl -lrt -lpthread /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.builtins.a -lc && :
ld.lld: error: undefined symbol: __sanitizer::MmapFixedSuperNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:150 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:150)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::DontDumpShadowMemory(unsigned long, unsigned long)
>>> referenced by sanitizer_common_libcdep.cpp:159 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:159)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::MmapFixedNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:151 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:151)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

That function isn't used on Fuchsia, but it seems like --gc-sections isn't being used here causing the failure. It might be sufficient to just add #if !SANITIZER_FUCHSIA around this function as a workaround.

This broke Fuchsia's toolchain build which is now failing with the following error:

FAILED: /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so 
: && /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/./bin/clang++ --target=x86_64-unknown-fuchsia --sysroot=/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot -fPIC --target=x86_64-unknown-fuchsia -I/b/s/w/ir/k/cipd/sdk/pkg/fdio/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins=../recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins -ffile-prefix-map=/b/s/w/ir/k/llvm-project/= -no-canonical-prefixes -Wall -std=c++14 -Wno-unused-parameter -O2 -g  -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib    -nodefaultlibs -Wl,-z,text -Wl,-z,defs,-z,now,-z,relro -Wl,--version-script,/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/ubsan/clang_rt.ubsan_standalone-dynamic-x86_64.vers -shared -Wl,-soname,libclang_rt.ubsan_standalone.so -o /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector1.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector2.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_errno.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_file.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flag_parser.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libignore.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_s390.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_persistent_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_freebsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_printf.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_bsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_rtems.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_suppressions.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_tls_get_addr.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_thread_registry.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_type_traits.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_termination.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_allocator_checks.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_mac_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sancov_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_libcdep_new.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_win_sections.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_allocator_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stackdepot.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_printer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_sparc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libbacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_markup.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_diag.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_init.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_flags.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_handlers.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_monitor.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_value.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_handlers_cxx.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_diag_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_init_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_signals_standalone.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_mac.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_win.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_type_test.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.x86_64.dir/dummy.cpp.obj -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib  -L/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot/lib /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libunwind.a /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libc++abi.so.1.0 -lc -lzircon -ldl -lrt -lpthread /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.builtins.a -lc && :
ld.lld: error: undefined symbol: __sanitizer::MmapFixedSuperNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:150 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:150)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::DontDumpShadowMemory(unsigned long, unsigned long)
>>> referenced by sanitizer_common_libcdep.cpp:159 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:159)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::MmapFixedNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:151 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:151)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

That function isn't used on Fuchsia, but it seems like --gc-sections isn't being used here causing the failure. It might be sufficient to just add #if !SANITIZER_FUCHSIA around this function as a workaround.

Sorry about that! I see that this code when it was in asan before my patch was guarded by:
#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
so probably I should guard it the same way here.

Also, while the error above doesn't show any undefs coming from ProtectGap, I'm assuming that will give the same issue as it was moved to the same place and references MmapFixedNoAccess. Both were guarded before in asan and I'll add the guard here and commit shortly. I guess hwasan wasn't built on Fuchscia since it didn't have the guards around its version?

Sorry about that! I see that this code when it was in asan before my patch was guarded by:
#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
so probably I should guard it the same way here.

Also, while the error above doesn't show any undefs coming from ProtectGap, I'm assuming that will give the same issue as it was moved to the same place and references MmapFixedNoAccess. Both were guarded before in asan and I'll add the guard here and commit shortly. I guess hwasan wasn't built on Fuchscia since it didn't have the guards around its version?

Not yet, we plan on porting HWASan to Fuchsia in the next few months.

This broke Fuchsia's toolchain build which is now failing with the following error:

FAILED: /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so 
: && /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/./bin/clang++ --target=x86_64-unknown-fuchsia --sysroot=/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot -fPIC --target=x86_64-unknown-fuchsia -I/b/s/w/ir/k/cipd/sdk/pkg/fdio/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins=../recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins -ffile-prefix-map=/b/s/w/ir/k/llvm-project/= -no-canonical-prefixes -Wall -std=c++14 -Wno-unused-parameter -O2 -g  -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib    -nodefaultlibs -Wl,-z,text -Wl,-z,defs,-z,now,-z,relro -Wl,--version-script,/b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/ubsan/clang_rt.ubsan_standalone-dynamic-x86_64.vers -shared -Wl,-soname,libclang_rt.ubsan_standalone.so -o /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.ubsan_standalone.so compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector1.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector2.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_errno.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_file.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flag_parser.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libignore.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_s390.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_persistent_allocator.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_freebsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_netbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_openbsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_posix.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_printf.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_common.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_bsd.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_linux.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_rtems.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_solaris.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_stoptheworld_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_suppressions.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_tls_get_addr.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_thread_registry.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_type_traits.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_termination.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_allocator_checks.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_mac_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sancov_flags.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_fuchsia.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_libcdep_new.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.x86_64.dir/sanitizer_coverage_win_sections.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_allocator_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stackdepot.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_printer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_sparc.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libbacktrace.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_mac.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_markup.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_posix_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_win.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_linux_libcdep.cpp.obj compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_unwind_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_diag.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_init.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_flags.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_handlers.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_monitor.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan.x86_64.dir/ubsan_value.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_handlers_cxx.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_itanium.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_win.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_diag_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_init_standalone.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_standalone.x86_64.dir/ubsan_signals_standalone.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_mac.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_win.cpp.obj compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_type_test.cpp.obj compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.x86_64.dir/dummy.cpp.obj -L/b/s/w/ir/k/cipd/sdk/arch/x64/lib  -L/b/s/w/ir/k/cipd/sdk/arch/x64/sysroot/lib /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libunwind.a /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/x86_64-unknown-fuchsia/c++/libc++abi.so.1.0 -lc -lzircon -ldl -lrt -lpthread /b/s/w/ir/k/recipe_cleanup/clangro8g9J/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.builtins.a -lc && :
ld.lld: error: undefined symbol: __sanitizer::MmapFixedSuperNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:150 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:150)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::DontDumpShadowMemory(unsigned long, unsigned long)
>>> referenced by sanitizer_common_libcdep.cpp:159 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:159)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))

ld.lld: error: undefined symbol: __sanitizer::MmapFixedNoReserve(unsigned long, unsigned long, char const*)
>>> referenced by sanitizer_common_libcdep.cpp:151 (compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp:151)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_common_libcdep.cpp.obj:(__sanitizer::ReserveShadowMemoryRange(unsigned long, unsigned long, char const*, bool))
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

That function isn't used on Fuchsia, but it seems like --gc-sections isn't being used here causing the failure. It might be sufficient to just add #if !SANITIZER_FUCHSIA around this function as a workaround.

Sorry about that! I see that this code when it was in asan before my patch was guarded by:
#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
so probably I should guard it the same way here.

Also, while the error above doesn't show any undefs coming from ProtectGap, I'm assuming that will give the same issue as it was moved to the same place and references MmapFixedNoAccess. Both were guarded before in asan and I'll add the guard here and commit shortly. I guess hwasan wasn't built on Fuchscia since it didn't have the guards around its version?

Fixed in db15b8ab90793e3707f72e7668c3844922fdf356

Thanks for a quick fix, I can confirm that it worked.