[cfe-dev] Setting architecture

Miguel Guedes miguel.a.guedes at gmail.com
Fri Apr 19 23:34:12 PDT 2013


Hello List,


I've built llvm/clang 3.2 for the x86 architecture only by specifying 
LLVM_TARGETS_TO_BUILD=X86 . I then proceeded to write a program based on 
clang to parse a source file. Unfortunately it seems the target being 
used is x86 32 bit as the diagnostics are outputting the following error:

  /usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/
stubs-32.h' file not found

Having looked in Base/Targets.cpp it seems to all depend on what 
Triple.getArch() returns; Also have in vain tried to find out how clang - 
the compiler - (identifies and ?) sets the correct architecture by 
default.

How can I set the target options to 64 bits?

Currently doing:

    llvm::IntrusiveRefCntPtr<TargetOptions> pto(new TargetOptions());
    pto->Triple = llvm::sys::getDefaultTargetTriple();

    TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), 
*pto);
    ci.setTarget(pti);

The contents of pto->Triple are:  x86_64-unknown-linux-gnu




More information about the cfe-dev mailing list