@@ -15,12 +15,16 @@ if (POLICY CMP0051)
15
15
cmake_policy (SET CMP0051 OLD )
16
16
endif ()
17
17
18
+ if (POLICY CMP0056 )
19
+ cmake_policy (SET CMP0056 NEW )
20
+ endif ()
21
+
18
22
if (POLICY CMP0057 )
19
23
cmake_policy (SET CMP0057 NEW )
20
24
endif ()
21
25
22
26
if (NOT DEFINED LLVM_VERSION_MAJOR )
23
- set (LLVM_VERSION_MAJOR 5 )
27
+ set (LLVM_VERSION_MAJOR 6 )
24
28
endif ()
25
29
if (NOT DEFINED LLVM_VERSION_MINOR )
26
30
set (LLVM_VERSION_MINOR 0 )
@@ -44,6 +48,13 @@ if (NOT PACKAGE_VERSION)
44
48
"${LLVM_VERSION_MAJOR} .${LLVM_VERSION_MINOR} .${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX} " )
45
49
endif ()
46
50
51
+ if ((CMAKE_GENERATOR MATCHES "Visual Studio" ) AND (CMAKE_GENERATOR_TOOLSET STREQUAL "" ))
52
+ message (WARNING "Visual Studio generators use the x86 host compiler by "
53
+ "default, even for 64-bit targets. This can result in linker "
54
+ "instability and out of memory errors. To use the 64-bit "
55
+ "host compiler, pass -Thost=x64 on the CMake command line." )
56
+ endif ()
57
+
47
58
project (LLVM
48
59
${cmake_3_0_PROJ_VERSION}
49
60
${cmake_3_0_LANGUAGES}
@@ -87,7 +98,7 @@ if(CMAKE_HOST_APPLE AND APPLE)
87
98
set (LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols" )
88
99
endif ()
89
100
endif ()
90
-
101
+
91
102
foreach (lang ${languages} )
92
103
set (CMAKE_${lang}_CREATE_STATIC_LIBRARY
93
104
"${CMAKE_LIBTOOL} -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> \
@@ -169,11 +180,6 @@ if(LLVM_DEPENDENCY_DEBUGGING)
169
180
endif ()
170
181
endif ()
171
182
172
- option (LLVM_BUILD_GLOBAL_ISEL "Experimental: Build GlobalISel" ON )
173
- if (LLVM_BUILD_GLOBAL_ISEL )
174
- add_definitions (-DLLVM_BUILD_GLOBAL_ISEL )
175
- endif ()
176
-
177
183
option (LLVM_ENABLE_DAGISEL_COV "Debug: Prints tablegen patterns that were used for selecting" OFF )
178
184
179
185
# Add path for custom modules
@@ -199,11 +205,7 @@ endif()
199
205
include (VersionFromVCS )
200
206
201
207
option (LLVM_APPEND_VC_REV
202
- "Append the version control system revision id to LLVM version" OFF )
203
-
204
- if ( LLVM_APPEND_VC_REV )
205
- add_version_info_from_vcs (PACKAGE_VERSION )
206
- endif ()
208
+ "Embed the version control system revision id in LLVM" ON )
207
209
208
210
set (PACKAGE_NAME LLVM )
209
211
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION} " )
@@ -239,11 +241,11 @@ endif()
239
241
include (CPack )
240
242
241
243
# Sanity check our source directory to make sure that we are not trying to
242
- # generate an in-tree build (unless on MSVC_IDE, where it is ok), and to make
244
+ # generate an in-source build (unless on MSVC_IDE, where it is ok), and to make
243
245
# sure that we don't have any stray generated files lying around in the tree
244
246
# (which would end up getting picked up by header search, instead of the correct
245
247
# versions).
246
- if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
248
+ if ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE )
247
249
message (FATAL_ERROR "In-source builds are not allowed.
248
250
CMake would overwrite the makefiles distributed with LLVM.
249
251
Please create a directory and run cmake from there, passing the path
@@ -281,6 +283,10 @@ set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name
281
283
set (LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')" )
282
284
mark_as_advanced (LLVM_TOOLS_INSTALL_DIR )
283
285
286
+ set (LLVM_UTILS_INSTALL_DIR "bin" CACHE STRING
287
+ "Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)" )
288
+ mark_as_advanced (LLVM_TOOLS_INSTALL_DIR )
289
+
284
290
# They are used as destination of target generators.
285
291
set (LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR}/bin )
286
292
set (LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX} )
@@ -303,6 +309,7 @@ set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
303
309
set (LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR} /examples )
304
310
set (LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} /include )
305
311
312
+ # List of all targets to be built by default:
306
313
set (LLVM_ALL_TARGETS
307
314
AArch64
308
315
AMDGPU
@@ -314,7 +321,6 @@ set(LLVM_ALL_TARGETS
314
321
MSP430
315
322
NVPTX
316
323
PowerPC
317
- RISCV
318
324
Sparc
319
325
SystemZ
320
326
X86
@@ -352,6 +358,8 @@ set(LLVM_TARGET_ARCH "host"
352
358
353
359
option (LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON )
354
360
361
+ option (LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON )
362
+
355
363
option (LLVM_ENABLE_LIBEDIT "Use libedit if available." ON )
356
364
357
365
option (LLVM_ENABLE_THREADS "Use threads if available." ON )
@@ -367,8 +375,6 @@ set(LLVM_TARGETS_TO_BUILD
367
375
${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD} )
368
376
list (REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD )
369
377
370
- include (AddLLVMDefinitions )
371
-
372
378
option (LLVM_ENABLE_PIC "Build Position-Independent Code" ON )
373
379
option (LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON )
374
380
option (LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF )
@@ -380,17 +386,24 @@ else()
380
386
option (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON )
381
387
endif ()
382
388
option (LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF )
389
+ option (LLVM_ENABLE_CXX1Z "Compile with C++1z enabled." OFF )
383
390
option (LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF )
384
391
option (LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF )
385
392
option (LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON )
386
393
option (LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF )
387
394
395
+ option (LLVM_ENABLE_DUMP "Enable dump functions in release builds" OFF )
396
+
388
397
if ( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
389
398
option (LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF )
390
399
else ()
391
400
option (LLVM_ENABLE_ASSERTIONS "Enable assertions" ON )
392
401
endif ()
393
402
403
+ if ( LLVM_ENABLE_ASSERTIONS )
404
+ set (LLVM_ENABLE_DUMP ON )
405
+ endif ()
406
+
394
407
option (LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF )
395
408
396
409
set (LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
@@ -426,6 +439,8 @@ endif( LLVM_USE_OPROFILE )
426
439
427
440
set (LLVM_USE_SANITIZER "" CACHE STRING
428
441
"Define the sanitizer used to build binaries and tests." )
442
+ set (LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
443
+ "Path to fuzzing library for linking with fuzz targets" )
429
444
430
445
option (LLVM_USE_SPLIT_DWARF
431
446
"Use -gsplit-dwarf when compiling llvm." OFF )
@@ -485,6 +500,10 @@ option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON)
485
500
option (LLVM_BUILD_UTILS
486
501
"Build LLVM utility binaries. If OFF, just generate build targets." ON )
487
502
503
+ option (LLVM_INCLUDE_RUNTIMES "Generate build targets for the LLVM runtimes." ON )
504
+ option (LLVM_BUILD_RUNTIMES
505
+ "Build the LLVM runtimes. If OFF, just generate build targets." ON )
506
+
488
507
option (LLVM_BUILD_RUNTIME
489
508
"Build the LLVM runtime libraries." ON )
490
509
option (LLVM_BUILD_EXAMPLES
@@ -510,6 +529,9 @@ set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
510
529
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
511
530
"Build compiler-rt as an external project." OFF )
512
531
532
+ option (LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
533
+ "Show target and host info when tools are invoked with --version." ON )
534
+
513
535
# You can configure which libraries from LLVM you want to include in the
514
536
# shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited
515
537
# list of LLVM components. All component names handled by llvm-config are valid.
@@ -525,6 +547,8 @@ if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
525
547
endif ()
526
548
option (LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default} )
527
549
550
+ option (LLVM_DYLIB_SYMBOL_VERSIONING OFF )
551
+
528
552
option (LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF )
529
553
if (CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES )))
530
554
set (LLVM_USE_HOST_TOOLS ON )
@@ -536,25 +560,29 @@ else()
536
560
set (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\ Visual Studio 2013\\ Visualizers" FORCE )
537
561
endif ()
538
562
539
- if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE )
563
+ if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR
564
+ LLVM_ENABLE_IR_PGO )
540
565
if (NOT LLVM_PROFILE_MERGE_POOL_SIZE )
541
566
# A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
542
567
# for spining disks. Anything higher may only help on slower mediums.
543
568
set (LLVM_PROFILE_MERGE_POOL_SIZE "4" )
544
569
endif ()
545
570
if (NOT LLVM_PROFILE_FILE_PATTERN )
546
571
if (NOT LLVM_PROFILE_DATA_DIR )
547
- file (TO_NATIVE_PATH "${LLVM_BINARY_DIR} /profiles/%${LLVM_PROFILE_MERGE_POOL_SIZE} m.profraw" LLVM_PROFILE_FILE_PATTERN )
548
- else ()
549
- file (TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR} /%${LLVM_PROFILE_MERGE_POOL_SIZE} m.profraw" LLVM_PROFILE_FILE_PATTERN )
572
+ file (TO_NATIVE_PATH "${LLVM_BINARY_DIR} /profiles" LLVM_PROFILE_DATA_DIR )
550
573
endif ()
574
+ file (TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR} /%${LLVM_PROFILE_MERGE_POOL_SIZE} m.profraw" LLVM_PROFILE_FILE_PATTERN )
551
575
endif ()
552
576
endif ()
553
577
554
578
if (LLVM_BUILD_STATIC )
555
579
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static" )
556
580
endif ()
557
581
582
+ # Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
583
+ set (LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank." )
584
+ mark_as_advanced (LLVM_TARGET_TRIPLE_ENV )
585
+
558
586
# All options referred to from HandleLLVMOptions have to be specified
559
587
# BEFORE this include, otherwise options will not be correctly set on
560
588
# first cmake run
@@ -620,7 +648,7 @@ endif (LLVM_USE_OPROFILE)
620
648
621
649
message (STATUS "Constructing LLVMBuild project information" )
622
650
execute_process (
623
- COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
651
+ COMMAND ${PYTHON_EXECUTABLE} -B ${LLVMBUILDTOOL}
624
652
--native-target "${LLVM_NATIVE_ARCH} "
625
653
--enable-targets "${LLVM_TARGETS_TO_BUILD} "
626
654
--enable-optional-components "${LLVMOPTIONALCOMPONENTS} "
@@ -773,19 +801,20 @@ if(LLVM_USE_HOST_TOOLS)
773
801
include (CrossCompile )
774
802
endif (LLVM_USE_HOST_TOOLS )
775
803
if (LLVM_TARGET_IS_CROSSCOMPILE_HOST )
776
- # Dummy use to avoid CMake Wraning : Manually-specified variables were not used
804
+ # Dummy use to avoid CMake Warning : Manually-specified variables were not used
777
805
# (this is a variable that CrossCompile sets on recursive invocations)
778
806
endif ()
779
807
780
808
if (${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)" )
781
809
# On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
782
810
# with libxml2, iconv.h, etc., we must add /usr/local paths.
783
- include_directories ("/usr/local/include" )
811
+ include_directories (SYSTEM "/usr/local/include" )
784
812
link_directories ("/usr/local/lib" )
785
813
endif (${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)" )
786
814
787
815
if ( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
788
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h" )
816
+ # special hack for Solaris to handle crazy system sys/regset.h
817
+ include_directories ("${LLVM_MAIN_INCLUDE_DIR} /llvm/Support/Solaris" )
789
818
endif ( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
790
819
791
820
# Make sure we don't get -rdynamic in every binary. For those that need it,
@@ -819,15 +848,6 @@ add_subdirectory(lib/TableGen)
819
848
820
849
add_subdirectory (utils/TableGen )
821
850
822
- # Force target to be built as soon as possible. Clang modules builds depend
823
- # header-wise on it as they ship all headers from the umbrella folders. Building
824
- # an entire module might include header, which depends on intrinsics_gen. This
825
- # should be right after LLVMSupport and LLVMTableGen otherwise we introduce a
826
- # circular dependence.
827
- if (LLVM_ENABLE_MODULES )
828
- list (APPEND LLVM_COMMON_DEPENDS intrinsics_gen )
829
- endif (LLVM_ENABLE_MODULES )
830
-
831
851
add_subdirectory (include /llvm )
832
852
833
853
add_subdirectory (lib )
@@ -837,9 +857,7 @@ if( LLVM_INCLUDE_UTILS )
837
857
add_subdirectory (utils/PerfectShuffle )
838
858
add_subdirectory (utils/count )
839
859
add_subdirectory (utils/not )
840
- add_subdirectory (utils/llvm-lit )
841
860
add_subdirectory (utils/yaml-bench )
842
- add_subdirectory (utils/unittest )
843
861
else ()
844
862
if ( LLVM_INCLUDE_TESTS )
845
863
message (FATAL_ERROR "Including tests when not building utils will not work.
@@ -864,7 +882,9 @@ if( LLVM_INCLUDE_TOOLS )
864
882
add_subdirectory (tools )
865
883
endif ()
866
884
867
- add_subdirectory (runtimes )
885
+ if ( LLVM_INCLUDE_RUNTIMES )
886
+ add_subdirectory (runtimes )
887
+ endif ()
868
888
869
889
if ( LLVM_INCLUDE_EXAMPLES )
870
890
add_subdirectory (examples )
@@ -879,8 +899,13 @@ if( LLVM_INCLUDE_TESTS )
879
899
NO_INSTALL
880
900
ALWAYS_CLEAN )
881
901
endif ()
902
+ add_subdirectory (utils/lit )
882
903
add_subdirectory (test )
883
904
add_subdirectory (unittests )
905
+ if ( LLVM_INCLUDE_UTILS )
906
+ add_subdirectory (utils/unittest )
907
+ endif ()
908
+
884
909
if (WIN32 )
885
910
# This utility is used to prevent crashing tests from calling Dr. Watson on
886
911
# Windows.
@@ -918,6 +943,11 @@ endif()
918
943
919
944
add_subdirectory (cmake/modules )
920
945
946
+ # Do this last so that all lit targets have already been created.
947
+ if (LLVM_INCLUDE_UTILS )
948
+ add_subdirectory (utils/llvm-lit )
949
+ endif ()
950
+
921
951
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY )
922
952
install (DIRECTORY include /llvm include /llvm-c
923
953
DESTINATION include
@@ -971,13 +1001,13 @@ if(LLVM_DISTRIBUTION_COMPONENTS)
971
1001
if (TARGET ${target} )
972
1002
add_dependencies (distribution ${target} )
973
1003
else ()
974
- message (FATAL_ERROR "Specified distribution component '${target} ' doesn't have a target" )
1004
+ message (SEND_ERROR "Specified distribution component '${target} ' doesn't have a target" )
975
1005
endif ()
976
1006
977
1007
if (TARGET install -${target} )
978
1008
add_dependencies (install -distribution install -${target} )
979
1009
else ()
980
- message (FATAL_ERROR "Specified distribution component '${target} ' doesn't have an install target" )
1010
+ message (SEND_ERROR "Specified distribution component '${target} ' doesn't have an install target" )
981
1011
endif ()
982
1012
endforeach ()
983
1013
endif ()
@@ -986,3 +1016,4 @@ endif()
986
1016
if (MSVC )
987
1017
include (InstallRequiredSystemLibraries )
988
1018
endif ()
1019
+
0 commit comments