1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

Use response file when generating LLVM-C.dll

As discovered in D56774 the command line gets to long, so use a response file
to give the script the libs. This change has been tested and is confirmed
working for me.

Commited on behalf of Jakob Bornecrantz.
Differential Revision: https://reviews.llvm.org/D56781

llvm-svn: 356443
This commit is contained in:
Serge Guelton 2019-03-19 09:14:09 +00:00
parent 08a34614fa
commit ff8e1cddfe
4 changed files with 48 additions and 5 deletions

View File

@ -570,7 +570,7 @@ if(NOT DEFINED LLVM_DYLIB_COMPONENTS)
endif() endif()
option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF) option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF)
if(MSVC) if(MSVC)
option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" OFF) option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON)
else() else()
option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF) option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF)
endif() endif()

View File

@ -132,18 +132,40 @@ if(MSVC)
set(GEN_UNDERSCORE "") set(GEN_UNDERSCORE "")
endif() endif()
# Set this name here, not used in multi conf loop,
# but add script will pick the right one.
set(LIBSFILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.args)
# Get the full name to the libs so the python script understands them. # Get the full name to the libs so the python script understands them.
foreach(lib ${LIB_NAMES}) foreach(lib ${LIB_NAMES})
list(APPEND FULL_LIB_NAMES ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib) list(APPEND FULL_LIB_NAMES ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib)
endforeach() endforeach()
# Need to seperate lib names with newlines.
string(REPLACE ";" "\n" FILE_CONTENT "${FULL_LIB_NAMES}")
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
# Replace the special string with a per config directory.
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} PER_CONF_CONTENT "${FILE_CONTENT}")
# Write out the full lib names into file to be read by the python script.
# One libsfile per build, the add_custom_command should expand
# ${CMAKE_CFG_INTDIR} correctly and select the right one.
file(WRITE ${CMAKE_BINARY_DIR}/${BUILD_MODE}/libllvm-c.args "${PER_CONF_CONTENT}")
endforeach()
else()
# Write out the full lib names into file to be read by the python script.
file(WRITE ${LIBSFILE} "${FILE_CONTENT}")
endif()
# Generate the exports file dynamically. # Generate the exports file dynamically.
set(GEN_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/gen-msvc-exports.py) set(GEN_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/gen-msvc-exports.py)
set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports)
add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE} add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}
COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} ${FULL_LIB_NAMES} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE} COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE}
DEPENDS ${LIB_NAMES} llvm-nm DEPENDS ${LIB_NAMES} llvm-nm
COMMENT "Generating export list for LLVM-C" COMMENT "Generating export list for LLVM-C"
VERBATIM ) VERBATIM )

View File

@ -82,6 +82,10 @@ def gen_llvm_c_export(output, underscore, libs, nm):
def main(): def main():
parser = argparse.ArgumentParser('gen-msvc-exports') parser = argparse.ArgumentParser('gen-msvc-exports')
parser.add_argument(
'-i', '--libsfile', help='file with list of libs, new line separated',
action='store', default=None
)
parser.add_argument( parser.add_argument(
'-o', '--output', help='output filename', default='LLVM-C.exports' '-o', '--output', help='output filename', default='LLVM-C.exports'
) )
@ -93,12 +97,19 @@ def main():
'--nm', help='path to the llvm-nm executable', default='llvm-nm' '--nm', help='path to the llvm-nm executable', default='llvm-nm'
) )
parser.add_argument( parser.add_argument(
'libs', metavar='LIBS', nargs='+', help='list of libraries to generate export from' 'libs', metavar='LIBS', nargs='*', help='list of libraries to generate export from'
) )
ns = parser.parse_args() ns = parser.parse_args()
gen_llvm_c_export(ns.output, ns.underscore, ns.libs, ns.nm) libs = ns.libs
# Add if we where given a libsfile add it to the libs.
if ns.libsfile:
with open(ns.libsfile) as f:
libs.extend(f.read().splitlines())
gen_llvm_c_export(ns.output, ns.underscore, libs, ns.nm)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -52,7 +52,17 @@ svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lldb/%branch% llvm
REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226. REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226.
set cmake_flags=-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DCMAKE_INSTALL_UCRT_LIBRARIES=ON -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% -DPACKAGE_VERSION=%package_version% -DLLDB_RELOCATABLE_PYTHON=1 -DLLDB_TEST_COMPILER=%cd%\build32_stage0\bin\clang.exe -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " set cmake_flags=^
-DCMAKE_BUILD_TYPE=Release ^
-DLLVM_ENABLE_ASSERTIONS=ON ^
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON ^
-DLLVM_BUILD_LLVM_C_DYLIB=ON ^
-DCMAKE_INSTALL_UCRT_LIBRARIES=ON ^
-DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% ^
-DPACKAGE_VERSION=%package_version% ^
-DLLDB_RELOCATABLE_PYTHON=1 ^
-DLLDB_TEST_COMPILER=%cd%\build32_stage0\bin\clang.exe ^
-DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: "
REM TODO: Run the "check-all" tests. REM TODO: Run the "check-all" tests.