[PATCH] light up UBSan for ARMv7

Greg Fitzgerald gregf at codeaurora.org
Fri May 23 09:15:18 PDT 2014



================
Comment at: CMakeLists.txt:219
@@ -220,2 +218,3 @@
   endif()
+  test_target_arch(arm "-march=armv7")
 endif()
----------------
Renato Golin wrote:
> Richard Smith wrote:
> > I don't understand what this change is doing: we don't want to run ARM tests if the native arch isn't ARM.
> yeah, it does look odd...
The macro checks if CMAKE_C_COMPILER can target a particular architecture.  If successful, it the build will generate a compiler-rt runtime with an ${arch} suffix.

Before this patch, we could only compile for ARM from a toolchain running on an ARM processor.  With this patch, we can cross-compile if the combination "-march=armv7", CMAKE_C_COMPILER and CMAKE_CXX_FLAGS successfully links.

>From the X86 build, this patch does nothing.  From an ARM-only build, it generates only ARM runtime libraries.

Some examples:

Combinations that cause the ARM runtimes to be generated:
arm-linux-gnueabi-g++ -march=armv7 simple.cc
clang++ -march=armv7 -target arm-linux-gnueabi --sysroot=... -B... simple.cc

Combinations that do nothing:
Bad flag on X86:  g++ -march=armv7 simple.cc
Wrong sysroot on X86: clang++ -march=armv7 simple.cc
Arch mismatch: aarch64-linux-gnu-g++ -march=armv7 simple.cc

http://reviews.llvm.org/D3794






More information about the llvm-commits mailing list