llvm.org GIT mirror llvm / release_31
Merge in 156319 156837 156838. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_31@156863 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
10 changed file(s) with 122 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
267267 "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc")
268268 set(LLVMBUILDCMAKEFRAG
269269 "${LLVM_BINARY_DIR}/LLVMBuild.cmake")
270
271 # Create the list of optional components that are enabled
272 if (LLVM_USE_INTEL_JITEVENTS)
273 set(LLVMOPTIONALCOMPONENTS IntelJITEvents)
274 endif (LLVM_USE_INTEL_JITEVENTS)
275 if (LLVM_USE_OPROFILE)
276 set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT)
277 endif (LLVM_USE_OPROFILE)
278
270279 message(STATUS "Constructing LLVMBuild project information")
271280 execute_process(
272281 COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
273282 --native-target "${LLVM_NATIVE_ARCH}"
274283 --enable-targets "${LLVM_TARGETS_TO_BUILD}"
284 --enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
275285 --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC}
276286 --write-cmake-fragment ${LLVMBUILDCMAKEFRAG}
277287 ERROR_VARIABLE LLVMBUILDOUTPUT
350350
351351 # Flags to control building support for OProfile JIT API
352352 USE_OPROFILE := @USE_OPROFILE@
353
354 ifeq ($(USE_INTEL_JITEVENTS), 1)
355 OPTIONAL_COMPONENTS += IntelJITEvents
356 endif
357 ifeq ($(USE_OPROFILE), 1)
358 OPTIONAL_COMPONENTS += OProfileJIT
359 endif
9999 $(Verb) $(LLVMBuildTool) \
100100 --native-target "$(TARGET_NATIVE_ARCH)" \
101101 --enable-targets "$(TARGETS_TO_BUILD)" \
102 --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
102103 --write-library-table $(LLVMConfigLibraryDependenciesInc) \
103104 --write-make-fragment $(LLVMBuildMakeFrag)
104105
271271 components. For example, the X86 target might define a library
272272 group for all of the X86 components. That library group might
273273 then be included in the all-targets library group.

