[cfe-dev] [llvm-dev] Build clang front end only for few languages ( say C and C++ )

Nitish Srivastava via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 22 11:11:14 PDT 2017


Hi Vedant,

  I have tried that. Choosing Release build and MinSizeRel does reduce the
size, and I have also tried to set static linking off. As, I am currently
hacking clang and llvm both, I do need to have the debug metadata attached
to the clang and llvm binaries, that's why I was asking if there are other
methods to reduce the size.

  Thanks,

Best Regards,
Nitish



‌

On Fri, Sep 22, 2017 at 2:04 PM, Vedant Kumar <vsk at apple.com> wrote:

>
> On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <nks45 at cornell.edu> wrote:
>
> Hi Vedant,
>
>   Clang + llvm build together takes around 26 GB. I was curious if there
> are any tricks to reduce the size as I need only C and C++ languages in
> frontend and RISCV ISA for llvm backend. For the backend I am already
> passing -DLLVM_TARGETS_TO_BUILD=RISCV to generate the backend only for
> RISCV. I was curious if I can do something to reduce the size of the clang
> build.
>
>
> Some ideas:
>
> 1. It sounds like you might have configured a Debug build. If you don't
> need to debug clang, you can configure a Release build instead, which will
> be much smaller.
>
> 2. You can enable a shared-library build to cut down on binary size
> (-DBUILD_SHARED_LIBS=On). That means there will be just one copy of the
> code from each llvm library in your build directory, instead of two.
>
> 3. You can pare down the list of targets you build. Just building the
> "clang" target is much faster, and takes much less space, than building the
> full suite of llvm tools (which is what you get if you run "ninja" or
> "make").
>
> 4. If you're building a Release clang, you can use -Os or -Oz, instead of
> -O3 which is the default.
>
> vedant
>
>
>   Thanks,
>
> Best Regards,
> Nitish
>
>
>
>>
> On Fri, Sep 22, 2017 at 1:47 PM, Vedant Kumar <vsk at apple.com> wrote:
>
>> - llvm-dev, + cfe-dev (moving off llvm-dev)
>>
>> Hi Nitish,
>>
>> On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>> Hi,
>>
>>  I am trying to build clang, however the build size is quite large. As
>> clang supports non-C family languages as well ( e.g. Java, Fortran ),
>>
>>
>> Clang does not accept Java or Fortran code. It links llvm, which has some
>> language-specific support for calling conventions, but excising this
>> support might not save you much in terms of binary size.
>>
>> is there a way to turn that off during the build. I just want to have
>> support for C and C++ and don't care about other languages.
>>
>> Is there a CMake option that needs to be set to do that??
>>
>>
>> What are you measuring exactly? Is it the size of the build directory,
>> the size of the clang binary itself, or something else?
>>
>> How small does clang need to be for your purposes?
>>
>> vedant
>>
>>
>> Thanks a lot!
>>
>> Best Regards,
>>
>> Nitish
>>
>>
>>>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170922/ad882b2a/attachment.html>


More information about the cfe-dev mailing list