1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Re-commit: r366610 and r366612: Expand pseudo-components before embedding in llvm-config

There were two main problems:
* The 'nativecodegen' pseudo-component was unconditionally adding
  ${native_tgt}CodeGen even though it conditionally added ${native_tgt}Info and
  ${native_tgt}Desc. This has been fixed by making ${native_tgt}CodeGen
  conditional too
* The 'all' pseudo-component was causing library names like LLVMLLVMDemangle as
  the expansion was to a library name and not a component. There doesn't seem to
  be a list of available components anywhere so this has been fixed by moving the
  expansion of 'all' back where it was before. This manifested in different ways
  on different builders but it was the same root cause

llvm-svn: 366622
This commit is contained in:
Daniel Sanders 2019-07-19 22:46:47 +00:00
parent 0e9abc2fbd
commit 60c2b0f7af
3 changed files with 101 additions and 83 deletions

View File

@ -117,6 +117,102 @@ function(llvm_map_components_to_libraries OUT_VAR)
set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
endfunction(llvm_map_components_to_libraries)
# Expand pseudo-components into real components.
# Does not cover 'native', 'backend', or 'engine' as these require special
# handling. Also does not cover 'all' as we only have a list of the libnames
# available and not a list of the components.
function(llvm_expand_pseudo_components out_components)
set( link_components ${ARGN} )
foreach(c ${link_components})
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
if( TARGET LLVM${c}CodeGen )
list(APPEND expanded_components "${c}CodeGen")
else()
if( TARGET LLVM${c} )
list(APPEND expanded_components "${c}")
else()
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
endif()
endif()
if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "${c}AsmPrinter")
endif()
if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "${c}AsmParser")
endif()
if( TARGET LLVM${c}Desc )
list(APPEND expanded_components "${c}Desc")
endif()
if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "${c}Disassembler")
endif()
if( TARGET LLVM${c}Info )
list(APPEND expanded_components "${c}Info")
endif()
if( TARGET LLVM${c}Utils )
list(APPEND expanded_components "${c}Utils")
endif()
elseif( c STREQUAL "nativecodegen" )
if( TARGET LLVM${LLVM_NATIVE_ARCH}CodeGen )
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}CodeGen")
endif()
if( TARGET LLVM${LLVM_NATIVE_ARCH}Desc )
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Desc")
endif()
if( TARGET LLVM${LLVM_NATIVE_ARCH}Info )
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Info")
endif()
elseif( c STREQUAL "AllTargetsCodeGens" )
# Link all the codegens from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}CodeGen)
list(APPEND expanded_components "${t}CodeGen")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsAsmPrinters" )
# Link all the asm printers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmPrinter )
list(APPEND expanded_components "${t}AsmPrinter")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsAsmParsers" )
# Link all the asm parsers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmParser )
list(APPEND expanded_components "${t}AsmParser")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDescs" )
# Link all the descs from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Desc )
list(APPEND expanded_components "${t}Desc")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDisassemblers" )
# Link all the disassemblers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Disassembler )
list(APPEND expanded_components "${t}Disassembler")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsInfos" )
# Link all the infos from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Info )
list(APPEND expanded_components "${t}Info")
endif()
endforeach(t)
else()
list(APPEND expanded_components "${c}")
endif()
endforeach()
set(${out_components} ${expanded_components} PARENT_SCOPE)
endfunction(llvm_expand_pseudo_components out_components)
# This is a variant intended for the final user:
# Map LINK_COMPONENTS to actual libnames.
function(llvm_map_components_to_libnames out_libs)
@ -162,95 +258,16 @@ function(llvm_map_components_to_libnames out_libs)
endif()
# Translate symbolic component names to real libraries:
llvm_expand_pseudo_components(link_components ${link_components})
foreach(c ${link_components})
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
if( TARGET LLVM${c}CodeGen )
list(APPEND expanded_components "LLVM${c}CodeGen")
else()
if( TARGET LLVM${c} )
list(APPEND expanded_components "LLVM${c}")
else()
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
endif()
endif()
if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "LLVM${c}AsmParser")
endif()
if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
if( TARGET LLVM${c}Desc )
list(APPEND expanded_components "LLVM${c}Desc")
endif()
if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "LLVM${c}Disassembler")
endif()
if( TARGET LLVM${c}Info )
list(APPEND expanded_components "LLVM${c}Info")
endif()
if( TARGET LLVM${c}Utils )
list(APPEND expanded_components "LLVM${c}Utils")
endif()
elseif( c STREQUAL "native" )
if( c STREQUAL "native" )
# already processed
elseif( c STREQUAL "nativecodegen" )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen")
if( TARGET LLVM${LLVM_NATIVE_ARCH}Desc )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Desc")
endif()
if( TARGET LLVM${LLVM_NATIVE_ARCH}Info )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Info")
endif()
elseif( c STREQUAL "backend" )
# same case as in `native'.
elseif( c STREQUAL "engine" )
# already processed
elseif( c STREQUAL "all" )
list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
elseif( c STREQUAL "AllTargetsCodeGens" )
# Link all the codegens from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}CodeGen)
list(APPEND expanded_components "LLVM${t}CodeGen")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsAsmPrinters" )
# Link all the asm printers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmPrinter )
list(APPEND expanded_components "LLVM${t}AsmPrinter")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsAsmParsers" )
# Link all the asm parsers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmParser )
list(APPEND expanded_components "LLVM${t}AsmParser")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDescs" )
# Link all the descs from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Desc )
list(APPEND expanded_components "LLVM${t}Desc")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDisassemblers" )
# Link all the disassemblers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Disassembler )
list(APPEND expanded_components "LLVM${t}Disassembler")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsInfos" )
# Link all the infos from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Info )
list(APPEND expanded_components "LLVM${t}Info")
endif()
endforeach(t)
else( NOT idx LESS 0 )
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
@ -272,7 +289,7 @@ function(llvm_map_components_to_libnames out_libs)
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
list(APPEND expanded_components ${canonical_lib})
endif( lib_idx LESS 0 )
endif( NOT idx LESS 0 )
endif( c STREQUAL "native" )
endforeach(c)
set(${out_libs} ${expanded_components} PARENT_SCOPE)

View File

@ -30,7 +30,7 @@
#define LLVM_ENABLE_DYLIB @LLVM_BUILD_LLVM_DYLIB@
#define LLVM_LINK_DYLIB @LLVM_LINK_LLVM_DYLIB@
#define LLVM_ENABLE_SHARED @BUILD_SHARED_LIBS@
#define LLVM_DYLIB_COMPONENTS "@LLVM_DYLIB_COMPONENTS@"
#define LLVM_DYLIB_COMPONENTS "@LLVM_DYLIB_COMPONENTS_expanded@"
#define LLVM_DYLIB_VERSION "@LLVM_DYLIB_VERSION@"
#define LLVM_HAS_GLOBAL_ISEL @LLVM_HAS_GLOBAL_ISEL@
#define LLVM_TOOLS_INSTALL_DIR "@LLVM_TOOLS_INSTALL_DIR@"

View File

@ -60,6 +60,7 @@ llvm_canonicalize_cmake_booleans(
LLVM_HAS_RTTI
LLVM_HAS_GLOBAL_ISEL
BUILD_SHARED_LIBS)
llvm_expand_pseudo_components(LLVM_DYLIB_COMPONENTS_expanded "${LLVM_DYLIB_COMPONENTS}")
configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
# Set build-time environment(s).