[PATCH] [sanitizer][MIPS] Add --target flag for MIPS32

Sagar Thakur Sagar.Thakur at imgtec.com
Thu May 7 01:30:49 PDT 2015


REPOSITORY
  rL LLVM

================
Comment at: cmake/Modules/CompilerRTCompile.cmake:49
@@ -48,2 +48,3 @@
   endif()
+  string(REPLACE " " ";" SOURCE_CFLAGS "${SOURCE_CFLAGS}")
 
----------------
Unit tests for ASan, MSan and TSan get their TARGET_CFLAGS from get_target_flags_for_arch () function. And TARGET_CFLAGS need to be in list form, otherwise unit tests fail to compile :

>Generating tsan_test.cc.mips64.o
>cd /home/kms/sagar/compiler-rt_build/lib/tsan/tests/rtl && /home/kms/sagar/bin/MyLLVM/install/bin/clang -Wall -std=c++11 -Wno-unknown-warning-option -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-function-sections -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -DGTEST_NO_LLVM_RAW_OSTREAM=1 -DGTEST_HAS_RTTI=0 -I/home/kms/sagar/bin/MyLLVM/llvm/utils/unittest/googletest/include -I/home/kms/sagar/bin/MyLLVM/llvm/utils/unittest/googletest -I/home/kms/sagar/compiler-rt/lib -I/home/kms/sagar/compiler-rt/lib/tsan/rtl -DGTEST_HAS_RTTI=0 \ -mips64r2\ -mabi=n64 -c -o tsan_test.cc.mips64.o /home/kms/sagar/compiler-rt/lib/tsan/tests/rtl/tsan_test.cc
>clang-3.7: error: no such file or directory: ' -mips64r2 -mabi=n64'

As get_target_flags_for_arch function now returns a string instead of a list, TARGET_CFLAGS will be passed to clang_compile macro as a string.
Therefore we need to convert these flags back to list here to fix the above shown error.

================
Comment at: cmake/config-ix.cmake:187
@@ -186,3 +186,3 @@
       # regex for mipsel, mips64el
-      test_target_arch(mipsel "" "-mips32r2")
-      test_target_arch(mips64el "" "-mips64r2 -mabi=n64")
+      test_target_arch(mipsel "" "-mips32r2\t--target=mipsel-linux-gnu")
+      test_target_arch(mips64el "" "-mips64r2\t-mabi=n64")
----------------
samsonov wrote:
> sagar wrote:
> > I used the tab escape sequence here because while generating asan tests I get the following error :
> > 
> > >Scanning dependencies of target Asan-mips64el-with-calls-Noinst-Test
> > >[ 76%] Generating ASAN_NOINST_TEST_OBJECTS.gtest-all.cc.mips64el-with-calls.o
> > >clang-3.7: error: unknown argument: '-mips64r2 -mabi=n64'
> > 
> Please test if you can provide multiple flags to `test_target_arch` function:
>   test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu")
> 
> If it doesn't work, we should fix it.
I am able to give multiple flags to `test_target_arch` funtion.
But with this the tests under AddressSanitizer-mips64-linux don't get the flags properly.
Since cmake list elements are glued with a semicolon, this semicolon gets inserted in between the two mips flags which divides the compile command into two parts. Therefore I have replaced this semicolon in get_target_flags_for_arch with a tab.

http://reviews.llvm.org/D9249

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list