[PATCH] D38021: [Compiler-rt][MIPS] Fix cross build for XRAY
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 13:30:56 PDT 2017
eugenis added inline comments.
================
Comment at: CMakeLists.txt:273
+ separate_arguments(CROSS_COMPILE_FLAGS)
+ list(APPEND SANITIZER_COMMON_CFLAGS ${CROSS_COMPILE_FLAGS})
+endif()
----------------
dberris wrote:
> nitesh.jain wrote:
> > dberris wrote:
> > > Do you still really need this if you just use `cmake -DCMAKE_CXX_FLAGS=...` without this change? What happens when you revert this change and provide the target flags instead when you invoke cmake?
> > Without this change I am getting following errors
> >
> > [3/788] Building ASM object projects/compiler-rt/lib/xray/CMakeFiles/clang_rt.xray-mipsel.dir/xray_trampoline_mips.S.o
> > FAILED: projects/compiler-rt/lib/xray/CMakeFiles/clang_rt.xray-mipsel.dir/xray_trampoline_mips.S.o
> > /home/nin/LLVM/x86_build/bin/clang -DXRAY_HAS_EXCEPTIONS=1 -DXRAY_SUPPORTED=1 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/xray -I/home/nin/LLVM/llvm/projects/compiler-rt/lib/xray -Iinclude -I/home/nin/LLVM/llvm/include -I/home/nin/LLVM/llvm/projects/compiler-rt/lib/xray/.. -I/home/nin/LLVM/llvm/projects/compiler-rt/lib/xray/../../include -O3 -DNDEBUG -fno-lto -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fvisibility-inlines-hidden -fno-lto -O3 -gline-tables-only -MD -MT projects/compiler-rt/lib/xray/CMakeFiles/clang_rt.xray-mipsel.dir/xray_trampoline_mips.S.o -MF projects/compiler-rt/lib/xray/CMakeFiles/clang_rt.xray-mipsel.dir/xray_trampoline_mips.S.o.d -o projects/compiler-rt/lib/xray/CMakeFiles/clang_rt.xray-mipsel.dir/xray_trampoline_mips.S.o -c /home/nin/LLVM/llvm/projects/compiler-rt/lib/xray/xray_trampoline_mips.S
> >
> > clang -cc1as: error: unknown target triple 'x86_64-unknown-linux-gnu', please use -triple or -arch
> >
> >
> > My build commands is
> >
> > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE='' -DCMAKE_C_FLAGS="$cflags" -DCMAKE_CXX_FLAGS="$cflags -std=c++11" -DLLVM_TABLEGEN=$LLVM_TBLGEN -DCLANG_TABLEGEN=$CLANG_TBLGEN -DCMAKE_CROSSCOMPILING=1 -DLLVM_TARGETS_TO_BUILD=Mips -DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE -DCMAKE_C_COMPILER_TARGET=$TRIPLE -DCMAKE_CXX_COMPILER_TARGET=$TRIPLE -DLLVM_HOST_TRIPLE=$TRIPLE -DLLVM_TARGET_ARCH=Mips -DCOMPILER_RT_DEFAULT_TARGET_ONLY=1 -DCOMPILER_RT_DEFAULT_TARGET_ARCH=mipsel -DCOMPILER_RT_TEST_COMPILER=$cxx_bin -DCMAKE_FIND_ROOT_PATH=$sysroot -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_C_COMPILER=$cc_bin -DCMAKE_CXX_COMPILER=$cxx_bin
> >
> > cflags=--gcc-toolchain=/projects/mipssw/toolchains/mips-mti-linux-gnu/2015.01-7/ --target=mipsel-mti-linux-gnu -mabi=32 -EL -mips32r2 -latomic.
> >
> > Let me know if I miss anything
> >
> > Thanks
> Aha -- this is much better, thanks.
>
> I think I see what the problem is here, and it might be better to fix this a different way.
>
> There's a change I prepared a while back that changes the way the runtime is built (https://reviews.llvm.org/D37372#65c567b0) which I've since abandoned. That's isolated to the XRay CMakeLists.txt file in compiler-rt, which might be a better definition conducive to cross-compilation.
>
> I see that it might be useful to use `COMPILER_RT_DEFAULT_TARGET_ARCH` somehow if we're not already using it in the compiler-rt cmake helpers.
>
> @beanz might know better how to support cross-compiler set-ups too. @eugenis might also know more about how the sanitizers achieve this better.
I think you are right. add_compiler_rt* functions should take care of this on their own by using TARGET_{$ARCH}_FLAGS which should include CMAKE_C_FLAGS / CMAKE_CXX_FLAGS.
https://reviews.llvm.org/D38021
More information about the llvm-commits
mailing list