[llvm-dev] LLVM_TARGETS_TO_BUILD

4,187 views
Skip to first unread message

John Cortell via llvm-dev

unread,
Feb 27, 2017, 9:58:20 PM2/27/17
to llvm-dev
I'm trying to build LLVM on Windows 10 for x86_64. The cmake cmdline I used is

c:\cmake-3.8.0-rc1-win64-x64\bin\cmake.exe -DLLVM_TARGETS_TO_BUILD=x86_64 -G "Visual Studio 14" .

And this ultimately gives me:

llvm-build: error: invalid target to enable: 'x86_64' (not in project)

The source I'm trying to build is the llvm-3.8.0.src.tar.xz I got from http://releases.llvm.org/download.html

If I don't specify LLVM_TARGETS_TO_BUILD or I set it to "X86", cmake completes fine, and I can build the solution (but it gives me 32-bit binaries)

What am I doing wrong?

John

Tim Northover via llvm-dev

unread,
Feb 27, 2017, 10:37:25 PM2/27/17
to John Cortell, llvm-dev
Hi John,

On 27 February 2017 at 18:57, John Cortell via llvm-dev


<llvm...@lists.llvm.org> wrote:
> If I don't specify LLVM_TARGETS_TO_BUILD or I set it to "X86", cmake
> completes fine, and I can build the solution

X86 is definitely what you should be using (both 32-bit and 64-bit x86
backends share the code in lib/Target/X86, which is the key point
CMake is looking for).

> (but it gives me 32-bit binaries)

I assume this means that when you run the Clang you've just built it
defaults to producing 32-bit binaries? If so, on *NIX platforms you
override the default target with LLVM_DEFAULT_TARGET_TRIPLE.

I'm not *sure* that'll work on Windows (which has its own weird driver
on top of Clang), but as far as I can tell from here it behaves as I'd
expect. If so you want to set it to something like
"x86_64-pc-windows-msvc18.0.0" for 64-bit default.

clang-cl also seems to accept -m32 and -m64 options as overrides,
which may or may not be useful to you. Probably a bit hacky to put
into a build system since MSVC itself won't accept them.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Tim Northover via llvm-dev

unread,
Feb 27, 2017, 11:00:13 PM2/27/17
to John Cortell, LLVM Developers Mailing List
Hi John,

[Adding llvm-dev again; best to keep these things in the open so they
show up in future searches].

On 27 February 2017 at 19:46, John Cortell <john.c...@gmail.com> wrote:
> After building the solution cmake gave me (with X86), I got those libraries
> I wanted, but they appear to be 32-bit. I need 64-bit versions.

Ah, that was my second guess. My limited reading suggests that Windows
has completely separate compilers to produce x64 and x32
libraries/binaries. A bit of grubbing around the internet suggests
CMake exposes this with the CMAKE_GENERATOR_PLATFORM variable, and -A
on the command line. So I'd suggest:

c:\cmake-3.8.0-rc1-win64-x64\bin\cmake.exe
-DLLVM_TARGETS_TO_BUILD=x86_64 -G "Visual Studio 14" -A Win64

(plus a path to the source). That last argument is a bit of a guess,
but fits in with documentation at
https://cmake.org/cmake/help/v3.8/generator/Visual%20Studio%2014%202015.html
(for example).

Hope this works out for you.

John Cortell via llvm-dev

unread,
Feb 27, 2017, 11:22:55 PM2/27/17
to Tim Northover, LLVM Developers Mailing List
Thanks! That should get me on the right track.

Direct reply was accidental. Thanks for putting me back on the list :-)

I'll repost with details once I've got it working.

Flamedoge via llvm-dev

unread,
Feb 28, 2017, 12:14:08 AM2/28/17
to John Cortell, LLVM Developers Mailing List
Available targets should be found at 
https://github.com/llvm-mirror/llvm/blob/master/CMakeLists.txt#L306

And CMake for Windows should have 
The following generators are available on this platform:
  Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                                 Optional [arch] can be "Win64" or "ARM".

So I'd suggest:
cmake -DLLVM_TARGETS_TO_BUILD=x86 -G "Visual Studio 14 2015 Win64"

Regards,
Kevin

Flamedoge via llvm-dev

unread,
Feb 28, 2017, 12:15:36 AM2/28/17
to John Cortell, LLVM Developers Mailing List
>cmake -DLLVM_TARGETS_TO_BUILD=X86 -G "Visual Studio 14 2015 Win64"
capital 'X' to be pedantic.                          ^

John Cortell via llvm-dev

unread,
Feb 28, 2017, 10:05:24 AM2/28/17
to Flamedoge, LLVM Developers Mailing List
Appending "Win64" to Visual Studio generator name did the trick! Thanks, guys.
Reply all
Reply to author
Forward
0 new messages