274
275
  • installed [optional] [boolean]
  • 276

    Whether this library is installed. Libraries that are not installed

    277 are only reported by llvm-config when it is run as part of a
    278 development directory.

    274279
    275280
    276281
    1717 [common]
    1818
    1919 [component_0]
    20 type = Library
    20 type = OptionalLibrary
    2121 name = IntelJITEvents
    2222 parent = ExecutionEngine
    1717 [common]
    1818
    1919 [component_0]
    20 type = Library
    20 type = OptionalLibrary
    2121 name = OProfileJIT
    2222 parent = ExecutionEngine
    5353 static void VisitComponent(StringRef Name,
    5454 const StringMap &ComponentMap,
    5555 std::set &VisitedComponents,
    56 std::vector &RequiredLibs) {
    56 std::vector &RequiredLibs,
    57 bool IncludeNonInstalled) {
    5758 // Lookup the component.
    5859 AvailableComponent *AC = ComponentMap.lookup(Name);
    5960 assert(AC && "Invalid component name!");
    6465 return;
    6566 }
    6667
    68 // Only include non-installed components if requested.
    69 if (!AC->IsInstalled && !IncludeNonInstalled)
    70 return;
    71
    6772 // Otherwise, visit all the dependencies.
    6873 for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) {
    6974 VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents,
    70 RequiredLibs);
    75 RequiredLibs, IncludeNonInstalled);
    7176 }
    7277
    7378 // Add to the required library list.
    8287 /// \param Components - The names of the components to find libraries for.
    8388 /// \param RequiredLibs [out] - On return, the ordered list of libraries that
    8489 /// are required to link the given components.
    90 /// \param IncludeNonInstalled - Whether non-installed components should be
    91 /// reported.
    8592 void ComputeLibsForComponents(const std::vector &Components,
    86 std::vector &RequiredLibs) {
    93 std::vector &RequiredLibs,
    94 bool IncludeNonInstalled) {
    8795 std::set VisitedComponents;
    8896
    8997 // Build a map of component names to information.
    106114 }
    107115
    108116 VisitComponent(ComponentLower, ComponentMap, VisitedComponents,
    109 RequiredLibs);
    117 RequiredLibs, IncludeNonInstalled);
    110118 }
    111119
    112120 // The list is now ordered with leafs first, we want the libraries to printed
    277285 PrintLibFiles = true;
    278286 } else if (Arg == "--components") {
    279287 for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
    288 // Only include non-installed components when in a development tree.
    289 if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree)
    290 continue;
    291
    280292 OS << ' ';
    281293 OS << AvailableComponents[j].Name;
    282294 }
    309321
    310322 // Construct the list of all the required libraries.
    311323 std::vector RequiredLibs;
    312 ComputeLibsForComponents(Components, RequiredLibs);
    324 ComputeLibsForComponents(Components, RequiredLibs,
    325 /*IncludeNonInstalled=*/IsInDevelopmentTree);
    313326
    314327 for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
    315328 StringRef Lib = RequiredLibs[i];
    6767 def get_llvmbuild_fragment(self):
    6868 abstract
    6969
    70 def get_parent_target_group(self):
    71 """get_parent_target_group() -> ComponentInfo or None
    72
    73 Return the nearest parent target group (if any), or None if the
    74 component is not part of any target group.
    75 """
    76
    77 # If this is a target group, return it.
    78 if self.type_name == 'TargetGroup':
    79 return self
    80
    81 # Otherwise recurse on the parent, if any.
    82 if self.parent_instance:
    83 return self.parent_instance.get_parent_target_group()
    84
    7085 class GroupComponentInfo(ComponentInfo):
    7186 """
    7287 Group components have no semantics as far as the build system are concerned,
    94109 type_name = 'Library'
    95110
    96111 @staticmethod
    97 def parse(subpath, items):
    112 def parse_items(items):
    98113 kwargs = ComponentInfo.parse_items(items)
    99114 kwargs['library_name'] = items.get_optional_string('library_name')
    100115 kwargs['required_libraries'] = items.get_list('required_libraries')
    101116 kwargs['add_to_library_groups'] = items.get_list(
    102117 'add_to_library_groups')
    118 kwargs['installed'] = items.get_optional_bool('installed', True)
    119 return kwargs
    120
    121 @staticmethod
    122 def parse(subpath, items):
    123 kwargs = LibraryComponentInfo.parse_items(items)
    103124 return LibraryComponentInfo(subpath, **kwargs)
    104125
    105126 def __init__(self, subpath, name, dependencies, parent, library_name,
    106 required_libraries, add_to_library_groups):
    127 required_libraries, add_to_library_groups, installed):
    107128 ComponentInfo.__init__(self, subpath, name, dependencies, parent)
    108129
    109130 # If given, the name to use for the library instead of deriving it from
    117138 # The names of the library group components this component should be
    118139 # considered part of.
    119140 self.add_to_library_groups = list(add_to_library_groups)
    141
    142 # Whether or not this library is installed.
    143 self.installed = installed
    120144
    121145 def get_component_references(self):
    122146 for r in ComponentInfo.get_component_references(self):
    139163 if self.add_to_library_groups:
    140164 print >>result, 'add_to_library_groups = %s' % ' '.join(
    141165 self.add_to_library_groups)
    166 if not self.installed:
    167 print >>result, 'installed = 0'
    142168 return result.getvalue()
    143169
    144170 def get_library_name(self):
    163189
    164190 def get_llvmconfig_component_name(self):
    165191 return self.get_library_name().lower()
    192
    193 class OptionalLibraryComponentInfo(LibraryComponentInfo):
    194 type_name = "OptionalLibrary"
    195
    196 @staticmethod
    197 def parse(subpath, items):
    198 kwargs = LibraryComponentInfo.parse_items(items)
    199 return OptionalLibraryComponentInfo(subpath, **kwargs)
    200
    201 def __init__(self, subpath, name, dependencies, parent, library_name,
    202 required_libraries, add_to_library_groups, installed):
    203 LibraryComponentInfo.__init__(self, subpath, name, dependencies, parent,
    204 library_name, required_libraries,
    205 add_to_library_groups, installed)
    166206
    167207 class LibraryGroupComponentInfo(ComponentInfo):
    168208 type_name = 'LibraryGroup'
    374414 for t in (GroupComponentInfo,
    375415 LibraryComponentInfo, LibraryGroupComponentInfo,
    376416 ToolComponentInfo, BuildToolComponentInfo,
    377 TargetGroupComponentInfo))
    417 TargetGroupComponentInfo, OptionalLibraryComponentInfo))
    378418 def load_from_path(path, subpath):
    379419 # Load the LLVMBuild.txt file as an .ini format file.
    380420 parser = ConfigParser.RawConfigParser()
    311311
    312312 f.close()
    313313
    314 def write_library_table(self, output_path):
    314 def write_library_table(self, output_path, enabled_optional_components):
    315315 # Write out the mapping from component names to required libraries.
    316316 #
    317317 # We do this in topological order so that we know we can append the
    318318 # dependencies for added library groups.
    319319 entries = {}
    320320 for c in self.ordered_component_infos:
    321 # Skip optional components which are not enabled.
    322 if c.type_name == 'OptionalLibrary' \
    323 and c.name not in enabled_optional_components:
    324 continue
    325
    326 # Skip target groups which are not enabled.
    327 tg = c.get_parent_target_group()
    328 if tg and not tg.enabled:
    329 continue
    330
    321331 # Only certain components are in the table.
    322 if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
    332 if c.type_name not in ('Library', 'OptionalLibrary', \
    333 'LibraryGroup', 'TargetGroup'):
    323334 continue
    324335
    325336 # Compute the llvm-config "component name". For historical reasons,
    327338 llvmconfig_component_name = c.get_llvmconfig_component_name()
    328339
    329340 # Get the library name, or None for LibraryGroups.
    330 if c.type_name == 'Library':
    341 if c.type_name == 'Library' or c.type_name == 'OptionalLibrary':
    331342 library_name = c.get_prefixed_library_name()
    343 is_installed = c.installed
    332344 else:
    333345 library_name = None
    346 is_installed = True
    334347
    335348 # Get the component names of all the required libraries.
    336349 required_llvmconfig_component_names = [
    343356
    344357 # Add the entry.
    345358 entries[c.name] = (llvmconfig_component_name, library_name,
    346 required_llvmconfig_component_names)
    359 required_llvmconfig_component_names,
    360 is_installed)
    347361
    348362 # Convert to a list of entries and sort by name.
    349363 entries = entries.values()
    351365 # Create an 'all' pseudo component. We keep the dependency list small by
    352366 # only listing entries that have no other dependents.
    353367 root_entries = set(e[0] for e in entries)
    354 for _,_,deps in entries:
    368 for _,_,deps,_ in entries:
    355369 root_entries -= set(deps)
    356 entries.append(('all', None, root_entries))
    370 entries.append(('all', None, root_entries, True))
    357371
    358372 entries.sort()
    359373
    360374 # Compute the maximum number of required libraries, plus one so there is
    361375 # always a sentinel.
    362376 max_required_libraries = max(len(deps)
    363 for _,_,deps in entries) + 1
    377 for _,_,deps,_ in entries) + 1
    364378
    365379 # Write out the library table.
    366380 make_install_dir(os.path.dirname(output_path))
    381395 print >>f, ' /// The name of the library for this component (or NULL).'
    382396 print >>f, ' const char *Library;'
    383397 print >>f, ''
    398 print >>f, ' /// Whether the component is installed.'
    399 print >>f, ' bool IsInstalled;'
    400 print >>f, ''
    384401 print >>f, '\
    385402 /// The list of libraries required when linking this component.'
    386403 print >>f, ' const char *RequiredLibraries[%d];' % (
    387404 max_required_libraries)
    388405 print >>f, '} AvailableComponents[%d] = {' % len(entries)
    389 for name,library_name,required_names in entries:
    406 for name,library_name,required_names,is_installed in entries:
    390407 if library_name is None:
    391408 library_name_as_cstr = '0'
    392409 else:
    393410 library_name_as_cstr = '"lib%s.a"' % library_name
    394 print >>f, ' { "%s", %s, { %s } },' % (
    395 name, library_name_as_cstr,
    411 print >>f, ' { "%s", %s, %d, { %s } },' % (
    412 name, library_name_as_cstr, is_installed,
    396413 ', '.join('"%s"' % dep
    397414 for dep in required_names))
    398415 print >>f, '};'
    777794 help=("Enable the given space or semi-colon separated "
    778795 "list of targets, or all targets if not present"),
    779796 action="store", default=None)
    797 group.add_option("", "--enable-optional-components",
    798 dest="optional_components", metavar="NAMES",
    799 help=("Enable the given space or semi-colon separated "
    800 "list of optional components"),
    801 action="store", default=None)
    780802 parser.add_option_group(group)
    781803
    782804 (opts, args) = parser.parse_args()
    818840
    819841 # Write out the required library table, if requested.
    820842 if opts.write_library_table:
    821 project_info.write_library_table(opts.write_library_table)
    843 project_info.write_library_table(opts.write_library_table,
    844 opts.optional_components)
    822845
    823846 # Write out the make fragment, if requested.
    824847 if opts.write_make_fragment:
    1919 name = gtest
    2020 parent = Libraries
    2121 required_libraries = Support
    22 installed = 0
    2223
    2324 [component_1]
    2425 type = Library
    2526 name = gtest_main
    2627 parent = Libraries
    2728 required_libraries = gtest
    29 installed = 0