[cfe-dev] Forcing default target, linker, includes
Petr Hosek via cfe-dev
cfe-dev at lists.llvm.org
Wed Nov 6 13:24:16 PST 2019
There's CLANG_DEFAULT_LINKER to set the default linker. There are other
similar flags
like CLANG_DEFAULT_OBJCOPY, CLANG_DEFAULT_CXX_STDLIB, CLANG_DEFAULT_RTLIB.
One issue I ran into is these settings are currently global and not
per-target. This is an issue e.g. on macOS where using
CLANG_DEFAULT_LINKER=lld makes even the Darwin target use lld which is a
problem. This is something we should address by either this setting a
per-target or change Darwin to always use system linker and ignore that
option.
There isn't CLANG_DEFAULT_SYSROOT right now. We could probably introduce it
but it'd have the same problem as CLANG_DEFAULT_LINKER where a single
option isn't going to work for all targets.
One thing we wanted to do for Fuchsia is implementing support for finding
sysroot in tooldir/sys-root/<target> which is already supported by GCC.
On Wed, Nov 6, 2019 at 12:11 PM Chris Hanson via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> 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
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191106/ba6dd528/attachment.html>
More information about the cfe-dev
mailing list