RFC: Upcoming Build System Changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
108 messages Options
1234 ... 6
Reply | Threaded
Open this post in threaded view
|

RFC: Upcoming Build System Changes

Daniel Dunbar
Hi all,

As you might have inferred, I'm in the process of working on some changes to the
way LLVM builds. I have outlined a rough proposal below, unless there are any
major objections I will probably start committing stuff next week.

This message may be verbose, if you want the executive summary, skip
to 'What This
Means For Jane "LLVM Developer" Doe' at the bottom.

Motivation
----------

We currently maintain two build systems (make, CMake). This has a couple of
problems:

 * Duplication: the two build systems duplicate a significant amount of implicit
   logic (higher level dependencies), some config files, and other miscellaneous
   features.

 * Maintenance: Some parts of the build systems requires regular maintenance
   (the CMake file lists, CMake dependency lists, module structure). Having one
   more thing to maintain is annoying.

 * Inconsistency: The two build systems behave inconsistently in some ways. If
   we want both to officially supported systems, it would be nice for them to
   behave as identically as possible.

   For example, CMake now uses explicit dependencies which are hard coded into
   the CMake files, but the Makefiles work completely differently.

There are also other general issues with the way LLVM is built now:

 * LLVM has a higher level structure for its organization, but this is not
   explicit. LLVM is roughly organized into components (libraries, tools, etc.)
   by directory. It would be nice to have this be more explicit.

 * Much of the project build structure is implicit in the Makefiles or
   CMakeFiles. It is not particularly explicit anywhere that, say, parts of
   VMCore depend on building the Intrinsics, which depend on building tblgen.

 * The Make system is not very efficient. We use recursive Makefiles which make
   the current system (relatively) simple in some ways, but mean the Make build
   is not nearly as scalable as it could be. In particular, the current
   organization means the built is often serialized on something that is not a
   strict dependency. It also makes it much more likely to do things like a
   stampeding link of all the tools, even though many tools could have been
   built earlier.


Specific Goals
--------------

 * Move both build systems to use explicit library dependencies, in a clean
   fashion. The CMake files do this now, but I don't think it has been made
   clear to developers when they are supposed to edit these files, or how (other
   than when something breaks, I guess).

 * Explicitly describe as much of the project structure as necessary to support
   builds. This means explicitly specifying how the project is organized, and
   the dependencies among the components required to build (e.g., Intrinsics
   before VMCore).

   I believe a number of other projects/users (FreeBSD, fbuild) have
built there own
   build system for LLVM. Encoding the project structure clearly should make it
   easier for such projects, or for other future users that want to do the same.

   This should make it easier to experiment with the build system, for example
   we could just directly generate good Makefiles for our project, or could
   experiment with systems like Ninja which expect to be targetted by a
   generator of some kind.


Proposal
--------

