[cfe-commits] [PATCH] problems building shared libraries with cmake

Peter Collingbourne peter at pcc.me.uk
Sun May 23 12:56:53 PDT 2010


On Mon, Oct 05, 2009 at 03:38:26PM -0700, Douglas Gregor wrote:
> --- tools/index-test/CMakeLists.txt	(revision 83272)
> +++ tools/index-test/CMakeLists.txt	(working copy)
> @@ -7,11 +7,20 @@
>    clangAST
>    clangLex
>    clangBasic
> +  clangRewrite
> +  clangParse
> +  clangAnalysis
> +  clangCodeGen
>    )
>
>  set( LLVM_LINK_COMPONENTS
>    bitreader
>    mc
> +  ipo
> +  scalaropts
> +  codegen
> +  bitwriter
> +  selectiondag
>    )
>
> This doesn't make a lot of sense. The index library's test harness  
> should not depend on anything related to code generation, much less on  
> optimization passes. If these are real dependencies, we need to try to  
> break them.

Sorry for the slow reply.

I had a chance to look into this problem again, and found that the
problem persists for clients of clangFrontend, which has a number of
(IMHO) unnecessary dependencies on various backend libraries.  This is
also causing real problems for us as a client of the Frontend library
(no backend/code generation) as we are needing to pull in a large
number of LLVM code generation libraries which slows down linking time.

When I made this patch, the dependencies were mostly caused by the AST
consumers in Frontend/Backend.cpp.  Now I see that this file has been
split up into several source files containing separate AST consumers.
Using some nm magic, I found that the files causing problems right
now appear to be:

AnalysisConsumer.cpp
CodeGenAction.cpp
FixItRewriter.cpp
HTMLDiagnostics.cpp
HTMLPrint.cpp
PlistDiagnostics.cpp
RewriteMacros.cpp
RewriteObjC.cpp
RewriteTest.cpp

I propose that we move each of these files to another appropriate
library, specifically:

AnalysisConsumer.cpp -> Checker
CodeGenAction.cpp -> CodeGen
FixItRewriter.cpp -> Rewrite
HTMLDiagnostics.cpp -> Rewrite or Checker
HTMLPrint.cpp -> Rewrite
PlistDiagnostics.cpp -> Checker
RewriteMacros.cpp -> Rewrite
RewriteObjC.cpp -> Rewrite
RewriteTest.cpp -> Rewrite

This may introduce a dependency on Frontend for the Checker, CodeGen
and Rewrite libraries, but I think this is the right approach, as I
think it is far more likely for a client to need to use the frontend
on its own than a backend on its own.  It also adds the AST consumers
to the library which indicates their function.

HTMLDiagnostics.cpp depends on Rewrite and Checker so we could move
it to either one of these, but this would create a dependency between
the two libraries.  Or we could move it to a new library.

Please let me know what you think of this proposal.

Thanks,
-- 
Peter



More information about the cfe-commits mailing list