llvm.org GIT mirror llvm / 7549354
Make IntelJITEvents and OProfileJIT as optional libraries and add optional library support to the llvm-build tool: - Add new command line parameter to llvm-build: “--enable-optional-libraries” - Add handing of new llvm-build library type “OptionalLibrary” - Update Cmake and automake build systems to pass correct flags to llvm-build based on configuration Patch by Dan Malea! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156319 91177308-0d34-0410-b5e6-96231b3b80d8 Preston Gurd 8 years ago
7 changed file(s) with 57 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
268268 "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc")
269269 set(LLVMBUILDCMAKEFRAG
270270 "${LLVM_BINARY_DIR}/LLVMBuild.cmake")
271
272 # Create the list of optional components that are enabled
273 if (LLVM_USE_INTEL_JITEVENTS)
274 set(LLVMOPTIONALCOMPONENTS IntelJITEvents)
275 endif (LLVM_USE_INTEL_JITEVENTS)
276 if (LLVM_USE_OPROFILE)
277 set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT)
278 endif (LLVM_USE_OPROFILE)
279
271280 message(STATUS "Constructing LLVMBuild project information")
272281 execute_process(
273282 COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
274283 --native-target "${LLVM_NATIVE_ARCH}"
275284 --enable-targets "${LLVM_TARGETS_TO_BUILD}"
285 --enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
276286 --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC}
277287 --write-cmake-fragment ${LLVMBUILDCMAKEFRAG}
278288 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
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
9494 type_name = 'Library'
9595
9696 @staticmethod
97 def parse(subpath, items):
97 def parse_items(items):
9898 kwargs = ComponentInfo.parse_items(items)
9999 kwargs['library_name'] = items.get_optional_string('library_name')
100100 kwargs['required_libraries'] = items.get_list('required_libraries')
101101 kwargs['add_to_library_groups'] = items.get_list(
102102 'add_to_library_groups')
103 return kwargs
104
105 @staticmethod
106 def parse(subpath, items):
107 kwargs = LibraryComponentInfo.parse_items(items)
103108 return LibraryComponentInfo(subpath, **kwargs)
104109
105110 def __init__(self, subpath, name, dependencies, parent, library_name,
163168
164169 def get_llvmconfig_component_name(self):
165170 return self.get_library_name().lower()
171
172 class OptionalLibraryComponentInfo(LibraryComponentInfo):
173 type_name = "OptionalLibrary"
174
175 @staticmethod
176 def parse(subpath, items):
177 kwargs = LibraryComponentInfo.parse_items(items)
178 return OptionalLibraryComponentInfo(subpath, **kwargs)
179
180 def __init__(self, subpath, name, dependencies, parent, library_name,
181 required_libraries, add_to_library_groups):
182 LibraryComponentInfo.__init__(self, subpath, name, dependencies, parent,
183 library_name, required_libraries,
184 add_to_library_groups)
166185
167186 class LibraryGroupComponentInfo(ComponentInfo):
168187 type_name = 'LibraryGroup'
374393 for t in (GroupComponentInfo,
375394 LibraryComponentInfo, LibraryGroupComponentInfo,
376395 ToolComponentInfo, BuildToolComponentInfo,
377 TargetGroupComponentInfo))
396 TargetGroupComponentInfo, OptionalLibraryComponentInfo))
378397 def load_from_path(path, subpath):
379398 # Load the LLVMBuild.txt file as an .ini format file.
380399 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
321326 # Only certain components are in the table.
322 if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
327 if c.type_name not in ('Library', 'OptionalLibrary', \
328 'LibraryGroup', 'TargetGroup'):
323329 continue
324330
325331 # Compute the llvm-config "component name". For historical reasons,
327333 llvmconfig_component_name = c.get_llvmconfig_component_name()
328334
329335 # Get the library name, or None for LibraryGroups.
330 if c.type_name == 'Library':
336 if c.type_name == 'Library' or c.type_name == 'OptionalLibrary':
331337 library_name = c.get_prefixed_library_name()
332338 else:
333339 library_name = None
777783 help=("Enable the given space or semi-colon separated "
778784 "list of targets, or all targets if not present"),
779785 action="store", default=None)
786 group.add_option("", "--enable-optional-components",
787 dest="optional_components", metavar="NAMES",
788 help=("Enable the given space or semi-colon separated "
789 "list of optional components"),
790 action="store", default=None)
780791 parser.add_option_group(group)
781792
782793 (opts, args) = parser.parse_args()
818829
819830 # Write out the required library table, if requested.
820831 if opts.write_library_table:
821 project_info.write_library_table(opts.write_library_table)
832 project_info.write_library_table(opts.write_library_table,
833 opts.optional_components)
822834
823835 # Write out the make fragment, if requested.
824836 if opts.write_make_fragment: