This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Android build cleanup.
ClosedPublic

Authored by eugenis on Sep 23 2014, 9:02 AM.

Details

Reviewers
glider
samsonov
Summary
  • Detect Android toolchain target arch and set runtime library name appropriately.
  • Merged a lot of Android and non-Android code paths.
  • Android is only supported in standalone build of compiler-rt now.
  • Linking lsan-common in ASan-Android (makes lsan annotations work).
  • Relying on -fsanitize=address linker flag when building tests (again, unification with non-Android path).
  • Runtime library moved from lib/asan to lib/linux for some reason. It's probably better this way.

Btw, why separate compiler setting for tests? Will it go away when we switch to standalone build?

Diff Detail

Event Timeline

eugenis updated this revision to Diff 13996.Sep 23 2014, 9:02 AM
eugenis retitled this revision from to [sanitizer] Android build cleanup..
eugenis updated this object.
eugenis edited the test plan for this revision. (Show Details)
eugenis added a reviewer: samsonov.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: Unknown Object (MLST).
glider added a subscriber: glider.Sep 24 2014, 5:55 AM

Some drive-by comments.
This stuff doesn't work for x86-Android, does it?

cmake/config-ix.cmake
95

"detect_target_arch" looks much like "test_target_arch" below, but it populates COMPILER_RT_SUPPORTED_ARCH with several arches instead of only one. I think we need a better name for "detect_target_arch"

122

Is this an arch suffix or an OS suffix? Should the suffix be present on Linux or other OSes?

lib/asan/scripts/asan_device_setup
110–111

So the android runtime is in lib/linux? Why?

lib/asan/tests/CMakeLists.txt
76

Please remove the commented lines (if you meant to) and fix indentation.
Do you still need the comment above now?

93

TODO(eugenis)

lib/sanitizer_common/tests/CMakeLists.txt
62

Link to the bug? (and in other places as well)

test/asan/CMakeLists.txt
10

You'd better list the possible 64-bit arches here to make sure we bail out if an unsupported arch comes around.

18–19

Pls indent this block.

34

Two spaces before the comment, please

test/asan/lit.cfg
58

Are changes to this file related to the CMake changes? If no, can they be landed separately?

eugenis updated this revision to Diff 14037.Sep 24 2014, 7:08 AM
eugenis added a reviewer: glider.
eugenis set the repository for this revision to rL LLVM.
eugenis removed a subscriber: glider.
eugenis added inline comments.
cmake/config-ix.cmake
95

Note the elseif()s. It's at most one arch.
Can you suggest a better name? IMO it is quite good - the function examines compiler output with default flags and detect the target architecture.

122

It's the suffix in libclang_rt.asan-${arch}- <<here>> .so
Renamed to OS_SUFFIX.

lib/asan/scripts/asan_device_setup
110–111

because it's arm-linux-androideabi, so the runtime goes to lib/linux/libclang_rt.asan-arm-android.so

lib/asan/tests/CMakeLists.txt
76

done
the comment is no longer true, removed

lib/sanitizer_common/tests/CMakeLists.txt
62

There is no bug, just a bunch of mail threads.

test/asan/CMakeLists.txt
10

done

18–19

done

34

done

test/asan/lit.cfg
58

Yes. No.
CAN_TARGET_arm_android used to be "TRUE"
Now ANDROID is "1".

glider accepted this revision.Sep 24 2014, 7:19 AM
glider edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 24 2014, 7:19 AM
samsonov edited edge metadata.Sep 24 2014, 7:45 PM

LGTM. This is really nice.

cmake/Modules/AddCompilerRT.cmake
46–47

While you're here, please mention OUTPUT_NAME in the comment.

cmake/config-ix.cmake
95

Cool. We'd definitely need to do smth. similar for non-Andorid case.

lib/asan/tests/CMakeLists.txt
83

Consider using append_if here as well.

94

incorrect variable name: should be ASAN_UNITTEST_NOINST_LIBS

95

and here

lib/sanitizer_common/tests/CMakeLists.txt
63

append_if

samsonov accepted this revision.Sep 24 2014, 7:45 PM
samsonov edited edge metadata.
eugenis updated this revision to Diff 14073.Sep 25 2014, 7:52 AM
eugenis edited edge metadata.
eugenis added inline comments.
cmake/Modules/AddCompilerRT.cmake
46–47

done

lib/asan/tests/CMakeLists.txt
83

done

94

good catch

eugenis closed this revision.Sep 29 2014, 6:29 AM

Thanks for the review.
Committed in r218605.