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!

llvm-svn: 156319
This commit is contained in:
Preston Gurd 2012-05-07 19:38:40 +00:00
parent 8a7a7d90d7
commit e65f4e66ac
7 changed files with 57 additions and 8 deletions

View File

@ -269,11 +269,21 @@ set(LLVMCONFIGLIBRARYDEPENDENCIESINC
"${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc") "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc")
set(LLVMBUILDCMAKEFRAG set(LLVMBUILDCMAKEFRAG
"${LLVM_BINARY_DIR}/LLVMBuild.cmake") "${LLVM_BINARY_DIR}/LLVMBuild.cmake")
# Create the list of optional components that are enabled
if (LLVM_USE_INTEL_JITEVENTS)
set(LLVMOPTIONALCOMPONENTS IntelJITEvents)
endif (LLVM_USE_INTEL_JITEVENTS)
if (LLVM_USE_OPROFILE)
set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT)
endif (LLVM_USE_OPROFILE)
message(STATUS "Constructing LLVMBuild project information") message(STATUS "Constructing LLVMBuild project information")
execute_process( execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL} COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
--native-target "${LLVM_NATIVE_ARCH}" --native-target "${LLVM_NATIVE_ARCH}"
--enable-targets "${LLVM_TARGETS_TO_BUILD}" --enable-targets "${LLVM_TARGETS_TO_BUILD}"
--enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
--write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC} --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC}
--write-cmake-fragment ${LLVMBUILDCMAKEFRAG} --write-cmake-fragment ${LLVMBUILDCMAKEFRAG}
ERROR_VARIABLE LLVMBUILDOUTPUT ERROR_VARIABLE LLVMBUILDOUTPUT

View File

@ -351,3 +351,10 @@ INTEL_JITEVENTS_LIBDIR := @INTEL_JITEVENTS_LIBDIR@
# Flags to control building support for OProfile JIT API # Flags to control building support for OProfile JIT API
USE_OPROFILE := @USE_OPROFILE@ USE_OPROFILE := @USE_OPROFILE@
ifeq ($(USE_INTEL_JITEVENTS), 1)
OPTIONAL_COMPONENTS += IntelJITEvents
endif
ifeq ($(USE_OPROFILE), 1)
OPTIONAL_COMPONENTS += OProfileJIT
endif

View File

