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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev
- llvm-dev, + cfe-dev (moving off llvm-dev)

Hi Nitish,

On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <[hidden email]> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev
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.

  Thanks,

Best Regards,
Nitish




On Fri, Sep 22, 2017 at 1:47 PM, Vedant Kumar <[hidden email]> wrote:
- llvm-dev, + cfe-dev (moving off llvm-dev)

Hi Nitish,

On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <[hidden email]> wrote:

<img width="0" height="0" class="m_3209270154627821229mailtrack-img" alt="" style="display:flex" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev

On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <[hidden email]> 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 <[hidden email]> wrote:
- llvm-dev, + cfe-dev (moving off llvm-dev)

Hi Nitish,

On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <[hidden email]> wrote:

<img width="0" height="0" class="m_3209270154627821229mailtrack-img" alt="" style="display:flex" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev
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 <[hidden email]> wrote:

On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <[hidden email]> wrote:

<img width="0" height="0" class="m_-7148135927697870314mailtrack-img" alt="" style="display:flex" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">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 <[hidden email]> wrote:
- llvm-dev, + cfe-dev (moving off llvm-dev)

Hi Nitish,

On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <[hidden email]> wrote:

<img width="0" height="0" class="m_-7148135927697870314m_3209270154627821229mailtrack-img" alt="" style="display:flex" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev
In reply to this post by Eric Fiselier via cfe-dev


Sent from my iPad

On Sep 22, 2017, at 11:04 AM, Vedant Kumar via cfe-dev <[hidden email]> wrote:


On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <[hidden email]> 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.

Please don’t do this. If you want to reduce code duplication the option you want is -DLLVM_LINK_LLVM_DYLIB=On. BUILD_SHARED_LIBS is not well supported and only for use by developers working on LLVM & Clang. If you’re intending to build something usable but are trying to be conscious of the size using libLLVM is the right way to go.

-Chris


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 <[hidden email]> wrote:
- llvm-dev, + cfe-dev (moving off llvm-dev)

Hi Nitish,

On Sep 22, 2017, at 10:32 AM, Nitish Srivastava via llvm-dev <[hidden email]> wrote:

<img width="0" height="0" class="m_3209270154627821229mailtrack-img" alt="" style="display:flex" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev
In reply to this post by Eric Fiselier via cfe-dev


2017-09-22 11:04 GMT-07:00 Vedant Kumar via cfe-dev <[hidden email]>:

On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <[hidden email]> 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.

I'd add on top of this to enable only the backend you care about, for example `-DLLVM_TARGETS_TO_BUILD=X86`, disable plugins `-CLANG_PLUGIN_SUPPORT=OFF` and try to enable LTO `-DLLVM_ENABLE_LTO=ON` (the latter may not be a win though, but with -Os hopefully it will!).

The clang binary can get down to ~50MB, but I suspect getting it smaller is likely gonna require more intrusive work.

Best,

-- 
Mehdi


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Eric Fiselier via cfe-dev

On Sep 22, 2017, at 6:03 PM, Mehdi AMINI <[hidden email]> wrote:



2017-09-22 11:04 GMT-07:00 Vedant Kumar via cfe-dev <[hidden email]>:

On Sep 22, 2017, at 10:55 AM, Nitish Srivastava <[hidden email]> 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.

I'd add on top of this to enable only the backend you care about, for example `-DLLVM_TARGETS_TO_BUILD=X86`, disable plugins `-CLANG_PLUGIN_SUPPORT=OFF` and try to enable LTO `-DLLVM_ENABLE_LTO=ON` (the latter may not be a win though, but with -Os hopefully it will!).

The clang binary can get down to ~50MB, but I suspect getting it smaller is likely gonna require more intrusive work.

Yeah. I also forgot about -DCLANG_ENABLE_ARCMT=Off and -DCLANG_ENABLE_STATIC_ANALYZER=Off, which can cut down on build-time a bit.

vedant


Best,

-- 
Mehdi



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev