> Note that ASan tests on Android require llvm-symbolizer binary.That's a really good point. And I see that llvm-symbolizer can't just
be pulled into compiler-rt because it has dependencies on DebugInfo,
Object, and Support libraries.
This throws a big wrench in Alexey's plan to have the native
compiler-rt build generate the cross-compiled binaries for all
supported targets. We would need to do the same in the llvm repo.
The alternative is to run a separate cross-compiled build for each
architecture. :-/
Alexey, Evgeniy,
I propose the following steps to unify multi-arch support in compiler-rt:
1) The compiler-rt test suite adds "-L${CMAKE_CURRENT_BINARY_DIR}/lib"
to its 'clang' variables. This way we can test the sanitizers without
installing any libs to the just-built-clang install directory.
2) The "clang/runtime" build calls ExternalProject once for each arch
it needs of compiler-rt. So once to create x86_64 libs and once for
i386 libs.
3) The compiler-rt build drops the ${arch} suffix from its libs, and
the "clang/runtime" build uses CMAKE_INSTALL_PREFIX to control where
the compiler-rt libs go.
"CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/lib/clang/${CLANG_VERSION}/x86_64-linux"
4) Remove multi-arch support from the compiler-rt build. Instead,
declare compiler-rt as an "any-arch" build, configured with:
CMAKE_CXX_COMPILER (defaults to just-built-clang)
CMAKE_CXX_FLAGS (defaults to llvm's default target)
COMPILER_RT_TEST_COMPILER (defaults to CMAKE_CXX_COMPILER)
COMPILER_RT_TEST_FLAGS (defaults to CMAKE_CXX_FLAGS)
> we would still want to use compiler-rt test-suite in a standalone mode, to test fully built/installed toolchains,Sounds good.
and even GCC.
Can we change the flags to "-lasan -L/path/to/clang/resource/dir"? If
> Clang driver links the static xsan runtimes from a hardcoded
> paths in Clang resource directory, and doesn't add flags like
> "-lasan -L/path/to/clang/resource/dir". I find this behavior reasonable.
we make that change,
I can stop suggesting that the clang build should
invoke the compiler-rt test suite directly. :-)
--Alexey Samsonov, MSK
Yes. I'm up to 75% of ASan's test suite passing now. Most of the remaining failures are 1-off line numbers in the stack traces.> Do you mean that you've added support for> QEMU-based testing to sanitizer CMakeLists?
Greg
On Wednesday, April 2, 2014, Yury Gribov <y.gr...@samsung.com> wrote:
By the way, locally, I now have just over half the ASan test suite
passing ARM-Linux via QEMU.
Greg,
Do you mean that you've added support for QEMU-based testing to sanitizer CMakeLists? That would be super-cool.
-Y
> I don't think it's a good idea to let user hijack> the driver and stuff in custom version of> ASan runtime instead the one installed/built> with compiler :)I'm okay with it. This is open source. If someone wants to put the sanitizers on a shorter release cycle than the full toolchain, who are we to hold them back?
> What do you mean by "invoking the test-suite directly"?
In Clang's CMakeLists, add_subdirectory() of compiler-rt's 'test' directory. I suggested we do this earlier, because of clang's hardcoded dependency on the path to ASan. Instead, I think a better solution is to break the hardcoded dependency, allowing the test suite to point clang to compiler-rt's local copy of ASan using a '-L' parameter.
GregOn Thu, Apr 3, 2014 at 5:04 AM, Greg Fitzgerald <gar...@gmail.com> wrote:
> we would still want to use compiler-rt test-suite in a standalone mode, to test fully built/installed toolchains,Sounds good.
and even GCC.
Can we change the flags to "-lasan -L/path/to/clang/resource/dir"? If
> Clang driver links the static xsan runtimes from a hardcoded
> paths in Clang resource directory, and doesn't add flags like
> "-lasan -L/path/to/clang/resource/dir". I find this behavior reasonable.
we make that change,I don't think it's a good idea to let user hijack the driver and stuff in custom version ofASan runtime instead the one installed/built with compiler :)I can stop suggesting that the clang build should
invoke the compiler-rt test suite directly. :-)I haven't yet fully understood your complaints.
Note that if you build/configure compiler-rtin a standalone mode, then "make check-compiler-rt" in that tree wouldn't rebuild runtimes,and instead assume that they are provided by toolchain (that is, in standalone mode runtimes andtest suites are effectively independent).
Alexey,
I made these changes locally and it went really well. The patch to
>> Some good news, the drivers (both gcc and clang) allow us to put the
>> '-L' parameters after the '-l' parameters.
clang is quite small and only one unit-test needed updating. In
compiler-rt, I updated the flags passed to clang to include a
'-L${COMPILER_RT_BINARY_DIR}/lib' and
'-I${COMPILER_RT_BINARY_DIR}/include' flag. All tests pass except for
the default blacklist tests. I had to move those into the clang test
suite.
As for cross-compilation and test ARM Linux, I needed to update all
tests to include '%sim' before invoking cross-compiled executables.
For x86, the variable is empty. For cross-compiling, it's a
user-configured ${COMPILER_RT_EMULATOR}, which for ARM Linux, is QEMU.
There are currently a handful of test failures. If you'd like, I can
XFAIL them and commit this stuff sooner than later.
> First of all, sorry for the late response (I'm in the process of moving to California).Welcome!
Agreed. The test suite is useful in many different scenarios:
> We need to verify that simple command "clang -fsanitize=address foo.cc" works
1) Verifying the integrated clang.
2) Verifying the integrated gcc.
3) Verifying the libraries during development.
I'm working to improve #3 and in a way that does not interfere with #1 or #2.
Yes, that's the next patch I have for you. But adding the '-L' flag
> we add additional -L/path/to/compiler-rt/libs to all %clang invocations in lit test-suite.
is optional. If you want to use the test suite to verify an
integrated clang or gcc, you disable that.
Clever, but I hope we can try to avoid the symlink hackery. Locally,
> This looks familiar to what Evgeniy did for running lit test suite on
> Android. This is now possible w/o modifying any RUN-lines, see
> the hacky scripts in compiler-rt/test/asan/android_commands/folder.
> Can you use the similar approach for QEMU?
I've renamed "%sim %t" to "%run %t" so it reads quite nicely, IMHO.
It was a bunch of work to go change all the tests, but I think it's
the right approach. Each cross-compiled variation configures "%run"
from the command-line when invoking CMake. No hacks.
> Does %run support ssh-based testing?Yes, %run is configured by the user. I configure it to call a shell
script that calls qemu-arm. It could just as easily ssh or "adb push
&& adb shell".
-Greg
On Wed, Apr 16, 2014 at 11:44 PM, Yury Gribov <y.gr...@samsung.com> wrote:
> Greg,
>
>
>> Clever, but I hope we can try to avoid the symlink hackery. Locally,
>> I've renamed "%sim %t" to "%run %t" so it reads quite nicely, IMHO.
>
> Does %run support ssh-based testing? qemu-arm is cool but it does not
> emulate threads and other low-level stuff well which may be important for
> some users.
>
> -Y
>
Sorry for the slow replies. I'm out on vacation this week.
I want to test an implementation of libraries, not that clang links a
Alexey wrote:
> If you want to test the sanitizer runtiume library "during development",
> you should verify that it works with the Clang at hand.
library in its install directory. We only need one clang test for the
latter (not 100) and that test already exists in the clang test suite.
They aren't that tightly-coupled though. There's an interface and an
> Sanitizer runtime and the compiler are tightly
> coupled, why would you want to test the former in isolation?
implementation. That interface rarely changes relative to the number
of changes to the implementation.
https://github.com/llvm-mirror/compiler-rt/commits/master/include/sanitizer
> This is a public interface. But ASan runtime (and test-suite) strongly depends onHow do you feel about adding a runtime init check of a version number
> the instrumentation pass in Clang.
defined by asan_interface.h?