@ -100,6 +100,7 @@ $(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
$(Verb) $(LLVMBuildTool) \ $(Verb) $(LLVMBuildTool) \
--native-target "$(TARGET_NATIVE_ARCH)" \ --native-target "$(TARGET_NATIVE_ARCH)" \
--enable-targets "$(TARGETS_TO_BUILD)" \ --enable-targets "$(TARGETS_TO_BUILD)" \
--enable-optional-components "$(OPTIONAL_COMPONENTS)" \
--write-library-table $(LLVMConfigLibraryDependenciesInc) \ --write-library-table $(LLVMConfigLibraryDependenciesInc) \
--write-make-fragment $(LLVMBuildMakeFrag) --write-make-fragment $(LLVMBuildMakeFrag)

View File

@ -18,6 +18,6 @@
[common] [common]
[component_0] [component_0]
type = Library type = OptionalLibrary
name = IntelJITEvents name = IntelJITEvents
parent = ExecutionEngine parent = ExecutionEngine

View File

@ -18,6 +18,6 @@
[common] [common]
[component_0] [component_0]
type = Library type = OptionalLibrary
name = OProfileJIT name = OProfileJIT
parent = ExecutionEngine parent = ExecutionEngine

View File

@ -95,12 +95,17 @@ class LibraryComponentInfo(ComponentInfo):
type_name = 'Library' type_name = 'Library'
@staticmethod @staticmethod
def parse(subpath, items): def parse_items(items):
kwargs = ComponentInfo.parse_items(items) kwargs = ComponentInfo.parse_items(items)
kwargs['library_name'] = items.get_optional_string('library_name') kwargs['library_name'] = items.get_optional_string('library_name')
kwargs['required_libraries'] = items.get_list('required_libraries') kwargs['required_libraries'] = items.get_list('required_libraries')
kwargs['add_to_library_groups'] = items.get_list( kwargs['add_to_library_groups'] = items.get_list(
'add_to_library_groups') 'add_to_library_groups')
return kwargs
@staticmethod
def parse(subpath, items):
kwargs = LibraryComponentInfo.parse_items(items)
return LibraryComponentInfo(subpath, **kwargs) return LibraryComponentInfo(subpath, **kwargs)
def __init__(self, subpath, name, dependencies, parent, library_name, def __init__(self, subpath, name, dependencies, parent, library_name,
@ -165,6 +170,20 @@ class LibraryComponentInfo(ComponentInfo):
def get_llvmconfig_component_name(self): def get_llvmconfig_component_name(self):
return self.get_library_name().lower() return self.get_library_name().lower()
class OptionalLibraryComponentInfo(LibraryComponentInfo):
type_name = "OptionalLibrary"
@staticmethod
def parse(subpath, items):
kwargs = LibraryComponentInfo.parse_items(items)
return OptionalLibraryComponentInfo(subpath, **kwargs)
def __init__(self, subpath, name, dependencies, parent, library_name,
required_libraries, add_to_library_groups):
LibraryComponentInfo.__init__(self, subpath, name, dependencies, parent,
library_name, required_libraries,
add_to_library_groups)
class LibraryGroupComponentInfo(ComponentInfo): class LibraryGroupComponentInfo(ComponentInfo):
type_name = 'LibraryGroup' type_name = 'LibraryGroup'
@ -375,7 +394,7 @@ _component_type_map = dict(
for t in (GroupComponentInfo, for t in (GroupComponentInfo,
LibraryComponentInfo, LibraryGroupComponentInfo, LibraryComponentInfo, LibraryGroupComponentInfo,
ToolComponentInfo, BuildToolComponentInfo, ToolComponentInfo, BuildToolComponentInfo,
TargetGroupComponentInfo)) TargetGroupComponentInfo, OptionalLibraryComponentInfo))
def load_from_path(path, subpath): def load_from_path(path, subpath):
# Load the LLVMBuild.txt file as an .ini format file. # Load the LLVMBuild.txt file as an .ini format file.
parser = ConfigParser.RawConfigParser() parser = ConfigParser.RawConfigParser()

View File

@ -312,15 +312,21 @@ subdirectories = %s
f.close() f.close()
def write_library_table(self, output_path): def write_library_table(self, output_path, enabled_optional_components):
# Write out the mapping from component names to required libraries. # Write out the mapping from component names to required libraries.
# #
# We do this in topological order so that we know we can append the # We do this in topological order so that we know we can append the
# dependencies for added library groups. # dependencies for added library groups.
entries = {} entries = {}
for c in self.ordered_component_infos: for c in self.ordered_component_infos:
# Skip optional components which are not enabled
if c.type_name == 'OptionalLibrary' \
and c.name not in enabled_optional_components:
continue
# Only certain components are in the table. # Only certain components are in the table.
if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'): if c.type_name not in ('Library', 'OptionalLibrary', \
'LibraryGroup', 'TargetGroup'):
continue continue
# Compute the llvm-config "component name". For historical reasons, # Compute the llvm-config "component name". For historical reasons,
@ -328,7 +334,7 @@ subdirectories = %s
llvmconfig_component_name = c.get_llvmconfig_component_name() llvmconfig_component_name = c.get_llvmconfig_component_name()
# Get the library name, or None for LibraryGroups. # Get the library name, or None for LibraryGroups.
if c.type_name == 'Library': if c.type_name == 'Library' or c.type_name == 'OptionalLibrary':
library_name = c.get_prefixed_library_name() library_name = c.get_prefixed_library_name()
else: else:
library_name = None library_name = None
@ -778,6 +784,11 @@ given by --build-root) at the same SUBPATH""",
help=("Enable the given space or semi-colon separated " help=("Enable the given space or semi-colon separated "
"list of targets, or all targets if not present"), "list of targets, or all targets if not present"),
action="store", default=None) action="store", default=None)
group.add_option("", "--enable-optional-components",
dest="optional_components", metavar="NAMES",
help=("Enable the given space or semi-colon separated "
"list of optional components"),
action="store", default=None)
parser.add_option_group(group) parser.add_option_group(group)
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()
@ -819,7 +830,8 @@ given by --build-root) at the same SUBPATH""",
# Write out the required library table, if requested. # Write out the required library table, if requested.
if opts.write_library_table: if opts.write_library_table:
project_info.write_library_table(opts.write_library_table) project_info.write_library_table(opts.write_library_table,
opts.optional_components)
# Write out the make fragment, if requested. # Write out the make fragment, if requested.
if opts.write_make_fragment: if opts.write_make_fragment: