[LLVMdev] cmake patch to build other targets

Óscar Fuentes ofv at wanadoo.es
Wed Nov 12 09:30:27 PST 2008


Hello Scott.

"Scott Graham" <scott.llvm at h4ck3r.net> writes:

> Hi, attached is a patch to improve including targets other than X86 in
> CMake MSVC builds.

Great!

> When adding libs to link, rather than always using LLVMX86CodeGen and
> LLVMX86AsmPrinter, it grabs the correct ones.
>
> It also adds "force-link-ints" to the various TargetMachine cpp files,
> as well as X86AsmPrinter and PPCAsmPrinter. These are needed to be
> able to encourage the Win32 linker to include those libs (even though
> they're otherwise unreferenced) so that the registration global ctors
> are run. llc's build file is updated to force include these modules
> when appropriate.

Can you submit the part of your patch that modifies .cpp files to
llvm-cvs for approval as a separate patch?

[snip]

> Index: tools/llc/CMakeLists.txt
> ===================================================================
> --- tools/llc/CMakeLists.txt	(revision 59091)
> +++ tools/llc/CMakeLists.txt	(working copy)
> @@ -3,3 +3,28 @@
>  add_llvm_tool(llc
>    llc.cpp
>    )
> +
> +if( MSVC )
> +    set(linkflags "")

Is there a reason for restricting this to llc? We could turn this into a
function an call it from add_llvm_executable.

[snip]

> +    # special cases for x86/ppc asmprinters to force link because
> +    # they use static unreference ctors to register too.
> +    list(FIND LLVM_TARGETS_TO_BUILD "X86" idx)
> +    if(NOT idx LESS 0)
> +        set(linkflags "${linkflags} /INCLUDE:_X86AsmPrinterForceLink")
> +    endif(NOT idx LESS 0)
> +
> +    list(FIND LLVM_TARGETS_TO_BUILD "PowerPC" idx)
> +    if(NOT idx LESS 0)
> +        set(linkflags "${linkflags} /INCLUDE:_PowerPCAsmPrinterForceLink")
> +    endif(NOT idx LESS 0)

We can generalise this by creating a new variable
LLVM_ASMPRINTERS_FORCE_LINK or somesuch that lists those special
cases. I guess the other asmprinters does not need this hack to link
into the executable.

As soon as your patch for the .cpp files is applied, I'll add the
improvement you suggest.

Thanks!

-- 
Oscar




More information about the llvm-dev mailing list