Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6.
Adds the patch by @hans from
https://github.com/llvm/llvm-project/issues/62719
This patch fixes the Windows build.
d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews
D144509 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.
This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193
Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.
D150532 [OpenMP] Compile assembly files as ASM, not C
Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent)
when compiling a file which has been set as having the language
C. This behaviour change only takes place if "cmake_minimum_required"
is set to 3.20 or newer, or if the policy CMP0119 is set to new.
Attempting to compile assembly files with "-x c" fails, however
this is workarounded in many cases, as OpenMP overrides this with
"-x assembler-with-cpp", however this is only added for non-Windows
targets.
Thus, after increasing cmake_minimum_required to 3.20, this breaks
compiling the GNU assembly for Windows targets; the GNU assembly is
used for ARM and AArch64 Windows targets when building with Clang.
This patch unbreaks that.
D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump
The build uses other mechanism to select the runtime.
Fixes #62719
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D151344
2023-05-24 18:12:32 +02:00
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
2015-07-17 15:50:48 +00:00
|
|
|
|
2022-10-24 06:31:37 +02:00
|
|
|
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
|
|
|
|
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
|
|
|
|
endif()
|
|
|
|
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
|
|
|
|
NO_POLICY_SCOPE)
|
|
|
|
|
2019-05-22 13:23:15 +00:00
|
|
|
# Add path for custom modules.
|
2017-04-27 16:04:26 +00:00
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
|
|
|
|
)
|
|
|
|
|
2019-07-17 16:47:02 +00:00
|
|
|
# If we are not building as part of LLVM, build LLDB as a standalone project,
|
|
|
|
# using LLVM as an external library.
|
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
2019-07-29 23:09:31 +00:00
|
|
|
project(lldb)
|
2022-01-19 06:45:07 +00:00
|
|
|
set(LLDB_BUILT_STANDALONE TRUE)
|
2022-11-17 13:46:40 -08:00
|
|
|
set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "")
|
2022-01-19 06:45:07 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Must go below project(..)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-10-23 14:47:50 +02:00
|
|
|
option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
|
|
|
|
|
2022-01-19 06:45:07 +00:00
|
|
|
if(LLDB_BUILT_STANDALONE)
|
2022-08-05 21:45:55 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
|
2019-10-29 08:24:10 -07:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS NO)
|
2023-05-15 14:29:20 -07:00
|
|
|
|
|
|
|
include(LLDBStandalone)
|
2019-07-17 16:47:02 +00:00
|
|
|
endif()
|
|
|
|
|
2017-04-27 16:04:26 +00:00
|
|
|
include(LLDBConfig)
|
|
|
|
include(AddLLDB)
|
2014-05-28 17:06:04 +00:00
|
|
|
|
2019-05-22 13:23:15 +00:00
|
|
|
# Define the LLDB_CONFIGURATION_xxx matching the build type.
|
2020-08-10 22:45:23 -07:00
|
|
|
if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
|
|
|
|
add_definitions(-DLLDB_CONFIGURATION_DEBUG)
|
2017-07-28 15:39:50 +00:00
|
|
|
endif()
|
|
|
|
|
2019-02-12 00:30:21 +00:00
|
|
|
if (WIN32)
|
|
|
|
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
|
|
|
|
endif()
|
|
|
|
|
2019-12-13 10:37:33 -08:00
|
|
|
if (LLDB_ENABLE_PYTHON)
|
2021-11-16 13:50:18 -08:00
|
|
|
set(cachestring_LLDB_PYTHON_RELATIVE_PATH
|
[lldb] remove usage of distutils, fix python path on debian/ubuntu
distutils is deprecated and will be removed, so we shouldn't be
using it.
We were using it to compute LLDB_PYTHON_RELATIVE_PATH.
Discussing a similar issue
[at python.org](https://bugs.python.org/issue41282), Filipe Laíns said:
If you are relying on the value of distutils.sysconfig.get_python_lib()
as you shown in your system, you probably don't want to. That
directory (dist-packages) should be for Debian provided packages
only, so moving to sysconfig.get_path() would be a good thing,
as it has the correct value for user installed packages on your
system.
So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.
On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.
On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.
This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D114106
2021-11-17 13:14:10 -08:00
|
|
|
"Path where Python modules are installed, relative to LLDB's install prefix")
|
2021-11-16 13:50:18 -08:00
|
|
|
set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
|
[lldb] remove usage of distutils, fix python path on debian/ubuntu
distutils is deprecated and will be removed, so we shouldn't be
using it.
We were using it to compute LLDB_PYTHON_RELATIVE_PATH.
Discussing a similar issue
[at python.org](https://bugs.python.org/issue41282), Filipe Laíns said:
If you are relying on the value of distutils.sysconfig.get_python_lib()
as you shown in your system, you probably don't want to. That
directory (dist-packages) should be for Debian provided packages
only, so moving to sysconfig.get_path() would be a good thing,
as it has the correct value for user installed packages on your
system.
So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.
On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.
On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.
This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D114106
2021-11-17 13:14:10 -08:00
|
|
|
"Path to python interpreter exectuable, relative to python's install prefix")
|
2021-11-16 14:32:03 -08:00
|
|
|
set(cachestring_LLDB_PYTHON_EXT_SUFFIX
|
|
|
|
"Filename extension for native code python modules")
|
2021-05-05 13:26:56 +03:00
|
|
|
|
2021-11-16 14:32:03 -08:00
|
|
|
foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
|
2021-11-16 13:50:18 -08:00
|
|
|
if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${Python3_EXECUTABLE}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
|
|
|
|
${var}
|
|
|
|
OUTPUT_VARIABLE value
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
file(TO_CMAKE_PATH "${value}" value)
|
|
|
|
set(${var} ${value} CACHE STRING ${cachestring_${var}})
|
|
|
|
else()
|
|
|
|
if ("${${var}}" STREQUAL "")
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Crosscompiling LLDB with Python requires manually setting ${var}.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2014-07-04 06:43:47 +00:00
|
|
|
endif ()
|
[lldb] Let table gen create command option initializers.
Summary:
We currently have man large arrays containing initializers for our command options.
These tables are tricky maintain as we don't have any good place to check them for consistency and
it's also hard to read (`nullptr, {}, 0` is not very descriptive).
This patch fixes this by letting table gen generate those tables. This way we can have a more readable
syntax for this (especially for all the default arguments) and we can let TableCheck check them
for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.).
Also refactoring the related data structures can now be done without changing the hundred of option initializers.
For example, this line:
```
{LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
```
becomes this:
```
def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">;
```
For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other
option initializers tables in separate patches.
Reviewers: JDevlieghere, davide, sgraenitz
Reviewed By: JDevlieghere
Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64365
llvm-svn: 365908
2019-07-12 15:30:55 +00:00
|
|
|
|
2021-10-12 22:08:05 +08:00
|
|
|
if (LLDB_ENABLE_LUA)
|
|
|
|
find_program(Lua_EXECUTABLE lua5.3)
|
|
|
|
set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/5.3")
|
|
|
|
set(LLDB_LUA_RELATIVE_PATH ${LLDB_LUA_DEFAULT_RELATIVE_PATH}
|
|
|
|
CACHE STRING "Path where Lua modules are installed, relative to install prefix")
|
|
|
|
endif ()
|
|
|
|
|
2019-12-22 10:01:09 +02:00
|
|
|
if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
|
2020-01-09 07:57:59 -08:00
|
|
|
add_subdirectory(bindings)
|
2019-12-22 10:01:09 +02:00
|
|
|
endif ()
|
2019-12-08 15:32:57 -08:00
|
|
|
|
[lldb] Let LLDB depend on intrinsics_gen to fix non-deterministic module build failures
Summary:
When building with modules we currently fail randomly to build LLDB's modules and get error messages like below:
```
In file included from <module-includes>:1:
In file included from llvm-project/llvm/include/llvm/IR/Argument.h:18:
llvm-project/llvm/include/llvm/IR/Attributes.h:74:14: fatal error: 'llvm/IR/Attributes.inc' file not found
#include "llvm/IR/Attributes.inc"
^~~~~~~~~~~~~~~~~~~~~~~~
...
In file included from llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp:9:
llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h:12:10: fatal error: could not build module 'lldb_Wrapper'
```
The reason for this is that our source files can include Clang headers which in turn include files like Attributes.inc which
are generated by intrinsics_gen. However, it seems Clang can't express this dependency in its CMake code, so intrinsics_gen
is actually not guaranteed to be built before we start parsing LLDB source files and Clang headers. Clang worked around this
by letting all libraries depend on intrinsics_gen, which at least lets their builds pass.
As I haven't figured out how to solve these dependencies properly and I want to get the LLDB+Modules build green,
I suggest we copy Clang's hack until we figure out how to get Clang's dependencies right.
Reviewers: sgraenitz, aprantl, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: mgorny, javed.absar, kristof.beyls, mgrang, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66208
llvm-svn: 368975
2019-08-15 07:29:53 +00:00
|
|
|
# We need the headers generated by instrinsics_gen before we can compile
|
|
|
|
# any source file in LLDB as the imported Clang modules might include
|
|
|
|
# some of these generated headers. This approach is copied from Clang's main
|
|
|
|
# CMakeLists.txt, so it should kept in sync the code in Clang which was added
|
|
|
|
# in llvm-svn 308844.
|
2020-07-17 16:43:05 -07:00
|
|
|
if(LLVM_ENABLE_MODULES)
|
[lldb] Let LLDB depend on intrinsics_gen to fix non-deterministic module build failures
Summary:
When building with modules we currently fail randomly to build LLDB's modules and get error messages like below:
```
In file included from <module-includes>:1:
In file included from llvm-project/llvm/include/llvm/IR/Argument.h:18:
llvm-project/llvm/include/llvm/IR/Attributes.h:74:14: fatal error: 'llvm/IR/Attributes.inc' file not found
#include "llvm/IR/Attributes.inc"
^~~~~~~~~~~~~~~~~~~~~~~~
...
In file included from llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp:9:
llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h:12:10: fatal error: could not build module 'lldb_Wrapper'
```
The reason for this is that our source files can include Clang headers which in turn include files like Attributes.inc which
are generated by intrinsics_gen. However, it seems Clang can't express this dependency in its CMake code, so intrinsics_gen
is actually not guaranteed to be built before we start parsing LLDB source files and Clang headers. Clang worked around this
by letting all libraries depend on intrinsics_gen, which at least lets their builds pass.
As I haven't figured out how to solve these dependencies properly and I want to get the LLDB+Modules build green,
I suggest we copy Clang's hack until we figure out how to get Clang's dependencies right.
Reviewers: sgraenitz, aprantl, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: mgorny, javed.absar, kristof.beyls, mgrang, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66208
llvm-svn: 368975
2019-08-15 07:29:53 +00:00
|
|
|
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
|
|
|
|
endif()
|
|
|
|
|
2021-08-13 13:25:14 -07:00
|
|
|
if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
|
2019-07-18 00:21:57 +00:00
|
|
|
set(LLVM_USE_HOST_TOOLS ON)
|
|
|
|
include(CrossCompile)
|
2019-07-18 23:40:23 +00:00
|
|
|
if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
|
2019-07-18 00:21:57 +00:00
|
|
|
message(FATAL_ERROR
|
2019-07-18 23:40:23 +00:00
|
|
|
"Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
|
2019-07-18 00:21:57 +00:00
|
|
|
for building the native lldb-tblgen used during the build process.")
|
|
|
|
endif()
|
|
|
|
llvm_create_cross_target(lldb NATIVE "" Release
|
2019-07-18 23:40:23 +00:00
|
|
|
-DLLVM_DIR=${NATIVE_LLVM_DIR}
|
|
|
|
-DClang_DIR=${NATIVE_Clang_DIR})
|
2019-07-18 00:21:57 +00:00
|
|
|
endif()
|
|
|
|
|
2019-07-26 18:14:04 +00:00
|
|
|
# TableGen
|
[lldb] Let table gen create command option initializers.
Summary:
We currently have man large arrays containing initializers for our command options.
These tables are tricky maintain as we don't have any good place to check them for consistency and
it's also hard to read (`nullptr, {}, 0` is not very descriptive).
This patch fixes this by letting table gen generate those tables. This way we can have a more readable
syntax for this (especially for all the default arguments) and we can let TableCheck check them
for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.).
Also refactoring the related data structures can now be done without changing the hundred of option initializers.
For example, this line:
```
{LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
```
becomes this:
```
def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">;
```
For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other
option initializers tables in separate patches.
Reviewers: JDevlieghere, davide, sgraenitz
Reviewed By: JDevlieghere
Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64365
llvm-svn: 365908
2019-07-12 15:30:55 +00:00
|
|
|
add_subdirectory(utils/TableGen)
|
2019-07-26 18:14:04 +00:00
|
|
|
|
2013-09-25 10:37:32 +00:00
|
|
|
add_subdirectory(source)
|
|
|
|
add_subdirectory(tools)
|
2019-04-29 16:29:10 +00:00
|
|
|
add_subdirectory(docs)
|
2017-10-06 22:21:36 +00:00
|
|
|
|
2020-08-11 08:43:44 -07:00
|
|
|
if (LLDB_ENABLE_PYTHON)
|
2020-07-29 17:56:38 -07:00
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
|
|
|
|
else()
|
|
|
|
set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
|
|
|
|
endif()
|
2020-08-11 08:43:44 -07:00
|
|
|
get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
|
2020-08-22 11:53:08 -07:00
|
|
|
finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
|
2020-07-29 17:56:38 -07:00
|
|
|
endif()
|
|
|
|
|
2021-10-12 22:08:05 +08:00
|
|
|
if (LLDB_ENABLE_LUA)
|
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
set(lldb_lua_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Lua")
|
|
|
|
else()
|
|
|
|
set(lldb_lua_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_LUA_RELATIVE_PATH}")
|
|
|
|
endif()
|
|
|
|
get_target_property(lldb_lua_bindings_dir swig_wrapper_lua BINARY_DIR)
|
|
|
|
finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
|
|
|
|
endif()
|
|
|
|
|
2022-08-10 16:56:05 -07:00
|
|
|
set(LLDB_INCLUDE_UNITTESTS ON)
|
|
|
|
if (NOT TARGET llvm_gtest)
|
|
|
|
set(LLDB_INCLUDE_UNITTESTS OFF)
|
|
|
|
endif()
|
|
|
|
|
2017-10-06 22:21:36 +00:00
|
|
|
if(LLDB_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(test)
|
2022-08-10 16:56:05 -07:00
|
|
|
if (LLDB_INCLUDE_UNITTESTS)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
endif()
|
2020-01-16 22:30:03 -08:00
|
|
|
add_subdirectory(utils)
|
2017-10-06 22:21:36 +00:00
|
|
|
endif()
|
2015-02-17 22:20:29 +00:00
|
|
|
|
2019-07-18 16:44:45 +00:00
|
|
|
if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
|
2019-07-10 11:09:11 +00:00
|
|
|
llvm_distribution_add_targets()
|
|
|
|
endif()
|