Without the --target flag, clang uses the mips64 triple which selects the n64 abi. We need to add --target=mips-linux-gnu, so that clang can select the correct abi for mips32r2.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
cmake/config-ix.cmake | ||
---|---|---|
199–200 | I used the tab escape sequence here because while generating asan tests I get the following error :
|
cmake/config-ix.cmake | ||
---|---|---|
199–200 | 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 function.
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 function with a tab.
cmake/config-ix.cmake | ||
---|---|---|
235 | You shouldn't modify TARGET_${arch}_CFLAGS here, or do a string replacement. Just glue all flags into a string using foreach() loop, e.g. see set_target_compile_flags in CompilerRTUtils.cmake |
No, I believe you should fix get_target_flags_for_arch function instead, so that it returns the string instead of the list.
cmake/Modules/CompilerRTCompile.cmake | ||
---|---|---|
49 ↗ | (On Diff #25141) | 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 :
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. |
cmake/config-ix.cmake | ||
199–200 | I am able to give multiple flags to test_target_arch funtion. |
cmake/config-ix.cmake | ||
---|---|---|
199–200 | Sorry this comment was sent by mistake. It was not getting deleted. |
Alright, so here's the problem: get_target_flags_for_arch is used in two places:
- Fetching flags eventually passed to clang_compile macro to build unit tests. They *should* be represented as list, as clang_compile description clearly says.
- Fetching flags passed to clang in lit-tests (through ASAN_TEST_TARGET_CFLAGS CMake variable, which is used while configuring lit.site.cfg.in. They should be represented in a string form (space-separated).
Working with lists is generally more convenient, so let's return to http://reviews.llvm.org/differential/diff/25012/, and correct the usage of get_target_flags_for_arch while generating lit configs. I'm OK with replacing ";" with space. Also note, that you should only do this when you actually call get_target_flags_for_arch, not when you obtain these flags from COMPILER_RT_TEST_COMPILER_CFLAGS variable, which is likely a string. A comment in get_target_flags_for_arch, specifying that it returns a *list* would also be convenient.
Returned to http://reviews.llvm.org/differential/diff/25012/ and corrected the usage of get_target_flags_for_arch only while generating lit configs.
I used the tab escape sequence here because while generating asan tests I get the following error :