make target for clang

Hi,

What is the target to pass to make, to build just clang and clang++?

Thanks,

Thiago,

I think clang is naturally retarget-able to a lot of targets simultaneously. If you don't add build target, you would be able to get a bunch of targets build, which means you can use clang command line option "-target xxx" to generate code for different targets, but with the same clang binary!

You can also specify a particular target to build on command line. If you use cmake to build, for example, you can use '-DLLVM_TARGETS_TO_BUILD="ARM"' to build arm target. If you just use make, you can use target triple like "arm-pc-linux-gnueabi".

Thanks,
-Jiangning

ÔÚ 2012-7-11£¬ÏÂÎç9:44£¬Thiago Farina <tfarina@chromium.org> дµÀ£º

Oh, sorry for not being clearer. :frowning:

What I meant is when compiling clang from source.

I just want to compile clang, not the tests and the other tools (my
system is slow unfortunately).

So instead of just saying:

$ make

I want to say:

$ make clang # or whatever that target to compile just clang is.

There is a clang-only target that may reduce the number of item build, but clang has a lot of dependencies, so I'm not sure it will reduce compile time significantly.

You can also disable features you don't need too at configuration time. And make sure you compile only the backend you need (usually --enable-targets=host ).

-- Jean-Daniel

There is no target in the top-level makefile which allows you to do
that. The target for clang and clang++ is in the makefile in the
following directory (relative to the build dir):
tools/clang/tools/driver. You can try

make -C tools/clang/tools/driver
/absolute/path/to/build/dir/Release+Asserts/bin/clang++

What is the target to pass to make, to build just clang and clang++?

It looks like someone has given you an answer for the autotools build,
but if you switch to CMake then there *is* a simple "make clang"
target.

Tim.

Thiago,

I think clang is naturally retarget-able to a lot of targets simultaneously. If you don't add build target, you would be able to get a bunch of targets build, which means you can use clang command line option "-target xxx" to generate code for different targets, but with the same clang binary!

You can also specify a particular target to build on command line. If you use cmake to build, for example, you can use '-DLLVM_TARGETS_TO_BUILD="ARM"' to build arm target. If you just use make, you can use target triple like "arm-pc-linux-gnueabi".

Oh, sorry for not being clearer. :frowning:

What I meant is when compiling clang from source.

I just want to compile clang, not the tests and the other tools (my
system is slow unfortunately).

So instead of just saying:

$ make

I want to say:

$ make clang # or whatever that target to compile just clang is.

There is a clang-only target that may reduce the number of item build, but clang has a lot of dependencies, so I'm not sure it will reduce compile time significantly.

You can also disable features you don't need too at configuration time. And make sure you compile only the backend you need (usually --enable-targets=host ).

-- Jean-Daniel

Actually, clang-only hasn't done anything (for quite a while, I believe). :wink:

clang-only: all
tools-only: all
libs-only: all
install-clang: install
install-libs: install

But cutting targets can definitely speed up compile time, as well as only compiling from the clang directory (or Csaba's clang/tools/driver advice).

Jordan

Last time I tried it, under cmake, “make clang” was not sufficient to build a working clang, because it didn’t copy the headers from lib/Headers into the right place in the build tree. I think “make clang clang-headers” is enough.

Sure. Do you think it would make sense that clang depends on clang-headers?
FYI, check-clang depends on both clang and clang-headers.

PS. similarly, "make clang-headers clang", multiple targets on
cmake-generated makefiles sometimes would cause weird failure in
build.

..Takumi

So far this has worked for me, so I was able to setup ninja to build clang.

$ cd llvm/llvm-build
$ cmake -G Ninja ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

Now it's building fine.

Thanks all for the inputs.

$ ninja
[1/1809] ...

$ ninja clang
[1/1396]

Which seems less and better. :slight_smile:

Last time I tried it, under cmake, "make clang" was not sufficient to build
a working clang, because it didn't copy the headers from lib/Headers into
the right place in the build tree. I think "make clang clang-headers" is
enough.

Sure. Do you think it would make sense that clang depends on clang-headers?

I think that'd make sense. It took me a while to figure out that I
need to build clang-headers when I used cmake for the first time.

Nico

I have added dependency on clang to clang-headers, in r160549.

I have added dependency on clang to clang-headers, in r160549.

Thanks!