[cfe-dev] Forcing default target, linker, includes
Robinson, Paul via cfe-dev
cfe-dev at lists.llvm.org
Wed Nov 6 12:32:18 PST 2019
I suspect most of your issues are related to Clang not understanding the triple you want, and falling back to host-related defaults.
You can tell cmake `-DLLVM_DEFAULT_TARGET_TRIPLE=mips-sgi-irix` so at least that part would be your default. And once you define the triple components, you can set up a ToolChain in the driver that can probably set up most or all of the rest of that stuff.
HTH,
--paulr
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Chris Hanson via cfe-dev
Sent: Wednesday, November 6, 2019 3:11 PM
To: cfe-dev at lists.llvm.org
Subject: [cfe-dev] Forcing default target, linker, includes
I’ve built clang, compiler_rt, and lld on Linux from LLVM master as of last night targeting MIPS like so:
cmake \
-G Ninja \
$CMHPROJECTS/llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld" \
-DCMAKE_INSTALL_PREFIX="/opt/llvm-mips" \
-DLLVM_TARGETS_TO_BUILD="Mips"
ninja -j8 -k8
(A couple things fail to link but clang, lld, etc. do get built.)
Unfortunately the built clang does two things I don’t want: It looks in my Linux system’s / for headers even when I specify -isysroot and it uses my Linux system’s ld instead of the built lld even when I specify -fuse-ld=lld.
Are there CMake flags that I can use to force the built clang to only ever use headers from the provided sysroot? (And of course, I’d love the same for forcing lld to only look in sysroot for libraries.) How about CMake flags to force the built clang to only use its paired lld?
I also have to specify a number of options to get the (IRIX MIPS IV n64 ABI) code generation I desire; I’m compiling hello.c in my LLVM build directory with:
./bin/clang -g --std=c99 -D_LANGUAGE_C=1 -D__sgi=1 -D_SGIAPI=1 -D_SGI_SOURCE=1 -D_MIPSABI_SOURCE=1 --target=mips-sgi-irix -march=mips4 -m64 -isysroot $IRIXSDK -isystem $IRIXSDK/usr/include -c hello.c
Obviously the target tuple mips-sgi-irix isn’t supported, it does at least result in MIPS codegen and the rest winds up getting me MIPS IV n64. If I eventually add support for the sgi-irix part of the target tuple I know I can easily make it imply the preprocessor macros, but is that also necessary to force the use of the MIPS n64 ABI? Or is there some other way to select which MIPS ABI that I get? And is there a CMake option I can use to make all of that the default for the built clang?
— Chris
Sent from my iPad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191106/f7c72a91/attachment.html>
More information about the cfe-dev
mailing list