llvm-build: Adopt generation of LLVM_LIBS_TO_EXPORT. Patch by
authorDan Liew <dan@su-root.co.uk>
Fri, 21 Aug 2015 18:10:55 +0000 (18:10 +0000)
committerDan Liew <dan@su-root.co.uk>
Fri, 21 Aug 2015 18:10:55 +0000 (18:10 +0000)
Brad King.

Move `LLVM_LIBS_TO_EXPORT` over to Makefile.llvmbuild and generate it
from `llvm-build` using the same logic used to export the dependencies
of these libraries.  This avoids depending on `llvm-config`.

This refactoring was originally motivated by issue #24154 due to commit
r243297 (Fix `llvm-config` to emit the linker flag for the combined
shared object, 2015-07-27) changing the output of `llvm-config --libs`
to not have the individual libraries when we configure with
`--enable-shared`.  That change was reverted by r244108 but this
refactoring makes sense on its own anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245717 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/Makefile
utils/llvm-build/llvmbuild/main.py

index f644c45dcd0d722265b05f1254cc814eee5bf544..fb375b1ead5d60fc7d674d5d4b5f4001f63ce8ed 100644 (file)
@@ -9,8 +9,6 @@
 
 LEVEL = ../..
 
 
 LEVEL = ../..
 
-LINK_COMPONENTS := all
-
 include $(LEVEL)/Makefile.common
 
 PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
 include $(LEVEL)/Makefile.common
 
 PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
@@ -39,24 +37,13 @@ else
        LLVM_ENABLE_RTTI := 0
 endif
 
        LLVM_ENABLE_RTTI := 0
 endif
 
-# Don't try to run llvm-config during clean because it won't be available
-ifneq ($(MAKECMDGOALS),clean)
-LLVM_LIBS_TO_EXPORT := $(subst -l,,$(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error))
-
-ifeq ($(LLVM_LIBS_TO_EXPORT),Error)
-$(error llvm-config --libs failed)
-endif
-
 # Strip out gtest and gtest_main from LLVM_LIBS_TO_EXPORT, these are not
 # installed and won't be available from the install tree.
 # Strip out gtest and gtest_main from LLVM_LIBS_TO_EXPORT, these are not
 # installed and won't be available from the install tree.
-# FIXME: If we used llvm-config from the install tree this wouldn't be
-# necessary.
 LLVM_LIBS_TO_EXPORT := $(filter-out gtest gtest_main,$(LLVM_LIBS_TO_EXPORT))
 
 ifndef LLVM_LIBS_TO_EXPORT
 $(error LLVM_LIBS_TO_EXPORT cannot be empty)
 endif
 LLVM_LIBS_TO_EXPORT := $(filter-out gtest gtest_main,$(LLVM_LIBS_TO_EXPORT))
 
 ifndef LLVM_LIBS_TO_EXPORT
 $(error LLVM_LIBS_TO_EXPORT cannot be empty)
 endif
-endif
 
 OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
 
 
 OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
 
index 5742b05d4f965cff790027718dddce282576c9ed..6a2da754c3b55f8e24e929b6f40de365f307a6ff 100644 (file)
@@ -640,7 +640,7 @@ set_property(TARGET %s PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES %s)\n""" % (
 
         f.close()
 
 
         f.close()
 
-    def write_make_fragment(self, output_path):
+    def write_make_fragment(self, output_path, enabled_optional_components):
         """
         write_make_fragment(output_path) -> None
 
         """
         write_make_fragment(output_path) -> None
 
@@ -706,6 +706,19 @@ set_property(TARGET %s PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES %s)\n""" % (
             f.write("%s:\n" % (mk_quote_string_for_target(dep),))
         f.write('endif\n')
 
             f.write("%s:\n" % (mk_quote_string_for_target(dep),))
         f.write('endif\n')
 
+        f.write("""
+# List of libraries to be exported for use by applications.
+# See 'cmake/modules/Makefile'.
+LLVM_LIBS_TO_EXPORT :=""")
+        self.foreach_cmake_library(
+            lambda ci:
+                f.write(' \\\n  %s' % ci.get_prefixed_library_name())
+            ,
+            enabled_optional_components,
+            skip_disabled = True
+            )
+        f.write('\n')
+
         f.close()
 
 def add_magic_target_components(parser, project, opts):
         f.close()
 
 def add_magic_target_components(parser, project, opts):
@@ -929,7 +942,8 @@ given by --build-root) at the same SUBPATH""",
 
     # Write out the make fragment, if requested.
     if opts.write_make_fragment:
 
     # Write out the make fragment, if requested.
     if opts.write_make_fragment:
-        project_info.write_make_fragment(opts.write_make_fragment)
+        project_info.write_make_fragment(opts.write_make_fragment,
+                                         opts.optional_components)
 
     # Write out the cmake fragment, if requested.
     if opts.write_cmake_fragment:
 
     # Write out the cmake fragment, if requested.
     if opts.write_cmake_fragment: