mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 20:29:53 +00:00
[llvm-config] Canonicalize CMake booleans to 0/1
Following the similar change to lit configuration, ensure that all CMake booleans are canonicalized to 0/1 when being passed to llvm-config. This fixes the incorrect interpretation of values when user passes another value than the ON/OFF, and simplifies the code by removing unnecessary string matching. Furthermore, the code for --has-rtti and --has-global-isel has been modified to print consistent values indepdently of the boolean used by passed by the user to CMake. Sadly, the code already implicitly used different values for the two (YES/NO for --has-rtti, ON/OFF for --has-global-isel). Include tests for all booleans and multi-value options in llvm-config. Differential Revision: https://reviews.llvm.org/D28366 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291593 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8548be38d1
commit
71b8698703
28
test/tools/llvm-config/booleans.test
Normal file
28
test/tools/llvm-config/booleans.test
Normal file
@ -0,0 +1,28 @@
|
||||
# Check whether boolean options are consistently normalized to ON/OFF.
|
||||
RUN: llvm-config --assertion-mode 2>&1 | FileCheck --check-prefix=CHECK-ONOFF %s
|
||||
RUN: llvm-config --has-global-isel 2>&1 | FileCheck --check-prefix=CHECK-ONOFF %s
|
||||
CHECK-ONOFF: {{ON|OFF}}
|
||||
CHECK-ONOFF-NOT: error:
|
||||
CHECK-ONOFF-NOT: warning
|
||||
|
||||
# ...or to YES/NO.
|
||||
RUN: llvm-config --has-rtti 2>&1 | FileCheck --check-prefix=CHECK-YESNO %s
|
||||
CHECK-YESNO: {{YES|NO}}
|
||||
CHECK-YESNO-NOT: error:
|
||||
CHECK-YESNO-NOT: warning
|
||||
|
||||
# Also check some other multi-choice options.
|
||||
RUN: llvm-config --build-mode 2>&1 | FileCheck --check-prefix=CHECK-BUILD-MODE %s
|
||||
CHECK-BUILD-MODE: {{[Dd][Ee][Bb][Uu][Gg]|[Rr][Ee][Ll][Ee][Aa][Ss][Ee]|[Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo]|[Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll]}}
|
||||
CHECK-BUILD-MODE-NOT: error:
|
||||
CHECK-BUILD-MODE-NOT: warning
|
||||
|
||||
RUN: llvm-config --build-system 2>&1 | FileCheck --check-prefix=CHECK-BUILD-SYSTEM %s
|
||||
CHECK-BUILD-SYSTEM: cmake
|
||||
CHECK-BUILD-SYSTEM-NOT: error:
|
||||
CHECK-BUILD-SYSTEM-NOT: warning
|
||||
|
||||
RUN: llvm-config --shared-mode 2>&1 | FileCheck --check-prefix=CHECK-SHARED-MODE %s
|
||||
CHECK-SHARED-MODE: {{static|shared}}
|
||||
CHECK-SHARED-MODE-NOT: error:
|
||||
CHECK-SHARED-MODE-NOT: warning
|
@ -27,10 +27,10 @@
|
||||
#define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
|
||||
#define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
|
||||
#define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
|
||||
#define LLVM_HAS_RTTI "@LLVM_HAS_RTTI@"
|
||||
#define LLVM_ENABLE_DYLIB "@LLVM_BUILD_LLVM_DYLIB@"
|
||||
#define LLVM_LINK_DYLIB "@LLVM_LINK_LLVM_DYLIB@"
|
||||
#define LLVM_ENABLE_SHARED "@LLVM_ENABLE_SHARED@"
|
||||
#define LLVM_HAS_RTTI @LLVM_HAS_RTTI@
|
||||
#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_VERSION "@LLVM_DYLIB_VERSION@"
|
||||
#define LLVM_HAS_GLOBAL_ISEL "@LLVM_HAS_GLOBAL_ISEL@"
|
||||
#define LLVM_HAS_GLOBAL_ISEL @LLVM_HAS_GLOBAL_ISEL@
|
||||
|
@ -47,12 +47,13 @@ endif()
|
||||
set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
||||
set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE})
|
||||
set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(LLVM_ENABLE_SHARED ON)
|
||||
else()
|
||||
set(LLVM_ENABLE_SHARED OFF)
|
||||
endif()
|
||||
string(REPLACE ";" " " LLVM_TARGETS_BUILT "${LLVM_TARGETS_TO_BUILD}")
|
||||
llvm_canonicalize_cmake_booleans(
|
||||
LLVM_BUILD_LLVM_DYLIB
|
||||
LLVM_LINK_LLVM_DYLIB
|
||||
LLVM_HAS_RTTI
|
||||
LLVM_HAS_GLOBAL_ISEL
|
||||
BUILD_SHARED_LIBS)
|
||||
configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
|
||||
|
||||
# Set build-time environment(s).
|
||||
|
@ -212,7 +212,7 @@ Options:\n\
|
||||
--assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
|
||||
--build-system Print the build system used to build LLVM (always cmake).\n\
|
||||
--has-rtti Print whether or not LLVM was built with rtti (YES or NO).\n\
|
||||
--has-global-isel Print whether or not LLVM was built with global-isel support (YES or NO).\n\
|
||||
--has-global-isel Print whether or not LLVM was built with global-isel support (ON or OFF).\n\
|
||||
--shared-mode Print how the provided components can be collectively linked (`shared` or `static`).\n\
|
||||
--link-shared Link the components as shared libraries.\n\
|
||||
--link-static Link the component libraries statically.\n\
|
||||
@ -383,10 +383,10 @@ int main(int argc, char **argv) {
|
||||
StaticPrefix = SharedPrefix = "lib";
|
||||
}
|
||||
|
||||
const bool BuiltDyLib = (std::strcmp(LLVM_ENABLE_DYLIB, "ON") == 0);
|
||||
const bool BuiltDyLib = !!LLVM_ENABLE_DYLIB;
|
||||
|
||||
/// CMake style shared libs, ie each component is in a shared library.
|
||||
const bool BuiltSharedLibs = std::strcmp(LLVM_ENABLE_SHARED, "ON") == 0;
|
||||
const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED;
|
||||
|
||||
bool DyLibExists = false;
|
||||
const std::string DyLibName =
|
||||
@ -395,7 +395,7 @@ int main(int argc, char **argv) {
|
||||
// If LLVM_LINK_DYLIB is ON, the single shared library will be returned
|
||||
// for "--libs", etc, if they exist. This behaviour can be overridden with
|
||||
// --link-static or --link-shared.
|
||||
bool LinkDyLib = (std::strcmp(LLVM_LINK_DYLIB, "ON") == 0);
|
||||
bool LinkDyLib = !!LLVM_LINK_DYLIB;
|
||||
|
||||
if (BuiltDyLib) {
|
||||
std::string path((SharedDir + DirSep + DyLibName).str());
|
||||
@ -549,9 +549,9 @@ int main(int argc, char **argv) {
|
||||
} else if (Arg == "--build-system") {
|
||||
OS << LLVM_BUILD_SYSTEM << '\n';
|
||||
} else if (Arg == "--has-rtti") {
|
||||
OS << LLVM_HAS_RTTI << '\n';
|
||||
OS << (LLVM_HAS_RTTI ? "YES" : "NO") << '\n';
|
||||
} else if (Arg == "--has-global-isel") {
|
||||
OS << LLVM_HAS_GLOBAL_ISEL << '\n';
|
||||
OS << (LLVM_HAS_GLOBAL_ISEL ? "ON" : "OFF") << '\n';
|
||||
} else if (Arg == "--shared-mode") {
|
||||
PrintSharedMode = true;
|
||||
} else if (Arg == "--obj-root") {
|
||||
|
Loading…
Reference in New Issue
Block a user