Android clang doesn't include sanitizer runtimes
Categories
(Firefox Build System :: Toolchains, enhancement)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: truber, Assigned: truber)
References
Details
Attachments
(1 file)
To compile for Android with sanitizers, we need the toolchain to contain the runtimes. The NDK does contain sanitizers, and fennec can be built with them (bug 1482167), but our toolchain does not currently build the sanitizer runtimes.
I've tried modifying build-clang.py:
diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py
index 99a5ed1..6d1e7e5 100755
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -293,7 +293,8 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
"-DRUNTIMES_%s_CMAKE_SHARED_LINKER_FLAGS=%s" % (target, android_link_flags),
"-DRUNTIMES_%s_CMAKE_SYSROOT=%s" % (target, sysroot_dir),
"-DRUNTIMES_%s_COMPILER_RT_BUILD_PROFILE=ON" % target,
- "-DRUNTIMES_%s_COMPILER_RT_BUILD_SANITIZERS=OFF" % target,
+ "-DRUNTIMES_%s_COMPILER_RT_BUILD_SANITIZERS=ON" % target,
+ "-DRUNTIMES_%s_SANITIZER_ALLOW_CXXABI=OFF" % target,
"-DRUNTIMES_%s_COMPILER_RT_BUILD_LIBFUZZER=OFF" % target,
"-DRUNTIMES_%s_COMPILER_RT_INCLUDE_TESTS=OFF" % target,
"-DRUNTIMES_%s_LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" % target,
but when I build clang-7-android.json, I get this error in stage 2:
FAILED: /home/user/src/m/u/build/build-clang/build-clang/build/stage2/build/./bin/clang++ --target=i686-linux-android --sysroot=/home/user/src/m/u/android-ndk/platforms/android-16/arch-x86 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/user/src/m/u/build/build-clang/build-clang/src/llvm/runtimes/compiler-rt/lib/interception/.. -isystem /home/user/src/m/u/android-ndk/sysroot/usr/include/i686-linux-android -isystem /home/user/src/m/u/android-ndk/sysroot/usr/include --gcc-toolchain=/home/user/src/m/u/android-ndk/toolchains/x86-4.9/prebuilt/linux-x86_64 -D__ANDROID_API__=16 -fPIC -Qunused-arguments -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++11 -Wno-unused-parameter -O3 -DNDEBUG -isystem /home/user/src/m/u/android-ndk/sysroot/usr/include/i686-linux-android -isystem /home/user/src/m/u/android-ndk/sysroot/usr/include --gcc-toolchain=/home/user/src/m/u/android-ndk/toolchains/x86-4.9/prebuilt/linux-x86_64 -D__ANDROID_API__=16 -fPIC -Qunused-arguments -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++11 -Wno-unused-parameter -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 -MD -MT compiler-rt/lib/interception/CMakeFiles/RTInterception.i386.dir/interception_type_test.cc.o -MF compiler-rt/lib/interception/CMakeFiles/RTInterception.i386.dir/interception_type_test.cc.o.d -o compiler-rt/lib/interception/CMakeFiles/RTInterception.i386.dir/interception_type_test.cc.o -c /home/user/src/m/u/build/build-clang/build-clang/src/llvm/runtimes/compiler-rt/lib/interception/interception_type_test.cc
/home/user/src/m/u/build/build-clang/build-clang/src/llvm/runtimes/compiler-rt/lib/interception/interception_type_test.cc:37:1: error: 'assertion_failed__37' declared as an array with a negative size
COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This happens for both i686 and arm targets, but aarch64 builds and produces lib64/clang/7.0.1/lib/linux/libclang_rt.asan-aarch64-android.so
. x86_64 also works if I add it to the config.
I've opened https://github.com/google/sanitizers/issues/1061 for this.
Assignee | ||
Updated•5 years ago
|
Comment 1•5 years ago
|
||
It looks like I simply missed adding -DANDROID=1 when building runtimes in bug 1504147. I'll fix this in a dependent bug.
Assignee | ||
Comment 2•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
(In reply to Chris Manchester (:chmanchester) from comment #1)
It looks like I simply missed adding -DANDROID=1 when building runtimes in bug 1504147. I'll fix this in a dependent bug.
Thanks! That fixed it.
Assignee | ||
Updated•5 years ago
|
Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b6ac884371a6
Enable sanitizer runtimes in Android clang. r=chmanchester
Comment 5•5 years ago
|
||
bugherder |
Description
•