My initial proposal is focused at moving us to use explicit library
dependencies, but paves the way for centralizing more "build systemy" stuff in
the future.

 * Every LLVM "component" (roughly corresponds to each place we have a Makefile
   or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.

   This file will be an LLVM specific description of that component. Initially,
   it will look something like this::

     [component]
     # The kind of component this is (currently library, tool, build tool). More
     # types will be defined over time.
     type = Library

     # The name of the component.
     name = VMCore

     # The name of the component to logically group this in. This is just for
     # organization purposes.
     parent = Libraries

     # The names of the library components that are also required when linking
     # with this library. More on this later.
     required_libraries = Support

   The exact structure of the format is TBD (and easy to change), currently the
   format is INI style but I may decide to change to JSON once all the pieces
   are in place.

   The LLVM web pages will have clear documentation on what these files should
   look like, what is required, what is supported, and so on.


 * I will add a new tool in utils/llvm-build which is designed to load and work
   with these files. This tool will be written in Python, and the expectation is
   that it can be run at configure time.

   TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
   order to build LLVM.

   For the Makefiles, this is no worse than requiring Perl, so I don't think
   there is much to argue with.

   For CMake, this is a new dependency. However, I feel this is unavoidable:

     * I see no way to support multiple build systems including CMake without
       either introducing a dependency on some extra tool (which can be shared),
       or duplicating a significant amount of logic in CMake.

       I believe that duplicating logic is worse than adding the Python
       dependency, and I think we already have more CMake code (a relatively
       horrible language) than can be expected for most LLVM developers to deal
       with.

   Additionally, we already require Python for running our tests, so anyone
   doing serious LLVM development should have it.

   The one use case I believe this particularly hurts is users who just want to
   download and play with LLVM, but I believe the Right Answer (tm) for that
   case would be for us to provide nice installer packages anyway.


 * utils/llvm-build will be run during configure time (both for Make and CMake),
   and will:

   * Generate the library dependency information required to link tools, in
     whatever format makes the most system for the build system in use.

   * Generate a C++ .inc file containing the dependency table for use by
     llvm-config (which I am going to rewrite in C++).

   * Add dependencies on the LLVMBuild.txt files to the build system, so that
     the build will reconfigure appropriately when the library
requirements change.


 * Remove GenLibDeps.pl, find-cycles.pl, etc.

   We will no longer be using these after llvm-config has moved over.


 * Add explicit source file lists to the LLVMBuild.txt files. Unfortunately,
   this is inevitable if we want to support CMake users projects automatically
   reconfiguring themselves when new files get added. I can make it easier to
   manage (for example, provide build targets that will automatically add any
   new files).


 * Move both Make and CMake over to using the explicit file lists in the
   LLVMBuild files. This ensures that both systems get the same behavior
   (instead of Make users being able to add files and forget to update
   CMakeLists.txt).


 * Add new 'lit' tests to check that the library dependency
information is correct.

   This seems a nicer place to do the checking which is currently partially
   handled by find-cycles, and we should also be able to do a better job of the
   checking (for example, verifying that the dependency list is "exact" -- only
   specifies the minimum set of libraries required, and isn't allowed to specify
   libraries which are only indirectly required).

   It would be particularly cool if we could just write these tests using our
   Object libraries.

   This is one piece I haven't prototyped yet. I can obviously do something as
   good as the current find-cycles.pl, but I hope to do better (eventually).


 * These are just the first steps, after this I will continue to incrementally
   try and move as much common information out of the Make and CMake systems so
   there is "one source of truth" with regard to the project definition.


 * I assume it is obvious, but when I say "LLVM" here I am referring to both
   LLVM and Clang. I have not looked at lldb yet, but if it uses the LLVM build
   system (and llvm-config) functionality I will try to make sure it
continues to work.


What This Means For Jane "LLVM Developer" Doe
---------------------------------------------

In practice, this means:

 * LLVM requires Python to build.

 * When you add a file to LLVM, you will need to edit LLVMBuild.txt instead of
   CMakeLists.txt, which will be in a slightly different, but otherwise totally
   obvious format.

   If you forget to do this, your file will not be built (which will most likely
   cause a link error eventually). This is better than it being built by Make,
   but causing CMake build failures when you check in.

 * When you add a new library requirement to an existing component, you will be
   required to edit LLVMBuild.txt instead of CMakeLists.txt, which will be in a
   slightly different, but otherwise totally obvious (hopefully) format.

   If you forget to do this, you will either get a link error or a test
   failure. This is better than library you need transparently getting linked in
   (with make) because it forces you to think about whether you actually should
   be adding that dependency.

   The goal is that this also ensures that if LLVM links and passes tests on
   your system, then it should for everyone else as well.

 * Developers not actively touching the build system should never need to touch
   a Makefile or a CMake file.

Overall, I believe this should be a quality of life improvement for the
developer community. The only downside is having to deal with a new non-standard
LLVM specific format, but I plan to solve this through documentation.

Comments?

 - Daniel
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Chandler Carruth-2
I have a very high level comment, and you may be able to directly shed light on it before I dig into a lot more detail.

Why not simply standardize on CMake? It's not my favorite tool, but it seems to work well, we have established usage of it, and several people involved in the project who understand how it works. It doesn't seem like a significantly more burdensome dependency than Python when developing, and it remains possible to build installable packages for the casual hacker.

I can see some objections to CMake, but it's not clear to me that they should carry the day. I'm also probably missing some.

The one I see most clearly is that the CMake build, as it stands, involves Too Much Magic. I don't at all disagree. That said, I strongly believe this could be completely addressed.

- If we moved to CMake as the standard build system, numerous kludgy aspects of the current build would go away. They are often in existence purely to support interoperation with the old system.

- It would be very straight forward to centralize all of the library dependencies and descriptions in the single top-level CMakeLists.txt file, making it easily consumable by your average developer. It would have a format no harder to edit or understand than the one you propose, and they would both (at worst) be unfamiliar to existing developers.

- It would likely improve the quality of our CMake builds by ensuring it was well tested and always in a consistent state.

- It already has a relatively optimized makefile-generation system, so we wouldn't need to re-invent this wheel again.


The biggest downside to making CMake the standard build system is the dependence on CMake to my eyes. However, among the cross-platform users of LLVM, I think CMake is often the preferred build system. I know of folks using it under xcode, visual studio, mingw, cygwin, and all flavors of Linux.


Anyways, I'm sure there are more considerations than just these, I just think it would be beneficial to seriously consider using an existing meta-build system rather than rolling our own.
-Chandler

On Thu, Oct 27, 2011 at 6:11 PM, Daniel Dunbar <[hidden email]> wrote:
Hi all,

As you might have inferred, I'm in the process of working on some changes to the
way LLVM builds. I have outlined a rough proposal below, unless there are any
major objections I will probably start committing stuff next week.

This message may be verbose, if you want the executive summary, skip
to 'What This
Means For Jane "LLVM Developer" Doe' at the bottom.

Motivation
----------

We currently maintain two build systems (make, CMake). This has a couple of
problems:

 * Duplication: the two build systems duplicate a significant amount of implicit
  logic (higher level dependencies), some config files, and other miscellaneous
  features.

 * Maintenance: Some parts of the build systems requires regular maintenance
  (the CMake file lists, CMake dependency lists, module structure). Having one
  more thing to maintain is annoying.

 * Inconsistency: The two build systems behave inconsistently in some ways. If
  we want both to officially supported systems, it would be nice for them to
  behave as identically as possible.

  For example, CMake now uses explicit dependencies which are hard coded into
  the CMake files, but the Makefiles work completely differently.

There are also other general issues with the way LLVM is built now:

 * LLVM has a higher level structure for its organization, but this is not
  explicit. LLVM is roughly organized into components (libraries, tools, etc.)
  by directory. It would be nice to have this be more explicit.

 * Much of the project build structure is implicit in the Makefiles or
  CMakeFiles. It is not particularly explicit anywhere that, say, parts of
  VMCore depend on building the Intrinsics, which depend on building tblgen.

 * The Make system is not very efficient. We use recursive Makefiles which make
  the current system (relatively) simple in some ways, but mean the Make build
  is not nearly as scalable as it could be. In particular, the current
  organization means the built is often serialized on something that is not a
  strict dependency. It also makes it much more likely to do things like a
  stampeding link of all the tools, even though many tools could have been
  built earlier.


Specific Goals
--------------

 * Move both build systems to use explicit library dependencies, in a clean
  fashion. The CMake files do this now, but I don't think it has been made
  clear to developers when they are supposed to edit these files, or how (other
  than when something breaks, I guess).

 * Explicitly describe as much of the project structure as necessary to support
  builds. This means explicitly specifying how the project is organized, and
  the dependencies among the components required to build (e.g., Intrinsics
  before VMCore).

  I believe a number of other projects/users (FreeBSD, fbuild) have
built there own
  build system for LLVM. Encoding the project structure clearly should make it
  easier for such projects, or for other future users that want to do the same.

  This should make it easier to experiment with the build system, for example
  we could just directly generate good Makefiles for our project, or could
  experiment with systems like Ninja which expect to be targetted by a
  generator of some kind.


Proposal
--------

My initial proposal is focused at moving us to use explicit library
dependencies, but paves the way for centralizing more "build systemy" stuff in
the future.

 * Every LLVM "component" (roughly corresponds to each place we have a Makefile
  or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.

  This file will be an LLVM specific description of that component. Initially,
  it will look something like this::

    [component]
    # The kind of component this is (currently library, tool, build tool). More
    # types will be defined over time.
    type = Library

    # The name of the component.
    name = VMCore

    # The name of the component to logically group this in. This is just for
    # organization purposes.
    parent = Libraries

    # The names of the library components that are also required when linking
    # with this library. More on this later.
    required_libraries = Support

  The exact structure of the format is TBD (and easy to change), currently the
  format is INI style but I may decide to change to JSON once all the pieces
  are in place.

  The LLVM web pages will have clear documentation on what these files should
  look like, what is required, what is supported, and so on.


 * I will add a new tool in utils/llvm-build which is designed to load and work
  with these files. This tool will be written in Python, and the expectation is
  that it can be run at configure time.

  TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
  order to build LLVM.

  For the Makefiles, this is no worse than requiring Perl, so I don't think
  there is much to argue with.

  For CMake, this is a new dependency. However, I feel this is unavoidable:

    * I see no way to support multiple build systems including CMake without
      either introducing a dependency on some extra tool (which can be shared),
      or duplicating a significant amount of logic in CMake.

      I believe that duplicating logic is worse than adding the Python
      dependency, and I think we already have more CMake code (a relatively
      horrible language) than can be expected for most LLVM developers to deal
      with.

  Additionally, we already require Python for running our tests, so anyone
  doing serious LLVM development should have it.

  The one use case I believe this particularly hurts is users who just want to
  download and play with LLVM, but I believe the Right Answer (tm) for that
  case would be for us to provide nice installer packages anyway.


 * utils/llvm-build will be run during configure time (both for Make and CMake),
  and will:

  * Generate the library dependency information required to link tools, in
    whatever format makes the most system for the build system in use.

  * Generate a C++ .inc file containing the dependency table for use by
    llvm-config (which I am going to rewrite in C++).

  * Add dependencies on the LLVMBuild.txt files to the build system, so that
    the build will reconfigure appropriately when the library
requirements change.


 * Remove GenLibDeps.pl, find-cycles.pl, etc.

  We will no longer be using these after llvm-config has moved over.


 * Add explicit source file lists to the LLVMBuild.txt files. Unfortunately,
  this is inevitable if we want to support CMake users projects automatically
  reconfiguring themselves when new files get added. I can make it easier to
  manage (for example, provide build targets that will automatically add any
  new files).


 * Move both Make and CMake over to using the explicit file lists in the
  LLVMBuild files. This ensures that both systems get the same behavior
  (instead of Make users being able to add files and forget to update
  CMakeLists.txt).


 * Add new 'lit' tests to check that the library dependency
information is correct.

  This seems a nicer place to do the checking which is currently partially
  handled by find-cycles, and we should also be able to do a better job of the
  checking (for example, verifying that the dependency list is "exact" -- only
  specifies the minimum set of libraries required, and isn't allowed to specify
  libraries which are only indirectly required).

  It would be particularly cool if we could just write these tests using our
  Object libraries.

  This is one piece I haven't prototyped yet. I can obviously do something as
  good as the current find-cycles.pl, but I hope to do better (eventually).


 * These are just the first steps, after this I will continue to incrementally
  try and move as much common information out of the Make and CMake systems so
  there is "one source of truth" with regard to the project definition.


 * I assume it is obvious, but when I say "LLVM" here I am referring to both
  LLVM and Clang. I have not looked at lldb yet, but if it uses the LLVM build
  system (and llvm-config) functionality I will try to make sure it
continues to work.


What This Means For Jane "LLVM Developer" Doe
---------------------------------------------

In practice, this means:

 * LLVM requires Python to build.

 * When you add a file to LLVM, you will need to edit LLVMBuild.txt instead of
  CMakeLists.txt, which will be in a slightly different, but otherwise totally
  obvious format.

  If you forget to do this, your file will not be built (which will most likely
  cause a link error eventually). This is better than it being built by Make,
  but causing CMake build failures when you check in.

 * When you add a new library requirement to an existing component, you will be
  required to edit LLVMBuild.txt instead of CMakeLists.txt, which will be in a
  slightly different, but otherwise totally obvious (hopefully) format.

  If you forget to do this, you will either get a link error or a test
  failure. This is better than library you need transparently getting linked in
  (with make) because it forces you to think about whether you actually should
  be adding that dependency.

  The goal is that this also ensures that if LLVM links and passes tests on
  your system, then it should for everyone else as well.

 * Developers not actively touching the build system should never need to touch
  a Makefile or a CMake file.

Overall, I believe this should be a quality of life improvement for the
developer community. The only downside is having to deal with a new non-standard
LLVM specific format, but I plan to solve this through documentation.

Comments?

 - Daniel
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Chandler Carruth-2
On Thu, Oct 27, 2011 at 6:34 PM, Chandler Carruth <[hidden email]> wrote:
I have a very high level comment, and you may be able to directly shed light on it before I dig into a lot more detail.

Why not simply standardize on CMake? It's not my favorite tool, but it seems to work well, we have established usage of it, and several people involved in the project who understand how it works. It doesn't seem like a significantly more burdensome dependency than Python when developing, and it remains possible to build installable packages for the casual hacker.

I can see some objections to CMake, but it's not clear to me that they should carry the day. I'm also probably missing some.

The one I see most clearly is that the CMake build, as it stands, involves Too Much Magic. I don't at all disagree. That said, I strongly believe this could be completely addressed.

- If we moved to CMake as the standard build system, numerous kludgy aspects of the current build would go away. They are often in existence purely to support interoperation with the old system.

- It would be very straight forward to centralize all of the library dependencies and descriptions in the single top-level CMakeLists.txt file, making it easily consumable by your average developer. It would have a format no harder to edit or understand than the one you propose, and they would both (at worst) be unfamiliar to existing developers.

- It would likely improve the quality of our CMake builds by ensuring it was well tested and always in a consistent state.

- It already has a relatively optimized makefile-generation system, so we wouldn't need to re-invent this wheel again.

Something else I wanted to mention, although I don't know how relevant it really is to most LLVM and/or Clang developers is that we have several Clang developers who are actually contributing to CMake specifically around integration with Clang and related tools. I expect these to increase over the next year...

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Chris Lattner-2
In reply to this post by Chandler Carruth-2

On Oct 27, 2011, at 6:34 PM, Chandler Carruth wrote:

I have a very high level comment, and you may be able to directly shed light on it before I dig into a lot more detail.

Why not simply standardize on CMake? It's not my favorite tool, but it seems to work well, we have established usage of it, and several people involved in the project who understand how it works. It doesn't seem like a significantly more burdensome dependency than Python when developing, and it remains possible to build installable packages for the casual hacker.

I can see some objections to CMake, but it's not clear to me that they should carry the day. I'm also probably missing some.

There are several major problems with CMake IMO:

1. It generates really slow build systems.

2. The build system generated by cmake is absolute garbage, at least for Xcode.  The build times of it are really bad, and having to work with it in the IDE is even more terrible.

3. I'd really like us to get to explicit and principled library dependencies, where the build horks if you accidentally add a library dependency.  Without this, I don't see how LLVM will ever scale up.

4. I'd really like us to move in a direction where LLVM is less monolithic.  Right now "llvm" contains all the MC stuff, all the targets, all the mid-level optimizer, etc.  Adding a new LLVM MC-based linker will cause it to naturally get dropped into the llvm project, which is great but not helping the monolithicness. :)

To me at least, I see this as a first step to getting LLVM to be a more scalable project.  Things like llvm-config are essential, but not extensible to subprojects like Clang, etc.

Anyways, I'm sure there are more considerations than just these, I just think it would be beneficial to seriously consider using an existing meta-build system rather than rolling our own.

It seems that all sufficiently large open source projects evolve their own meta build systems!  

-Chris

-Chandler

On Thu, Oct 27, 2011 at 6:11 PM, Daniel Dunbar <[hidden email]> wrote:
Hi all,

As you might have inferred, I'm in the process of working on some changes to the
way LLVM builds. I have outlined a rough proposal below, unless there are any
major objections I will probably start committing stuff next week.

This message may be verbose, if you want the executive summary, skip
to 'What This
Means For Jane "LLVM Developer" Doe' at the bottom.

Motivation
----------

We currently maintain two build systems (make, CMake). This has a couple of
problems:

 * Duplication: the two build systems duplicate a significant amount of implicit
  logic (higher level dependencies), some config files, and other miscellaneous
  features.

 * Maintenance: Some parts of the build systems requires regular maintenance
  (the CMake file lists, CMake dependency lists, module structure). Having one
  more thing to maintain is annoying.

 * Inconsistency: The two build systems behave inconsistently in some ways. If
  we want both to officially supported systems, it would be nice for them to
  behave as identically as possible.

  For example, CMake now uses explicit dependencies which are hard coded into
  the CMake files, but the Makefiles work completely differently.

There are also other general issues with the way LLVM is built now:

 * LLVM has a higher level structure for its organization, but this is not
  explicit. LLVM is roughly organized into components (libraries, tools, etc.)
  by directory. It would be nice to have this be more explicit.

 * Much of the project build structure is implicit in the Makefiles or
  CMakeFiles. It is not particularly explicit anywhere that, say, parts of
  VMCore depend on building the Intrinsics, which depend on building tblgen.

 * The Make system is not very efficient. We use recursive Makefiles which make
  the current system (relatively) simple in some ways, but mean the Make build
  is not nearly as scalable as it could be. In particular, the current
  organization means the built is often serialized on something that is not a
  strict dependency. It also makes it much more likely to do things like a
  stampeding link of all the tools, even though many tools could have been
  built earlier.


Specific Goals
--------------

 * Move both build systems to use explicit library dependencies, in a clean
  fashion. The CMake files do this now, but I don't think it has been made
  clear to developers when they are supposed to edit these files, or how (other
  than when something breaks, I guess).

 * Explicitly describe as much of the project structure as necessary to support
  builds. This means explicitly specifying how the project is organized, and
  the dependencies among the components required to build (e.g., Intrinsics
  before VMCore).

  I believe a number of other projects/users (FreeBSD, fbuild) have
built there own
  build system for LLVM. Encoding the project structure clearly should make it
  easier for such projects, or for other future users that want to do the same.

  This should make it easier to experiment with the build system, for example
  we could just directly generate good Makefiles for our project, or could
  experiment with systems like Ninja which expect to be targetted by a
  generator of some kind.


Proposal
--------

My initial proposal is focused at moving us to use explicit library
dependencies, but paves the way for centralizing more "build systemy" stuff in
the future.

 * Every LLVM "component" (roughly corresponds to each place we have a Makefile
  or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.

  This file will be an LLVM specific description of that component. Initially,
  it will look something like this::

    [component]
    # The kind of component this is (currently library, tool, build tool). More
    # types will be defined over time.
    type = Library

    # The name of the component.
    name = VMCore

    # The name of the component to logically group this in. This is just for
    # organization purposes.
    parent = Libraries

    # The names of the library components that are also required when linking
    # with this library. More on this later.
    required_libraries = Support

  The exact structure of the format is TBD (and easy to change), currently the
  format is INI style but I may decide to change to JSON once all the pieces
  are in place.

  The LLVM web pages will have clear documentation on what these files should
  look like, what is required, what is supported, and so on.


 * I will add a new tool in utils/llvm-build which is designed to load and work
  with these files. This tool will be written in Python, and the expectation is
  that it can be run at configure time.

  TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
  order to build LLVM.

  For the Makefiles, this is no worse than requiring Perl, so I don't think
  there is much to argue with.

  For CMake, this is a new dependency. However, I feel this is unavoidable:

    * I see no way to support multiple build systems including CMake without
      either introducing a dependency on some extra tool (which can be shared),
      or duplicating a significant amount of logic in CMake.

      I believe that duplicating logic is worse than adding the Python
      dependency, and I think we already have more CMake code (a relatively
      horrible language) than can be expected for most LLVM developers to deal
      with.

  Additionally, we already require Python for running our tests, so anyone
  doing serious LLVM development should have it.

  The one use case I believe this particularly hurts is users who just want to
  download and play with LLVM, but I believe the Right Answer (tm) for that
  case would be for us to provide nice installer packages anyway.


 * utils/llvm-build will be run during configure time (both for Make and CMake),
  and will:

  * Generate the library dependency information required to link tools, in
    whatever format makes the most system for the build system in use.

  * Generate a C++ .inc file containing the dependency table for use by
    llvm-config (which I am going to rewrite in C++).

  * Add dependencies on the LLVMBuild.txt files to the build system, so that
    the build will reconfigure appropriately when the library
requirements change.


 * Remove GenLibDeps.pl, find-cycles.pl, etc.

  We will no longer be using these after llvm-config has moved over.


 * Add explicit source file lists to the LLVMBuild.txt files. Unfortunately,
  this is inevitable if we want to support CMake users projects automatically
  reconfiguring themselves when new files get added. I can make it easier to
  manage (for example, provide build targets that will automatically add any
  new files).


 * Move both Make and CMake over to using the explicit file lists in the
  LLVMBuild files. This ensures that both systems get the same behavior
  (instead of Make users being able to add files and forget to update
  CMakeLists.txt).


 * Add new 'lit' tests to check that the library dependency
information is correct.

  This seems a nicer place to do the checking which is currently partially
  handled by find-cycles, and we should also be able to do a better job of the
  checking (for example, verifying that the dependency list is "exact" -- only
  specifies the minimum set of libraries required, and isn't allowed to specify
  libraries which are only indirectly required).

  It would be particularly cool if we could just write these tests using our
  Object libraries.

  This is one piece I haven't prototyped yet. I can obviously do something as
  good as the current find-cycles.pl, but I hope to do better (eventually).


 * These are just the first steps, after this I will continue to incrementally
  try and move as much common information out of the Make and CMake systems so
  there is "one source of truth" with regard to the project definition.


 * I assume it is obvious, but when I say "LLVM" here I am referring to both
  LLVM and Clang. I have not looked at lldb yet, but if it uses the LLVM build
  system (and llvm-config) functionality I will try to make sure it
continues to work.


What This Means For Jane "LLVM Developer" Doe
---------------------------------------------

In practice, this means:

 * LLVM requires Python to build.

 * When you add a file to LLVM, you will need to edit LLVMBuild.txt instead of
  CMakeLists.txt, which will be in a slightly different, but otherwise totally
  obvious format.

  If you forget to do this, your file will not be built (which will most likely
  cause a link error eventually). This is better than it being built by Make,
  but causing CMake build failures when you check in.

 * When you add a new library requirement to an existing component, you will be
  required to edit LLVMBuild.txt instead of CMakeLists.txt, which will be in a
  slightly different, but otherwise totally obvious (hopefully) format.

  If you forget to do this, you will either get a link error or a test
  failure. This is better than library you need transparently getting linked in
  (with make) because it forces you to think about whether you actually should
  be adding that dependency.

  The goal is that this also ensures that if LLVM links and passes tests on
  your system, then it should for everyone else as well.

 * Developers not actively touching the build system should never need to touch
  a Makefile or a CMake file.

Overall, I believe this should be a quality of life improvement for the
developer community. The only downside is having to deal with a new non-standard
LLVM specific format, but I plan to solve this through documentation.

Comments?

 - Daniel
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: RFC: Upcoming Build System Changes

Shea Levy
In reply to this post by Daniel Dunbar
Hi Daniel,

On 10/27/2011 09:11 PM, Daniel Dunbar wrote:
> Hi all,
>
> As you might have inferred, I'm in the process of working on some changes to the
> way LLVM builds. I have outlined a rough proposal below, unless there are any
> major objections I will probably start committing stuff next week.
>
>

I'm not an LLVM dev, but I am the maintainer for all of the LLVM-related
packages for my distro. I have a few thoughts on changes to the build
system that could make my life easier, but they're largely orthogonal to
the work you described. Are you interested in hearing about them now, or
would you rather just focus on the (rather large) task you've already
set out? I've been planning on doing a writeup to send to the list
anyway, but if there's a chance you'll integrate the changes in work
starting next week I'll be sure to collect all my thoughts and send them
sooner.

Regards,
Shea Levy
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Chris Lattner-2
In reply to this post by Chris Lattner-2

On Oct 27, 2011, at 11:28 PM, Óscar Fuentes wrote:

> Chris Lattner <[hidden email]> writes:
>
>> There are several major problems with CMake IMO:
>>
>> 1. It generates really slow build systems.
>
> In my Linux box, last time I checked (long time ago) the cmake build was
> a bit faster than the Makefiles. But this is a tricky terrain, because
> they are not identical, not on the features supported (and some have an
> impact on build-time) nor even on the options passed to the compiler.

The makefiles are known to be really slow, among other problems being based on recursive make.  One goal of this is to get a non-recursive makefile generated.  We've prototyped this in the past and found it to be substantially faster than the recursive makefile.

>> 2. The build system generated by cmake is absolute garbage, at least
>> for Xcode.  The build times of it are really bad, and having to work
>> with it in the IDE is even more terrible.
>
> AFAIK there is a Xcode project file on the LLVM source tree.

Nope, there was once but it was removed a long time ago though.

> Are the
> LLVM makefiles used by the Xcode project?

No, it is generated by Cmake.

> If the Xcode project files
> generated by cmake is not satisfactory, can't they use the Makefiles
> generated by cmake instead?

Xcode can drive a makefile, but it doesn't provide any of the IDE integration features, e.g. clang code completion.

-Chris


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Óscar Fuentes
Chris Lattner <[hidden email]> writes:

>>> 1. It generates really slow build systems.
>>
>> In my Linux box, last time I checked (long time ago) the cmake build was
>> a bit faster than the Makefiles. But this is a tricky terrain, because
>> they are not identical, not on the features supported (and some have an
>> impact on build-time) nor even on the options passed to the compiler.
>
> The makefiles are known to be really slow, among other problems being
> based on recursive make.  One goal of this is to get a non-recursive
> makefile generated.  We've prototyped this in the past and found it to
> be substantially faster than the recursive makefile.

A good measure of how fast a set of Makefile are is to run the build
with all targets up-to-date. Both builds takes a few seconds (3 or so)
on my Linux quad core box. Whatever improvement can be achieved on this
seems pretty insignifant.

Furthermore, recursive make is necessary for automatic generation of
header dependencies, among other things. The makefiles generated by
cmake are "partially" recursive for that reason:

http://www.cmake.org/Wiki/CMake_FAQ#Why_does_CMake_generate_recursive_Makefiles.3F

>>> 2. The build system generated by cmake is absolute garbage, at least
>>> for Xcode.  The build times of it are really bad, and having to work
>>> with it in the IDE is even more terrible.
>>
>> AFAIK there is a Xcode project file on the LLVM source tree.
>
> Nope, there was once but it was removed a long time ago though.
>
>> Are the
>> LLVM makefiles used by the Xcode project?
>
> No, it is generated by Cmake.

So, the cmake-generated Xcode file was considered good enough or... ?

[snip]

Anyways, if you wish to avoid duplicating info on both Makefile and
CMakeLists.txt there is a simple solution: read and parse the Makefile
from the corresponding CMakeLists.txt. For instance, if you put the
library dependencies on the Makefile like this:

LLVMLIBDEPS := foo zoo bar

obtaining that info from the CMakeLists.txt and generating the cmake
library dependencies is very simple, nor even you have to put anything
new on all those CMakeLists.txt, just modify one of the macros that are
(indirectly) called from each CMakeLists.txt.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

decalek
In reply to this post by Daniel Dunbar
+1: Extract full, exact (meta) data in pure form in easy to handle
format and generate bits for concrete build system on demand - simply great!

As a side effect, probably LLVMBuild.txt data would help the
distribution maintainers in the support of the package specifications too.

On 28.10.2011 04:11, Daniel Dunbar wrote:

>   * Every LLVM "component" (roughly corresponds to each place we have a Makefile
>     or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.
>
>     This file will be an LLVM specific description of that component. Initially,
>     it will look something like this::
>
>       [component]
>       # The kind of component this is (currently library, tool, build tool). More
>       # types will be defined over time.
>       type = Library
>
>       # The name of the component.
>       name = VMCore
>
>       # The name of the component to logically group this in. This is just for
>       # organization purposes.
>       parent = Libraries
>
>       # The names of the library components that are also required when linking
>       # with this library. More on this later.
>       required_libraries = Support
>
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Anton Korobeynikov-2
In reply to this post by Daniel Dunbar
Hi Oskar,

> If having two build systems is a problem, just standardize on cmake.
Does cmake support cross-compilation? Can it cross-compile LLVM ?

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Arnaud Allard de Grandmaison
Hi Anton,

Cmake definitely support cross-compilation. This is achieved by defining some so-called 'toolchain' files. Doing this is not well documented in the web documentation, as far as I know, but the cmake paper book describe it extensively. Several reasonnable size projects here have used it successfully.

Regards,
--
Arnaud de Grandmaison

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Anton Korobeynikov
Sent: Friday, October 28, 2011 10:27 AM
To: Óscar Fuentes
Cc: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] RFC: Upcoming Build System Changes

Hi Oskar,

> If having two build systems is a problem, just standardize on cmake.
Does cmake support cross-compilation? Can it cross-compile LLVM ?

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

David Chisnall-2
In reply to this post by Daniel Dunbar
On 28 Oct 2011, at 02:11, Daniel Dunbar wrote:

>   TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
>   order to build LLVM.
>
>   For the Makefiles, this is no worse than requiring Perl, so I don't think
>   there is much to argue with.

I disagree there.  Perl is pretty much guaranteed to be installed on any UNIXish system.  Even FreeBSD, which has removed it from the base system, tends to install the Perl package by default.  In contrast, a lot of the machines I use don't have Python installed.  I need to install it if I'm doing LLVM development because it's needed for the tests, but needing it just to build seems like massive overkill.

That said, if the information required for the build is going to be made explicit, maybe this isn't such a problem, as other tools can be written to parse it and run the build.

David


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Csaba Raduly-2
In reply to this post by Chandler Carruth-2
On Fri, Oct 28, 2011 at 3:34 AM, Chandler Carruth  wrote:
> I have a very high level comment, and you may be able to directly shed light
> on it before I dig into a lot more detail.
> Why not simply standardize on CMake?

That would establish a hard dependency on CMake. Not every system has
CMake whereas most systems do have Python by default (on the machines
I use daily, Python has a 5-1 lead).
See also David Chisnall's mail about Perl > Python.

Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Reid Kleckner-3
In reply to this post by Óscar Fuentes
On Fri, Oct 28, 2011 at 3:54 AM, Óscar Fuentes <[hidden email]> wrote:
Anyways, if you wish to avoid duplicating info on both Makefile and
CMakeLists.txt there is a simple solution: read and parse the Makefile
from the corresponding CMakeLists.txt. For instance, if you put the
library dependencies on the Makefile like this:

LLVMLIBDEPS := foo zoo bar

obtaining that info from the CMakeLists.txt and generating the cmake
library dependencies is very simple, nor even you have to put anything
new on all those CMakeLists.txt, just modify one of the macros that are
(indirectly) called from each CMakeLists.txt.


While eliminating duplication is one of the goals I see in this build system change, I think the more important ones are a) simplifying the build files and b) making the build faster.

Adding CMake code (I agree it's a terrible scripting language) to parse Makefiles will make the build slower and more complicated.

-----

I'm not really a stakeholder, but I agree with Chandler, it's worth investigating simplifying LLVM's CMake files before making Yet Another build system generator if you haven't already.  That may not solve the problems associated with the bad XCode project generation, though.

OTOH, LLVM seems to have invented many of it's own tools (lit, tablegen, filecheck) and they seem to have worked out great.  I wish our test suite for DynamoRIO had a tool as flexible as FileCheck.  :(

Reid

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

[cfe-dev] RFC: Upcoming Build System Changes

Bugzilla from trapni@gentoo.org
In reply to this post by Csaba Raduly-2
I wouldn't say that. I know quite a few systems here around that even try to avoid python where possible. but cmake however, as a build system, is welcomed by all of us (working as a sysop in a unix environment).

I'd also (as a non-llvm-dev but llvm-userdev) vote for NOT reinventing the wheel but to use the tool the fits you the best, personally that's even cmake, too. it has a well list of great backing companies / projects and is still improving well, e.g. Qt planned (I do not know how up-to-date this info is) improve it in a way to make it more suitable for IDEs, however, from the sysop point of view, it's much more a pleasure to work with cmake than with autotools, and when you introduce (yet) another new build system, it would be just a headache :)

Best regards,
Christian Parpart.


On Fri, Oct 28, 2011 at 12:55 PM, Csaba Raduly <[hidden email]> wrote:
On Fri, Oct 28, 2011 at 3:34 AM, Chandler Carruth  wrote:
> I have a very high level comment, and you may be able to directly shed light
> on it before I dig into a lot more detail.
> Why not simply standardize on CMake?

That would establish a hard dependency on CMake. Not every system has
CMake whereas most systems do have Python by default (on the machines
I use daily, Python has a 5-1 lead).
See also David Chisnall's mail about Perl > Python.

Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Jean-Daniel Dupas-2

Le 28 oct. 2011 à 15:40, Christian Parpart a écrit :

I wouldn't say that. I know quite a few systems here around that even try to avoid python where possible. but cmake however, as a build system, is welcomed by all of us (working as a sysop in a unix environment).

I'd also (as a non-llvm-dev but llvm-userdev) vote for NOT reinventing the wheel but to use the tool the fits you the best, personally that's even cmake, too. it has a well list of great backing companies / projects and is still improving well, e.g. Qt planned (I do not know how up-to-date this info is) improve it in a way to make it more suitable for IDEs, however, from the sysop point of view, it's much more a pleasure to work with cmake than with autotools, and when you introduce (yet) another new build system, it would be just a headache :)

If I understand the proposal correctly, from a Jan Doe (llvm-user) point of view, you will just continue to use cmake. The only difference will be that cmake will call a python script to generate a bunch of files used by cmake  or make.

That said, wouldn't it be possible to not require this script to be run for the users, but simply add resulting files in the repository (just like many project do not require you run autoconf, and just distribute the generated configure script).

Like that, the python dependency will be required only if you change the module description files, and not for casual developers and users who just plan to recompile llvm.

Best regards,
Christian Parpart.


On Fri, Oct 28, 2011 at 12:55 PM, Csaba Raduly <[hidden email]> wrote:
On Fri, Oct 28, 2011 at 3:34 AM, Chandler Carruth  wrote:
> I have a very high level comment, and you may be able to directly shed light
> on it before I dig into a lot more detail.
> Why not simply standardize on CMake?

That would establish a hard dependency on CMake. Not every system has
CMake whereas most systems do have Python by default (on the machines
I use daily, Python has a 5-1 lead).
See also David Chisnall's mail about Perl > Python.

Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-- Jean-Daniel





_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Rotem, Nadav
In reply to this post by Chandler Carruth-2

+1

 

We build our OpenCL SDK (for windows and Linux) using CMake.  We’ve  integrated LLVM’s Cmake hierarchy into our own (customizing LLVM external parameters like build and install directories, added passes, etc)

 

Migrating LLVM’s build system from CMake to something else would require us to change the way we currently do things.

 

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Chandler Carruth
Sent: Friday, October 28, 2011 03:35
To: Daniel Dunbar
Cc: cfe-dev; LLVM Developers Mailing List
Subject: Re: [LLVMdev] [cfe-dev] RFC: Upcoming Build System Changes

 

I have a very high level comment, and you may be able to directly shed light on it before I dig into a lot more detail.

 

Why not simply standardize on CMake? It's not my favorite tool, but it seems to work well, we have established usage of it, and several people involved in the project who understand how it works. It doesn't seem like a significantly more burdensome dependency than Python when developing, and it remains possible to build installable packages for the casual hacker.

 

I can see some objections to CMake, but it's not clear to me that they should carry the day. I'm also probably missing some.

 

The one I see most clearly is that the CMake build, as it stands, involves Too Much Magic. I don't at all disagree. That said, I strongly believe this could be completely addressed.

 

- If we moved to CMake as the standard build system, numerous kludgy aspects of the current build would go away. They are often in existence purely to support interoperation with the old system.

 

- It would be very straight forward to centralize all of the library dependencies and descriptions in the single top-level CMakeLists.txt file, making it easily consumable by your average developer. It would have a format no harder to edit or understand than the one you propose, and they would both (at worst) be unfamiliar to existing developers.

 

- It would likely improve the quality of our CMake builds by ensuring it was well tested and always in a consistent state.

 

- It already has a relatively optimized makefile-generation system, so we wouldn't need to re-invent this wheel again.

 

 

The biggest downside to making CMake the standard build system is the dependence on CMake to my eyes. However, among the cross-platform users of LLVM, I think CMake is often the preferred build system. I know of folks using it under xcode, visual studio, mingw, cygwin, and all flavors of Linux.

 

 

Anyways, I'm sure there are more considerations than just these, I just think it would be beneficial to seriously consider using an existing meta-build system rather than rolling our own.

-Chandler

 

On Thu, Oct 27, 2011 at 6:11 PM, Daniel Dunbar <[hidden email]> wrote:

Hi all,

As you might have inferred, I'm in the process of working on some changes to the
way LLVM builds. I have outlined a rough proposal below, unless there are any
major objections I will probably start committing stuff next week.

This message may be verbose, if you want the executive summary, skip
to 'What This
Means For Jane "LLVM Developer" Doe' at the bottom.

Motivation
----------

We currently maintain two build systems (make, CMake). This has a couple of
problems:

 * Duplication: the two build systems duplicate a significant amount of implicit
  logic (higher level dependencies), some config files, and other miscellaneous
  features.

 * Maintenance: Some parts of the build systems requires regular maintenance
  (the CMake file lists, CMake dependency lists, module structure). Having one
  more thing to maintain is annoying.

 * Inconsistency: The two build systems behave inconsistently in some ways. If
  we want both to officially supported systems, it would be nice for them to
  behave as identically as possible.

  For example, CMake now uses explicit dependencies which are hard coded into
  the CMake files, but the Makefiles work completely differently.

There are also other general issues with the way LLVM is built now:

 * LLVM has a higher level structure for its organization, but this is not
  explicit. LLVM is roughly organized into components (libraries, tools, etc.)
  by directory. It would be nice to have this be more explicit.

 * Much of the project build structure is implicit in the Makefiles or
  CMakeFiles. It is not particularly explicit anywhere that, say, parts of
  VMCore depend on building the Intrinsics, which depend on building tblgen.

 * The Make system is not very efficient. We use recursive Makefiles which make
  the current system (relatively) simple in some ways, but mean the Make build
  is not nearly as scalable as it could be. In particular, the current
  organization means the built is often serialized on something that is not a
  strict dependency. It also makes it much more likely to do things like a
  stampeding link of all the tools, even though many tools could have been
  built earlier.


Specific Goals
--------------

 * Move both build systems to use explicit library dependencies, in a clean
  fashion. The CMake files do this now, but I don't think it has been made
  clear to developers when they are supposed to edit these files, or how (other
  than when something breaks, I guess).

 * Explicitly describe as much of the project structure as necessary to support
  builds. This means explicitly specifying how the project is organized, and
  the dependencies among the components required to build (e.g., Intrinsics
  before VMCore).

  I believe a number of other projects/users (FreeBSD, fbuild) have
built there own
  build system for LLVM. Encoding the project structure clearly should make it
  easier for such projects, or for other future users that want to do the same.

  This should make it easier to experiment with the build system, for example
  we could just directly generate good Makefiles for our project, or could
  experiment with systems like Ninja which expect to be targetted by a
  generator of some kind.


Proposal
--------

My initial proposal is focused at moving us to use explicit library
dependencies, but paves the way for centralizing more "build systemy" stuff in
the future.

 * Every LLVM "component" (roughly corresponds to each place we have a Makefile
  or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.

  This file will be an LLVM specific description of that component. Initially,
  it will look something like this::

    [component]
    # The kind of component this is (currently library, tool, build tool). More
    # types will be defined over time.
    type = Library

    # The name of the component.
    name = VMCore

    # The name of the component to logically group this in. This is just for
    # organization purposes.
    parent = Libraries

    # The names of the library components that are also required when linking
    # with this library. More on this later.
    required_libraries = Support

  The exact structure of the format is TBD (and easy to change), currently the
  format is INI style but I may decide to change to JSON once all the pieces
  are in place.

  The LLVM web pages will have clear documentation on what these files should
  look like, what is required, what is supported, and so on.


 * I will add a new tool in utils/llvm-build which is designed to load and work
  with these files. This tool will be written in Python, and the expectation is
  that it can be run at configure time.

  TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
  order to build LLVM.

  For the Makefiles, this is no worse than requiring Perl, so I don't think
  there is much to argue with.

  For CMake, this is a new dependency. However, I feel this is unavoidable:

    * I see no way to support multiple build systems including CMake without
      either introducing a dependency on some extra tool (which can be shared),
      or duplicating a significant amount of logic in CMake.

      I believe that duplicating logic is worse than adding the Python
      dependency, and I think we already have more CMake code (a relatively
      horrible language) than can be expected for most LLVM developers to deal
      with.

  Additionally, we already require Python for running our tests, so anyone
  doing serious LLVM development should have it.

  The one use case I believe this particularly hurts is users who just want to
  download and play with LLVM, but I believe the Right Answer (tm) for that
  case would be for us to provide nice installer packages anyway.


 * utils/llvm-build will be run during configure time (both for Make and CMake),
  and will:

  * Generate the library dependency information required to link tools, in
    whatever format makes the most system for the build system in use.

  * Generate a C++ .inc file containing the dependency table for use by
    llvm-config (which I am going to rewrite in C++).

  * Add dependencies on the LLVMBuild.txt files to the build system, so that
    the build will reconfigure appropriately when the library
requirements change.


 * Remove GenLibDeps.pl, find-cycles.pl, etc.

  We will no longer be using these after llvm-config has moved over.


 * Add explicit source file lists to the LLVMBuild.txt files. Unfortunately,
  this is inevitable if we want to support CMake users projects automatically
  reconfiguring themselves when new files get added. I can make it easier to
  manage (for example, provide build targets that will automatically add any
  new files).


 * Move both Make and CMake over to using the explicit file lists in the
  LLVMBuild files. This ensures that both systems get the same behavior
  (instead of Make users being able to add files and forget to update
  CMakeLists.txt).


 * Add new 'lit' tests to check that the library dependency
information is correct.

  This seems a nicer place to do the checking which is currently partially
  handled by find-cycles, and we should also be able to do a better job of the
  checking (for example, verifying that the dependency list is "exact" -- only
  specifies the minimum set of libraries required, and isn't allowed to specify
  libraries which are only indirectly required).

  It would be particularly cool if we could just write these tests using our
  Object libraries.

  This is one piece I haven't prototyped yet. I can obviously do something as
  good as the current find-cycles.pl, but I hope to do better (eventually).


 * These are just the first steps, after this I will continue to incrementally
  try and move as much common information out of the Make and CMake systems so
  there is "one source of truth" with regard to the project definition.


 * I assume it is obvious, but when I say "LLVM" here I am referring to both
  LLVM and Clang. I have not looked at lldb yet, but if it uses the LLVM build
  system (and llvm-config) functionality I will try to make sure it
continues to work.


What This Means For Jane "LLVM Developer" Doe
---------------------------------------------

In practice, this means:

 * LLVM requires Python to build.

 * When you add a file to LLVM, you will need to edit LLVMBuild.txt instead of
  CMakeLists.txt, which will be in a slightly different, but otherwise totally
  obvious format.

  If you forget to do this, your file will not be built (which will most likely
  cause a link error eventually). This is better than it being built by Make,
  but causing CMake build failures when you check in.

 * When you add a new library requirement to an existing component, you will be
  required to edit LLVMBuild.txt instead of CMakeLists.txt, which will be in a
  slightly different, but otherwise totally obvious (hopefully) format.

  If you forget to do this, you will either get a link error or a test
  failure. This is better than library you need transparently getting linked in
  (with make) because it forces you to think about whether you actually should
  be adding that dependency.

  The goal is that this also ensures that if LLVM links and passes tests on
  your system, then it should for everyone else as well.

 * Developers not actively touching the build system should never need to touch
  a Makefile or a CMake file.

Overall, I believe this should be a quality of life improvement for the
developer community. The only downside is having to deal with a new non-standard
LLVM specific format, but I plan to solve this through documentation.

Comments?

 - Daniel
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

 

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

decalek
In reply to this post by David Chisnall-2
Hi David,

On 28.10.2011 13:05, David Chisnall wrote:
> I disagree there.  Perl is pretty much guaranteed to be installed on any UNIXish system.  Even FreeBSD, which has removed it from the base system, tends to install the Perl package by default.  In contrast, a lot of the machines I use don't have Python installed.  I need to install it if I'm doing LLVM development because it's needed for the tests, but needing it just to build seems like massive overkill.

It is possible that you are right about the overall index of "presence".
Just to mention that in Fedora derivatives (RedHat, CentOS, maybe 35-50%
of Linux dev stations - I don't know) Python is guaranteed because of
yum (the package manager).

>
> That said, if the information required for the build is going to be made explicit, maybe this isn't such a problem, as other tools can be written to parse it and run the build.

Absolutely - once the generators are prototyped and tested in Python, if
current Perl (presence) > Python's, they can be easily ported to Perl.

Kind Regards,
Alek
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Nico Weber-2
In reply to this post by Daniel Dunbar
Hi,

my 2 cents:

1) If you're targeting python 2.6 or less, I prefer a python
dependency over cmake 'cause it's already installed on all machines I
build clang on. If you're targeting 2.7+, I don't care either way.

2) On the chromium project, we're using a custom meta build system
written in python, and it's been a lot more useful than we initially
expected. Based on this experience, your proposal sounds good to me.

Nico

On Thu, Oct 27, 2011 at 6:11 PM, Daniel Dunbar <[hidden email]> wrote:

> Hi all,
>
> As you might have inferred, I'm in the process of working on some changes to the
> way LLVM builds. I have outlined a rough proposal below, unless there are any
> major objections I will probably start committing stuff next week.
>
> This message may be verbose, if you want the executive summary, skip
> to 'What This
> Means For Jane "LLVM Developer" Doe' at the bottom.
>
> Motivation
> ----------
>
> We currently maintain two build systems (make, CMake). This has a couple of
> problems:
>
>  * Duplication: the two build systems duplicate a significant amount of implicit
>   logic (higher level dependencies), some config files, and other miscellaneous
>   features.
>
>  * Maintenance: Some parts of the build systems requires regular maintenance
>   (the CMake file lists, CMake dependency lists, module structure). Having one
>   more thing to maintain is annoying.
>
>  * Inconsistency: The two build systems behave inconsistently in some ways. If
>   we want both to officially supported systems, it would be nice for them to
>   behave as identically as possible.
>
>   For example, CMake now uses explicit dependencies which are hard coded into
>   the CMake files, but the Makefiles work completely differently.
>
> There are also other general issues with the way LLVM is built now:
>
>  * LLVM has a higher level structure for its organization, but this is not
>   explicit. LLVM is roughly organized into components (libraries, tools, etc.)
>   by directory. It would be nice to have this be more explicit.
>
>  * Much of the project build structure is implicit in the Makefiles or
>   CMakeFiles. It is not particularly explicit anywhere that, say, parts of
>   VMCore depend on building the Intrinsics, which depend on building tblgen.
>
>  * The Make system is not very efficient. We use recursive Makefiles which make
>   the current system (relatively) simple in some ways, but mean the Make build
>   is not nearly as scalable as it could be. In particular, the current
>   organization means the built is often serialized on something that is not a
>   strict dependency. It also makes it much more likely to do things like a
>   stampeding link of all the tools, even though many tools could have been
>   built earlier.
>
>
> Specific Goals
> --------------
>
>  * Move both build systems to use explicit library dependencies, in a clean
>   fashion. The CMake files do this now, but I don't think it has been made
>   clear to developers when they are supposed to edit these files, or how (other
>   than when something breaks, I guess).
>
>  * Explicitly describe as much of the project structure as necessary to support
>   builds. This means explicitly specifying how the project is organized, and
>   the dependencies among the components required to build (e.g., Intrinsics
>   before VMCore).
>
>   I believe a number of other projects/users (FreeBSD, fbuild) have
> built there own
>   build system for LLVM. Encoding the project structure clearly should make it
>   easier for such projects, or for other future users that want to do the same.
>
>   This should make it easier to experiment with the build system, for example
>   we could just directly generate good Makefiles for our project, or could
>   experiment with systems like Ninja which expect to be targetted by a
>   generator of some kind.
>
>
> Proposal
> --------
>
> My initial proposal is focused at moving us to use explicit library
> dependencies, but paves the way for centralizing more "build systemy" stuff in
> the future.
>
>  * Every LLVM "component" (roughly corresponds to each place we have a Makefile
>   or CMakeLists.txt currently) will get a 'LLVMBuild.txt' file.
>
>   This file will be an LLVM specific description of that component. Initially,
>   it will look something like this::
>
>     [component]
>     # The kind of component this is (currently library, tool, build tool). More
>     # types will be defined over time.
>     type = Library
>
>     # The name of the component.
>     name = VMCore
>
>     # The name of the component to logically group this in. This is just for
>     # organization purposes.
>     parent = Libraries
>
>     # The names of the library components that are also required when linking
>     # with this library. More on this later.
>     required_libraries = Support
>
>   The exact structure of the format is TBD (and easy to change), currently the
>   format is INI style but I may decide to change to JSON once all the pieces
>   are in place.
>
>   The LLVM web pages will have clear documentation on what these files should
>   look like, what is required, what is supported, and so on.
>
>
>  * I will add a new tool in utils/llvm-build which is designed to load and work
>   with these files. This tool will be written in Python, and the expectation is
>   that it can be run at configure time.
>
>   TO BE CLEAR: I intend to introduce a hard dependency on requiring Python in
>   order to build LLVM.
>
>   For the Makefiles, this is no worse than requiring Perl, so I don't think
>   there is much to argue with.
>
>   For CMake, this is a new dependency. However, I feel this is unavoidable:
>
>     * I see no way to support multiple build systems including CMake without
>       either introducing a dependency on some extra tool (which can be shared),
>       or duplicating a significant amount of logic in CMake.
>
>       I believe that duplicating logic is worse than adding the Python
>       dependency, and I think we already have more CMake code (a relatively
>       horrible language) than can be expected for most LLVM developers to deal
>       with.
>
>   Additionally, we already require Python for running our tests, so anyone
>   doing serious LLVM development should have it.
>
>   The one use case I believe this particularly hurts is users who just want to
>   download and play with LLVM, but I believe the Right Answer (tm) for that
>   case would be for us to provide nice installer packages anyway.
>
>
>  * utils/llvm-build will be run during configure time (both for Make and CMake),
>   and will:
>
>   * Generate the library dependency information required to link tools, in
>     whatever format makes the most system for the build system in use.
>
>   * Generate a C++ .inc file containing the dependency table for use by
>     llvm-config (which I am going to rewrite in C++).
>
>   * Add dependencies on the LLVMBuild.txt files to the build system, so that
>     the build will reconfigure appropriately when the library
> requirements change.
>
>
>  * Remove GenLibDeps.pl, find-cycles.pl, etc.
>
>   We will no longer be using these after llvm-config has moved over.
>
>
>  * Add explicit source file lists to the LLVMBuild.txt files. Unfortunately,
>   this is inevitable if we want to support CMake users projects automatically
>   reconfiguring themselves when new files get added. I can make it easier to
>   manage (for example, provide build targets that will automatically add any
>   new files).
>
>
>  * Move both Make and CMake over to using the explicit file lists in the
>   LLVMBuild files. This ensures that both systems get the same behavior
>   (instead of Make users being able to add files and forget to update
>   CMakeLists.txt).
>
>
>  * Add new 'lit' tests to check that the library dependency
> information is correct.
>
>   This seems a nicer place to do the checking which is currently partially
>   handled by find-cycles, and we should also be able to do a better job of the
>   checking (for example, verifying that the dependency list is "exact" -- only
>   specifies the minimum set of libraries required, and isn't allowed to specify
>   libraries which are only indirectly required).
>
>   It would be particularly cool if we could just write these tests using our
>   Object libraries.
>
>   This is one piece I haven't prototyped yet. I can obviously do something as
>   good as the current find-cycles.pl, but I hope to do better (eventually).
>
>
>  * These are just the first steps, after this I will continue to incrementally
>   try and move as much common information out of the Make and CMake systems so
>   there is "one source of truth" with regard to the project definition.
>
>
>  * I assume it is obvious, but when I say "LLVM" here I am referring to both
>   LLVM and Clang. I have not looked at lldb yet, but if it uses the LLVM build
>   system (and llvm-config) functionality I will try to make sure it
> continues to work.
>
>
> What This Means For Jane "LLVM Developer" Doe
> ---------------------------------------------
>
> In practice, this means:
>
>  * LLVM requires Python to build.
>
>  * When you add a file to LLVM, you will need to edit LLVMBuild.txt instead of
>   CMakeLists.txt, which will be in a slightly different, but otherwise totally
>   obvious format.
>
>   If you forget to do this, your file will not be built (which will most likely
>   cause a link error eventually). This is better than it being built by Make,
>   but causing CMake build failures when you check in.
>
>  * When you add a new library requirement to an existing component, you will be
>   required to edit LLVMBuild.txt instead of CMakeLists.txt, which will be in a
>   slightly different, but otherwise totally obvious (hopefully) format.
>
>   If you forget to do this, you will either get a link error or a test
>   failure. This is better than library you need transparently getting linked in
>   (with make) because it forces you to think about whether you actually should
>   be adding that dependency.
>
>   The goal is that this also ensures that if LLVM links and passes tests on
>   your system, then it should for everyone else as well.
>
>  * Developers not actively touching the build system should never need to touch
>   a Makefile or a CMake file.
>
> Overall, I believe this should be a quality of life improvement for the
> developer community. The only downside is having to deal with a new non-standard
> LLVM specific format, but I plan to solve this through documentation.
>
> Comments?
>
>  - Daniel
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Óscar Fuentes
In reply to this post by Anton Korobeynikov-2
Hello Anton.

Anton Korobeynikov <[hidden email]> writes:

>> If having two build systems is a problem, just standardize on cmake.
> Does cmake support cross-compilation? Can it cross-compile LLVM ?

Yes: http://www.llvm.org/docs/CMake.html#cross

The main difference is that you use a configuration file instead of
passing arguments on the command line. Please note that the
configuration file is for a toolset, not for a project (i.e. you don't
need to create one every time you want to cross-compile a new project
from Debian to Windows with MinGW.)
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] RFC: Upcoming Build System Changes

Óscar Fuentes
In reply to this post by Reid Kleckner-3
Reid Kleckner <[hidden email]> writes:

> While eliminating duplication is one of the goals I see in this build system
> change, I think the more important ones are a) simplifying the build files
> and b) making the build faster.

The "build files" are the Makefiles, right? And Dan's proposal will not
make the cmake build any faster. So those goals are orthogonal to the
cmake build.

> Adding CMake code (I agree it's a terrible scripting language) to parse
> Makefiles will make the build slower and more complicated.

Wrong! :-) Adding that feature is a few lines of code (orders of
magnitude less than the system proposed by Dan) which are executed only
at generation-time, i.e. when cmake has to regenerate the
makefiles/project-files because a file was added/removed, etc. It adds
nothing at build time and you will need a stopwatch to notice the
difference at generation time.

> I'm not really a stakeholder, but I agree with Chandler, it's worth
> investigating simplifying LLVM's CMake files before making Yet Another build
> system generator if you haven't already.  That may not solve the problems
> associated with the bad XCode project generation, though.

You guys are mixing several things on the discussion. What Dan proposed
makes no difference for Xcode. If it speeds up the Makefile-based build
(something I doubt) that's good, but it is unnecessary for that system
to fiddle with the cmake build as long as cmake can deal with the
changes on its own.

Keep in mind that, if Dan goes ahead his plans, tinkering on any build
system would require knowledge of both of them plus the python
scripts. That's adding complexity, quite a lot.

[snip]
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
1234 ... 6