Vendor import of llvm release_39 branch r276489:

https://llvm.org/svn/llvm-project/llvm/branches/release_39@276489
This commit is contained in:
Dimitry Andric 2016-07-23 20:41:05 +00:00
parent f0f4822ed4
commit 01095a5d43
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/llvm/dist/; revision=303231
svn path=/vendor/llvm/llvm-release_39-r276489/; revision=303232; tag=vendor/llvm/llvm-release_39-r276489
8741 changed files with 672944 additions and 246694 deletions

View File

@ -1,4 +1,4 @@
{
"project_id" : "llvm",
"conduit_uri" : "http://reviews.llvm.org/"
"conduit_uri" : "https://reviews.llvm.org/"
}

View File

@ -1,4 +1,4 @@
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,readability-identifier-naming'
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming'
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase

2
.gitignore vendored
View File

@ -46,6 +46,8 @@ autoconf/autom4te.cache
projects/*
!projects/*.*
!projects/Makefile
runtimes/*
!runtimes/*.*
# Clang, which is tracked independently.
tools/clang
# LLDB, which is tracked independently.

View File

@ -1,10 +1,10 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
cmake_minimum_required(VERSION 2.8.12.2)
cmake_minimum_required(VERSION 3.4.3)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to Debug")
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)")
endif()
if(POLICY CMP0022)
@ -20,17 +20,11 @@ if (POLICY CMP0051)
cmake_policy(SET CMP0051 OLD)
endif()
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
if(NOT DEFINED LLVM_VERSION_MAJOR)
set(LLVM_VERSION_MAJOR 3)
endif()
if(NOT DEFINED LLVM_VERSION_MINOR)
set(LLVM_VERSION_MINOR 8)
set(LLVM_VERSION_MINOR 9)
endif()
if(NOT DEFINED LLVM_VERSION_PATCH)
set(LLVM_VERSION_PATCH 0)
@ -56,23 +50,43 @@ project(LLVM
${cmake_3_0_LANGUAGES}
C CXX ASM)
if(APPLE)
if(NOT CMAKE_LIBTOOL)
find_program(CMAKE_LIBTOOL NAMES libtool)
endif()
if(CMAKE_LIBTOOL)
set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach(lang ${languages})
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
"${CMAKE_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
endforeach()
endif()
endif()
# The following only works with the Ninja generator in CMake >= 3.0.
set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
"Define the maximum number of concurrent compilation jobs.")
if(LLVM_PARALLEL_COMPILE_JOBS)
if(CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later.")
if(NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators.")
else()
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${LLVM_PARALLEL_COMPILE_JOBS})
set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
endif()
endif()
set(LLVM_BUILD_GLOBAL_ISEL OFF CACHE BOOL "Experimental: Build GlobalISel")
if(LLVM_BUILD_GLOBAL_ISEL)
add_definitions(-DLLVM_BUILD_GLOBAL_ISEL)
endif()
set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING
"Define the maximum number of concurrent link jobs.")
if(LLVM_PARALLEL_LINK_JOBS)
if(CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later.")
if(NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators.")
else()
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${LLVM_PARALLEL_LINK_JOBS})
set(CMAKE_JOB_POOL_LINK link_job_pool)
@ -181,6 +195,9 @@ endif()
set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
@ -206,7 +223,6 @@ set(LLVM_ALL_TARGETS
AMDGPU
ARM
BPF
CppBackend
Hexagon
Mips
MSP430
@ -230,11 +246,6 @@ set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
option(BUILD_SHARED_LIBS
"Build all libraries as shared libraries instead of static" OFF)
option(LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON)
if(LLVM_ENABLE_TIMESTAMPS)
set(ENABLE_TIMESTAMPS 1)
endif()
option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON)
if(LLVM_ENABLE_BACKTRACES)
set(ENABLE_BACKTRACES 1)
@ -272,6 +283,13 @@ include(AddLLVMDefinitions)
option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON)
option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." OFF)
else()
option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF)
option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
endif()
option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
option(LLVM_ENABLE_LIBCXXABI "Use libc++abi when using libc++." OFF)
@ -284,6 +302,8 @@ else()
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
endif()
option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
@ -321,8 +341,26 @@ set(LLVM_USE_SANITIZER "" CACHE STRING
option(LLVM_USE_SPLIT_DWARF
"Use -gsplit-dwarf when compiling llvm." OFF)
option(WITH_POLLY "Build LLVM with Polly" ON)
option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" OFF)
option(LLVM_POLLY_LINK_INTO_TOOLS "Statically link Polly into tools (if available)" ON)
option(LLVM_POLLY_BUILD "Build LLVM with Polly" ON)
if (EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
set(POLLY_IN_TREE TRUE)
else()
set(POLLY_IN_TREE FALSE)
endif()
if (LLVM_POLLY_BUILD AND POLLY_IN_TREE)
set(WITH_POLLY ON)
else()
set(WITH_POLLY OFF)
endif()
if (LLVM_POLLY_LINK_INTO_TOOLS AND WITH_POLLY)
set(LINK_POLLY_INTO_TOOLS ON)
else()
set(LINK_POLLY_INTO_TOOLS OFF)
endif()
# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
@ -353,6 +391,8 @@ option(LLVM_BUILD_TOOLS
"Build the LLVM tools. If OFF, just generate build targets." ON)
option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON)
option(LLVM_BUILD_UTILS
"Build LLVM utility binaries. If OFF, just generate build targets." ON)
option(LLVM_BUILD_RUNTIME
"Build the LLVM runtime libraries." ON)
@ -387,25 +427,42 @@ if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default})
set(LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT ON)
if (LLVM_LINK_LLVM_DYLIB)
set(LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT OFF)
endif()
option(LLVM_DISABLE_LLVM_DYLIB_ATEXIT "Disable llvm-shlib's atexit destructors." ${LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT})
if(LLVM_DISABLE_LLVM_DYLIB_ATEXIT)
set(DISABLE_LLVM_DYLIB_ATEXIT 1)
endif()
option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF)
if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND LLVM_ENABLE_ASSERTIONS))
set(LLVM_USE_HOST_TOOLS ON)
endif()
if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
else()
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)
endif()
if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE)
if(NOT LLVM_PROFILE_MERGE_POOL_SIZE)
# A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
# for spining disks. Anything higher may only help on slower mediums.
set(LLVM_PROFILE_MERGE_POOL_SIZE "4")
endif()
if(NOT LLVM_PROFILE_FILE_PATTERN)
if(NOT LLVM_PROFILE_DATA_DIR)
set(LLVM_PROFILE_FILE_PATTERN "%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw")
else()
file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)
endif()
endif()
endif()
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
include(config-ix)
string(REPLACE "Native" ${LLVM_NATIVE_ARCH}
LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD}")
list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
# By default, we target the host, but this can be overridden at CMake
# invocation time.
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
@ -645,6 +702,15 @@ add_subdirectory(lib/TableGen)
add_subdirectory(utils/TableGen)
# Force target to be built as soon as possible. Clang modules builds depend
# header-wise on it as they ship all headers from the umbrella folders. Building
# an entire module might include header, which depends on intrinsics_gen. This
# should be right after LLVMSupport and LLVMTableGen otherwise we introduce a
# circular dependence.
if (LLVM_ENABLE_MODULES)
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
endif(LLVM_ENABLE_MODULES)
add_subdirectory(include/llvm)
add_subdirectory(lib)
@ -663,6 +729,11 @@ else()
endif()
endif()
# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
add_subdirectory(utils/LLVMVisualizers)
endif()
if(LLVM_INCLUDE_TESTS)
add_subdirectory(utils/unittest)
endif()
@ -675,16 +746,12 @@ endforeach()
add_subdirectory(projects)
if(WITH_POLLY)
if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
set(WITH_POLLY OFF)
endif()
endif(WITH_POLLY)
if( LLVM_INCLUDE_TOOLS )
add_subdirectory(tools)
endif()
add_subdirectory(runtimes)
if( LLVM_INCLUDE_EXAMPLES )
add_subdirectory(examples)
endif()
@ -695,7 +762,8 @@ if( LLVM_INCLUDE_TESTS )
llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite
USE_TOOLCHAIN
EXCLUDE_FROM_ALL
NO_INSTALL)
NO_INSTALL
ALWAYS_CLEAN)
endif()
add_subdirectory(test)
add_subdirectory(unittests)
@ -718,6 +786,8 @@ if( LLVM_INCLUDE_TESTS )
DEPENDS ${LLVM_LIT_DEPENDS}
ARGS ${LLVM_LIT_EXTRA_ARGS}
)
add_custom_target(test-depends DEPENDS ${LLVM_LIT_DEPENDS})
set_target_properties(test-depends PROPERTIES FOLDER "Tests")
endif()
if (LLVM_INCLUDE_DOCS)
@ -761,3 +831,27 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endif()
# This must be at the end of the LLVM root CMakeLists file because it must run
# after all targets are created.
if(LLVM_DISTRIBUTION_COMPONENTS)
if(CMAKE_CONFIGURATION_TYPES)
message(FATAL_ERROR "LLVM_DISTRIBUTION_COMPONENTS cannot be specified with multi-configuration generators (i.e. Xcode or Visual Studio)")
endif()
add_custom_target(distribution)
add_custom_target(install-distribution)
foreach(target ${LLVM_DISTRIBUTION_COMPONENTS})
if(TARGET ${target})
add_dependencies(distribution ${target})
else()
message(FATAL_ERROR "Specified distribution component '${target}' doesn't have a target")
endif()
if(TARGET install-${target})
add_dependencies(install-distribution install-${target})
else()
message(FATAL_ERROR "Specified distribution component '${target}' doesn't have an install target")
endif()
endforeach()
endif()

View File

@ -12,17 +12,10 @@ N: Joe Abbey
E: jabbey@arxan.com
D: LLVM Bitcode (lib/Bitcode/* include/llvm/Bitcode/*)
N: Owen Anderson
E: resistor@mac.com
D: SelectionDAG (lib/CodeGen/SelectionDAG/*)
N: Rafael Avila de Espindola
E: rafael.espindola@gmail.com
D: Gold plugin (tools/gold/*)
N: Justin Bogner
E: mail@justinbogner.com
D: InstrProfiling and related parts of ProfileData
D: SelectionDAG (lib/CodeGen/SelectionDAG/*)
N: Chandler Carruth
E: chandlerc@gmail.com
@ -35,12 +28,16 @@ D: parts of code generator not covered by someone else
N: Eric Christopher
E: echristo@gmail.com
D: Debug Information, autotools/configure/make build, inline assembly
D: Debug Information, inline assembly
N: Greg Clayton
E: gclayton@apple.com
D: LLDB
N: Sanjoy Das
E: sanjoy@playingwithpointers.com
D: IndVar Simplify, Scalar Evolution
N: Marshall Clow
E: mclow.lists@gmail.com
D: libc++
@ -87,7 +84,11 @@ D: NVPTX Target (lib/Target/NVPTX/*)
N: Lang Hames
E: lhames@gmail.com
D: MCJIT, RuntimeDyld and JIT event listeners
D: MCJIT, RuntimeDyld and JIT event listeners, Orcish Warchief
N: Teresa Johnson
E: tejohnson@google.com
D: Gold plugin (tools/gold/*)
N: Galina Kistanova
E: gkistanova@gmail.com
@ -138,6 +139,10 @@ N: Krzysztof Parzyszek
E: kparzysz@codeaurora.org
D: Hexagon Backend
N: Jacques Pienaar
E: jpienaar@google.com
D: Lanai Backend
N: Paul Robinson
E: paul_robinson@playstation.sony.com
D: Sony PlayStation®4 support
@ -147,7 +152,7 @@ E: mcrosier@codeaurora.org
D: Fast-Isel
N: Nadav Rotem
E: nrotem@apple.com
E: nadav.rotem@me.com
D: X86 Backend, Loop Vectorizer
N: Daniel Sanders
@ -181,7 +186,7 @@ D: MemorySanitizer (LLVM part)
N: Andrew Trick
E: atrick@apple.com
D: IndVar Simplify, Loop Strength Reduction, Instruction Scheduling
D: Loop Strength Reduction, Instruction Scheduling
N: Ulrich Weigand
E: uweigand@de.ibm.com
@ -191,6 +196,10 @@ N: Bill Wendling
E: isanbard@gmail.com
D: libLTO, IR Linker
N: Hans Wennborg
E: hans@chromium.org
D: Release management (x.y.0 releases)
N: Peter Zotov
E: whitequark@whitequark.org
D: OCaml bindings

View File

@ -347,6 +347,10 @@ N: Richard Osborne
E: richard@xmos.com
D: XCore backend
N: Piotr Padlewski
E: piotr.padlewski@gmail.com
D: !invariant.group metadata and other intrinsics for devirtualization in clang
N: Devang Patel
E: dpatel@apple.com
D: LTO tool, PassManager rewrite, Loop Pass Manager, Loop Rotate
@ -392,7 +396,7 @@ D: Fixes and improvements to the ARM fast-isel pass
D: Fixes and improvements to the AArch64 backend
N: Nadav Rotem
E: nrotem@apple.com
E: nadav.rotem@me.com
D: X86 code generation improvements, Loop Vectorizer.
N: Roman Samoilov

View File

@ -4,7 +4,7 @@ LLVM Release License
University of Illinois/NCSA
Open Source License
Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign.
Copyright (c) 2003-2016 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:

295
Makefile
View File

@ -1,295 +0,0 @@
#===- ./Makefile -------------------------------------------*- Makefile -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
LEVEL := .
# Top-Level LLVM Build Stages:
# 1. Build lib/Support and lib/TableGen, which are used by utils (tblgen).
# 2. Build utils, which is used by IR.
# 3. Build IR, which builds the Intrinsics.inc file used by libs.
# 4. Build libs, which are needed by llvm-config.
# 5. Build llvm-config, which determines inter-lib dependencies for tools.
# 6. Build tools, docs, and cmake modules.
#
# When cross-compiling, there are some things (tablegen) that need to
# be build for the build system first.
# If "RC_ProjectName" exists in the environment, and its value is
# "llvmCore", then this is an "Apple-style" build; search for
# "Apple-style" in the comments for more info. Anything else is a
# normal build.
ifneq ($(findstring llvmCore, $(RC_ProjectName)),llvmCore) # Normal build (not "Apple-style").
ifeq ($(BUILD_DIRS_ONLY),1)
DIRS := lib/Support lib/TableGen utils tools/llvm-config
OPTIONAL_DIRS := tools/clang/utils/TableGen
else
DIRS := lib/Support lib/TableGen utils lib/IR lib tools/llvm-shlib \
tools/llvm-config tools docs cmake unittests
OPTIONAL_DIRS := projects bindings
endif
ifeq ($(BUILD_EXAMPLES),1)
OPTIONAL_DIRS += examples
endif
EXTRA_DIST := test unittests llvm.spec include win32 Xcode
include $(LEVEL)/Makefile.config
ifneq ($(ENABLE_SHARED),1)
DIRS := $(filter-out tools/llvm-shlib, $(DIRS))
endif
ifneq ($(ENABLE_DOCS),1)
DIRS := $(filter-out docs, $(DIRS))
endif
ifeq ($(MAKECMDGOALS),libs-only)
DIRS := $(filter-out tools docs, $(DIRS))
OPTIONAL_DIRS :=
endif
ifeq ($(MAKECMDGOALS),install-libs)
DIRS := $(filter-out tools docs, $(DIRS))
OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
endif
ifeq ($(MAKECMDGOALS),tools-only)
DIRS := $(filter-out docs, $(DIRS))
OPTIONAL_DIRS :=
endif
ifeq ($(MAKECMDGOALS),install-clang)
DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
tools/clang/tools/libclang \
tools/clang/tools/c-index-test \
tools/clang/include/clang-c \
tools/clang/runtime tools/clang/docs \
tools/lto
OPTIONAL_DIRS :=
NO_INSTALL = 1
endif
ifeq ($(MAKECMDGOALS),clang-only)
DIRS := $(filter-out tools docs unittests, $(DIRS)) \
tools/clang tools/lto
OPTIONAL_DIRS :=
endif
ifeq ($(MAKECMDGOALS),unittests)
DIRS := $(filter-out tools docs, $(DIRS)) utils unittests
OPTIONAL_DIRS :=
endif
# Use NO_INSTALL define of the Makefile of each directory for deciding
# if the directory is installed or not
ifeq ($(MAKECMDGOALS),install)
OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
endif
# Don't build unittests when ONLY_TOOLS is set.
ifneq ($(ONLY_TOOLS),)
DIRS := $(filter-out unittests, $(DIRS))
endif
# If we're cross-compiling, build the build-hosted tools first
ifeq ($(LLVM_CROSS_COMPILING),1)
all:: cross-compile-build-tools
clean::
$(Verb) rm -rf BuildTools
cross-compile-build-tools:
$(Verb) if [ ! -f BuildTools/Makefile ]; then \
$(MKDIR) BuildTools; \
cd BuildTools ; \
unset CFLAGS ; \
unset CXXFLAGS ; \
AR=$(BUILD_AR) ; \
AS=$(BUILD_AS) ; \
LD=$(BUILD_LD) ; \
CC=$(BUILD_CC) ; \
CXX=$(BUILD_CXX) ; \
unset SDKROOT ; \
unset UNIVERSAL_SDK_PATH ; \
configure_opts= ; \
if test "$(ENABLE_LIBCPP)" -ne 0 ; then \
configure_opts="$$configure_opts --enable-libcpp"; \
fi; \
$(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
--host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE) \
--disable-polly $$configure_opts; \
cd .. ; \
fi; \
($(MAKE) -C BuildTools \
BUILD_DIRS_ONLY=1 \
UNIVERSAL= \
UNIVERSAL_SDK_PATH= \
SDKROOT= \
TARGET_NATIVE_ARCH="$(TARGET_NATIVE_ARCH)" \
TARGETS_TO_BUILD="$(TARGETS_TO_BUILD)" \
TARGET_LIBS="$(LIBS)" \
ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
ENABLE_PROFILING=$(ENABLE_PROFILING) \
ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
ENABLE_LIBCPP=$(ENABLE_LIBCPP) \
CFLAGS= \
CXXFLAGS= \
) || exit 1;
endif
# Include the main makefile machinery.
include $(LLVM_SRC_ROOT)/Makefile.rules
# Specify options to pass to configure script when we're
# running the dist-check target
DIST_CHECK_CONFIG_OPTIONS = --with-llvmgccdir=$(LLVMGCCDIR)
.PHONY: debug-opt-prof
debug-opt-prof:
$(Echo) Building Debug Version
$(Verb) $(MAKE)
$(Echo)
$(Echo) Building Optimized Version
$(Echo)
$(Verb) $(MAKE) ENABLE_OPTIMIZED=1
$(Echo)
$(Echo) Building Profiling Version
$(Echo)
$(Verb) $(MAKE) ENABLE_PROFILING=1
dist-hook::
$(Echo) Eliminating files constructed by configure
$(Verb) $(RM) -f \
$(TopDistDir)/include/llvm/Config/config.h \
$(TopDistDir)/include/llvm/Support/DataTypes.h
clang-only: all
tools-only: all
libs-only: all
install-clang: install
install-libs: install
# If SHOW_DIAGNOSTICS is enabled, clear the diagnostics file first.
ifeq ($(SHOW_DIAGNOSTICS),1)
clean-diagnostics:
$(Verb) rm -f $(LLVM_OBJ_ROOT)/$(BuildMode)/diags
.PHONY: clean-diagnostics
all-local:: clean-diagnostics
endif
#------------------------------------------------------------------------
# Make sure the generated files are up-to-date. This must be kept in
# sync with the AC_CONFIG_HEADER and AC_CONFIG_FILE invocations in
# autoconf/configure.ac.
# Note that Makefile.config is covered by its own separate rule
# in Makefile.rules where it can be reused by sub-projects.
#------------------------------------------------------------------------
FilesToConfig := \
bindings/ocaml/llvm/META.llvm \
docs/doxygen.cfg \
llvm.spec \
include/llvm/Config/config.h \
include/llvm/Config/llvm-config.h \
include/llvm/Config/Targets.def \
include/llvm/Config/AsmPrinters.def \
include/llvm/Config/AsmParsers.def \
include/llvm/Config/Disassemblers.def \
include/llvm/Support/DataTypes.h
FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
all-local:: $(FilesToConfigPATH)
$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in
$(Echo) Regenerating $*
$(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
.PRECIOUS: $(FilesToConfigPATH)
# NOTE: This needs to remain as the last target definition in this file so
# that it gets executed last.
ifneq ($(BUILD_DIRS_ONLY),1)
all::
$(Echo) '*****' Completed $(BuildMode) Build
ifneq ($(ENABLE_OPTIMIZED),1)
$(Echo) '*****' Note: Debug build can be 10 times slower than an
$(Echo) '*****' optimized build. Use 'make ENABLE_OPTIMIZED=1' to
$(Echo) '*****' make an optimized build. Alternatively you can
$(Echo) '*****' configure with --enable-optimized.
ifeq ($(SHOW_DIAGNOSTICS),1)
$(Verb) if test -s $(LLVM_OBJ_ROOT)/$(BuildMode)/diags; then \
$(LLVM_SRC_ROOT)/utils/clang-parse-diagnostics-file -a \
$(LLVM_OBJ_ROOT)/$(BuildMode)/diags; \
fi
endif
endif
endif
check-llvm2cpp:
$(Verb)$(MAKE) check TESTSUITE=Feature RUNLLVM2CPP=1
srpm: $(LLVM_OBJ_ROOT)/llvm.spec
rpmbuild -bs $(LLVM_OBJ_ROOT)/llvm.spec
rpm: $(LLVM_OBJ_ROOT)/llvm.spec
rpmbuild -bb --target $(TARGET_TRIPLE) $(LLVM_OBJ_ROOT)/llvm.spec
show-footprint:
$(Verb) du -sk $(LibDir)
$(Verb) du -sk $(ToolDir)
$(Verb) du -sk $(ExmplDir)
$(Verb) du -sk $(ObjDir)
build-for-llvm-top:
$(Verb) if test ! -f ./config.status ; then \
./configure --prefix="$(LLVM_TOP)/install" \
--with-llvm-gcc="$(LLVM_TOP)/llvm-gcc" ; \
fi
$(Verb) $(MAKE) tools-only
SVN = svn
SVN-UPDATE-OPTIONS =
AWK = awk
# Multiline variable defining a recursive function for finding svn repos rooted at
# a given path. svnup() requires one argument: the root to search from.
define SUB_SVN_DIRS
svnup() {
dirs=`svn status --no-ignore $$1 | awk '/^(I|\?) / {print $$2}' | LC_ALL=C xargs svn info 2>/dev/null | awk '/^Path:\ / {print $$2}'`;
if [ "$$dirs" = "" ]; then
return;
fi;
for f in $$dirs; do
echo $$f;
svnup $$f;
done
}
endef
export SUB_SVN_DIRS
update:
$(SVN) $(SVN-UPDATE-OPTIONS) update $(LLVM_SRC_ROOT)
@eval $$SUB_SVN_DIRS; $(SVN) status --no-ignore $(LLVM_SRC_ROOT) | svnup $(LLVM_SRC_ROOT) | xargs $(SVN) $(SVN-UPDATE-OPTIONS) update
happiness: update all check-all
.PHONY: srpm rpm update happiness
# declare all targets at this level to be serial:
.NOTPARALLEL:
else # Building "Apple-style."
# In an Apple-style build, once configuration is done, lines marked
# "Apple-style" are removed with sed! Please don't remove these!
# Look for the string "Apple-style" in utils/buildit/build_llvm.
include $(shell find . -name GNUmakefile) # Building "Apple-style."
endif # Building "Apple-style."

View File

@ -1,69 +0,0 @@
#===-- Makefile.common - Common make rules for LLVM --------*- Makefile -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
#
# This file is included by all of the LLVM makefiles. This file defines common
# rules to do things like compile a .cpp file or generate dependency info.
# These are platform dependent, so this is the file used to specify these
# system dependent operations.
#
# The following functionality can be set by setting incoming variables.
# The variable $(LEVEL) *must* be set:
#
# 1. LEVEL - The level of the current subdirectory from the top of the
# source directory. This level should be expressed as a path, for
# example, ../.. for two levels deep.
#
# 2. DIRS - A list of subdirectories to be built. Fake targets are set up
# so that each of the targets "all", "install", and "clean" each build
# the subdirectories before the local target. DIRS are guaranteed to be
# built in order.
#
# 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be
# built in any order. All DIRS are built in order before PARALLEL_DIRS are
# built, which are then built in any order.
#
# 4. SOURCES - If specified, this sets the source code filenames. If this
# is not set, it defaults to be all of the .cpp, .c, .y, and .l files
# in the current directory.
#
# 5. SourceDir - If specified, this specifies a directory that the source files
# are in, if they are not in the current directory. This should include a
# trailing / character.
#
# 6. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree.
#
# 8. PROJ_SRC_DIR - The directory which contains the current set of Makefiles
# and usually the source code too (unless SourceDir is set).
#
# 9. PROJ_SRC_ROOT - The root directory of the source code being compiled.
#
# 10. PROJ_OBJ_DIR - The directory where object code should be placed.
#
# 11. PROJ_OBJ_ROOT - The root directory for where object code should be
# placed.
#
# For building,
# LLVM, LLVM_SRC_ROOT = PROJ_SRC_ROOT
#
#===-----------------------------------------------------------------------====
#
# Configuration file to set paths specific to local installation of LLVM
#
ifndef LLVM_OBJ_ROOT
include $(LEVEL)/Makefile.config
else
include $(LLVM_OBJ_ROOT)/Makefile.config
endif
#
# Include all of the build rules used for making LLVM
#
include $(LLVM_SRC_ROOT)/Makefile.rules

View File

@ -1,435 +0,0 @@
#===-- Makefile.config - Local configuration for LLVM ------*- Makefile -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
#
# This file is included by Makefile.common. It defines paths and other
# values specific to a particular installation of LLVM.
#
#===------------------------------------------------------------------------===#
# Define LLVM specific info and directories based on the autoconf variables
LLVMPackageName := @PACKAGE_TARNAME@
LLVMVersion := @PACKAGE_VERSION@
LLVM_VERSION_MAJOR := @LLVM_VERSION_MAJOR@
LLVM_VERSION_MINOR := @LLVM_VERSION_MINOR@
LLVM_VERSION_PATCH := @LLVM_VERSION_PATCH@
LLVM_VERSION_SUFFIX := @LLVM_VERSION_SUFFIX@
LLVM_CONFIGTIME := @LLVM_CONFIGTIME@
###########################################################################
# Directory Configuration
# This section of the Makefile determines what is where. To be
# specific, there are several locations that need to be defined:
#
# o LLVM_SRC_ROOT : The root directory of the LLVM source code.
# o LLVM_OBJ_ROOT : The root directory containing the built LLVM code.
#
# o PROJ_SRC_DIR : The directory containing the code to build.
# o PROJ_SRC_ROOT : The root directory of the code to build.
#
# o PROJ_OBJ_DIR : The directory in which compiled code will be placed.
# o PROJ_OBJ_ROOT : The root directory in which compiled code is placed.
#
###########################################################################
PWD := @BINPWD@
# Set the project name to LLVM if its not defined
ifndef PROJECT_NAME
PROJECT_NAME := $(LLVMPackageName)
endif
# The macro below is expanded when 'realpath' is not built-in.
# Built-in 'realpath' is available on GNU Make 3.81.
realpath = $(shell cd $(1); $(PWD))
PROJ_OBJ_DIR := $(call realpath, .)
PROJ_OBJ_ROOT := $(call realpath, $(PROJ_OBJ_DIR)/$(LEVEL))
CLANG_SRC_ROOT := @CLANG_SRC_ROOT@
ifeq ($(PROJECT_NAME),$(LLVMPackageName))
LLVM_SRC_ROOT := $(call realpath, @abs_top_srcdir@)
LLVM_OBJ_ROOT := $(call realpath, @abs_top_builddir@)
PROJ_SRC_ROOT := $(LLVM_SRC_ROOT)
PROJ_SRC_DIR := $(LLVM_SRC_ROOT)$(patsubst $(PROJ_OBJ_ROOT)%,%,$(PROJ_OBJ_DIR))
# See: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150323/268067.html
ifeq ($(LLVM_SRC_ROOT), $(LLVM_OBJ_ROOT))
$(error In-source builds are not allowed. Please configure from a separate build directory!)
endif
ifneq ($(CLANG_SRC_ROOT),)
CLANG_SRC_ROOT:= $(call realpath, $(CLANG_SRC_ROOT))
PROJ_SRC_DIR := $(patsubst $(LLVM_SRC_ROOT)/tools/clang%,$(CLANG_SRC_ROOT)%,$(PROJ_SRC_DIR))
endif
prefix := @prefix@
PROJ_prefix := $(prefix)
program_prefix := @program_prefix@
PROJ_VERSION := $(LLVMVersion)
else
ifndef PROJ_SRC_ROOT
$(error Projects must define PROJ_SRC_ROOT)
endif
ifndef PROJ_OBJ_ROOT
$(error Projects must define PROJ_OBJ_ROOT)
endif
ifndef PROJ_INSTALL_ROOT
$(error Projects must define PROJ_INSTALL_ROOT)
endif
ifndef LLVM_SRC_ROOT
$(error Projects must define LLVM_SRC_ROOT)
endif
ifndef LLVM_OBJ_ROOT
$(error Projects must define LLVM_OBJ_ROOT)
endif
PROJ_SRC_DIR := $(call realpath, $(PROJ_SRC_ROOT)/$(patsubst $(PROJ_OBJ_ROOT)%,%,$(PROJ_OBJ_DIR)))
prefix := $(PROJ_INSTALL_ROOT)
PROJ_prefix := $(prefix)
ifndef PROJ_VERSION
PROJ_VERSION := 1.0
endif
endif
INTERNAL_PREFIX := @INTERNAL_PREFIX@
ifneq ($(INTERNAL_PREFIX),)
PROJ_internal_prefix := $(INTERNAL_PREFIX)
else
PROJ_internal_prefix := $(prefix)
endif
PROJ_bindir := $(PROJ_prefix)/bin
PROJ_libdir := $(PROJ_prefix)/lib
PROJ_datadir := $(PROJ_prefix)/share
PROJ_docsdir := $(PROJ_prefix)/docs/llvm
PROJ_etcdir := $(PROJ_prefix)/etc/llvm
PROJ_includedir := $(PROJ_prefix)/include
PROJ_infodir := $(PROJ_prefix)/info
PROJ_mandir := $(PROJ_prefix)/share/man
# Determine if we're on a unix type operating system
LLVM_ON_UNIX:=@LLVM_ON_UNIX@
LLVM_ON_WIN32:=@LLVM_ON_WIN32@
# Host operating system for which LLVM will be run.
OS=@OS@
HOST_OS=@HOST_OS@
# Target operating system for which LLVM will compile for.
TARGET_OS=@TARGET_OS@
# Host hardware architecture
HOST_ARCH=@HOST_ARCH@
# Target hardware architecture
ARCH=@ARCH@
TARGET_NATIVE_ARCH := $(ARCH)
LLVM_NATIVE_ARCH := @LLVM_NATIVE_ARCH@
# Indicates, whether we're cross-compiling LLVM or not
LLVM_CROSS_COMPILING=@LLVM_CROSS_COMPILING@
# Executable file extension for build platform (mainly for
# tablegen call if we're cross-compiling).
BUILD_EXEEXT=@BUILD_EXEEXT@
# Compilers for the build platflorm (mainly for tablegen
# call if we're cross-compiling).
BUILD_CC=@BUILD_CC@
BUILD_CXX=@BUILD_CXX@
# Triple for configuring build tools when cross-compiling
BUILD_TRIPLE=@build@
# Target triple (cpu-vendor-os) which LLVM is compiled for
HOST_TRIPLE=@host@
# Target triple (cpu-vendor-os) for which we should generate code
TARGET_TRIPLE=@target@
# Extra options to compile LLVM with
EXTRA_OPTIONS=@EXTRA_OPTIONS@
# Extra options to link LLVM with
EXTRA_LD_OPTIONS=@EXTRA_LD_OPTIONS@
# Endian-ness of the target
ENDIAN=@ENDIAN@
# Path to the C++ compiler to use. This is an optional setting, which defaults
# to whatever your gmake defaults to.
CXX = @CXX@
# Path to the CC binary, which use used by testcases for native builds.
CC := @CC@
# C/C++ preprocessor flags.
CPPFLAGS += @CPPFLAGS@
# C compiler flags.
CFLAGS += @CFLAGS@
# C++ compiler flags.
CXXFLAGS += @CXXFLAGS@
# Linker flags.
LDFLAGS += @LDFLAGS@
# Path to the library archiver program.
AR_PATH = @AR@
AR = @AR@
# Path to the nm program
NM_PATH = @NM@
# The pathnames of the programs we require to build
CMP := @CMP@
CP := @CP@
DATE := @DATE@
FIND := @FIND@
GREP := @GREP@
INSTALL := @INSTALL@
MKDIR := $(LLVM_SRC_ROOT)/autoconf/mkinstalldirs
MV := @MV@
RANLIB := @RANLIB@
RM := @RM@
SED := @SED@
TAR := @TAR@
PYTHON := @PYTHON@
# Paths to miscellaneous programs we hope are present but might not be
BZIP2 := @BZIP2@
CAT := @CAT@
DOT := @DOT@
DOXYGEN := @DOXYGEN@
GROFF := @GROFF@
GZIPBIN := @GZIPBIN@
GO := @GO@
OCAMLFIND := @OCAMLFIND@
GAS := @GAS@
POD2HTML := @POD2HTML@
POD2MAN := @POD2MAN@
PDFROFF := @PDFROFF@
ZIP := @ZIP@
HAVE_LIBZ := @HAVE_LIBZ@
HAVE_DLOPEN := @HAVE_DLOPEN@
HAVE_PTHREAD := @HAVE_PTHREAD@
HAVE_TERMINFO := @HAVE_TERMINFO@
HAVE_OCAMLOPT := @HAVE_OCAMLOPT@
HAVE_OCAML_OUNIT := @HAVE_OCAML_OUNIT@
LIBS := @LIBS@
# Targets that are possible to build
ALL_TARGETS := @ALL_TARGETS@
# Targets that we should build
TARGETS_TO_BUILD=@TARGETS_TO_BUILD@
# Targets supporting JIT
TARGETS_WITH_JIT := @TARGETS_WITH_JIT@
# Path to directory where object files should be stored during a build.
# Set OBJ_ROOT to "." if you do not want to use a separate place for
# object files.
OBJ_ROOT := .
# What to pass as rpath flag to g++
RPATH := @RPATH@
# What to pass as -rdynamic flag to g++
RDYNAMIC := @RDYNAMIC@
# These are options that can either be enabled here, or can be enabled on the
# make command line (ie, make ENABLE_PROFILING=1):
# When ENABLE_LIBCPP is enabled, LLVM uses libc++ by default to build.
#ENABLE_LIBCPP = 0
ENABLE_LIBCPP = @ENABLE_LIBCPP@
# When ENABLE_CXX1Y is enabled, LLVM uses c++1y mode by default to build.
# Otherwise it uses the baseline c++11.
ENABLE_CXX1Y = @ENABLE_CXX1Y@
# When ENABLE_SPLIT_DWARF is enabled, LLVM uses -gfission to build in debug mode.
ENABLE_SPLIT_DWARF = @ENABLE_SPLIT_DWARF@
# When enabled, clang will have plugin support.
CLANG_PLUGIN_SUPPORT = @CLANG_PLUGIN_SUPPORT@
# When ENABLE_CLANG_ARCMT is enabled, clang will have ARCMigrationTool.
ENABLE_CLANG_ARCMT = @ENABLE_CLANG_ARCMT@
# When ENABLE_CLANG_STATIC_ANALYZER is enabled, clang will have StaticAnalyzer.
ENABLE_CLANG_STATIC_ANALYZER = @ENABLE_CLANG_STATIC_ANALYZER@
# When ENABLE_WERROR is enabled, we'll pass -Werror on the command line
ENABLE_WERROR = @ENABLE_WERROR@
# When ENABLE_TERMINFO is enabled, we use terminfo.
ENABLE_TERMINFO = @ENABLE_TERMINFO@
# When ENABLE_OPTIMIZED is enabled, LLVM code is optimized and output is put
# into the "Release" directories. Otherwise, LLVM code is not optimized and
# output is put in the "Debug" directories.
#ENABLE_OPTIMIZED = 1
@ENABLE_OPTIMIZED@
# When ENABLE_PROFILING is enabled, profile instrumentation is done
# and output is put into the "<Flavor>+Profile" directories, where
# <Flavor> is either Debug or Release depending on how other build
# flags are set. Otherwise, output is put in the <Flavor>
# directories.
#ENABLE_PROFILING = 1
@ENABLE_PROFILING@
# When DISABLE_ASSERTIONS is enabled, builds of all of the LLVM code will
# exclude assertion checks, otherwise they are included.
#DISABLE_ASSERTIONS = 1
@DISABLE_ASSERTIONS@
# When ENABLE_EXPENSIVE_CHECKS is enabled, builds of all of the LLVM
# code will include expensive checks, otherwise they are excluded.
#ENABLE_EXPENSIVE_CHECKS = 0
@ENABLE_EXPENSIVE_CHECKS@
# --enable-abi-breaking-checks : decide whether we should compile in asserts and
# checks that make the build ABI incompatible with an llvm built without these
# checks enabled.
ENABLE_ABI_BREAKING_CHECKS = @ENABLE_ABI_BREAKING_CHECKS@
# When DEBUG_RUNTIME is enabled, the runtime libraries will retain debug
# symbols.
#DEBUG_RUNTIME = 1
@DEBUG_RUNTIME@
# When DEBUG_SYMBOLS is enabled, the compiler libraries will retain debug
# symbols.
#DEBUG_SYMBOLS = 1
@DEBUG_SYMBOLS@
# When KEEP_SYMBOLS is enabled, installed executables will never have their
# symbols stripped.
#KEEP_SYMBOLS = 1
@KEEP_SYMBOLS@
# The compiler flags to use for optimized builds.
OPTIMIZE_OPTION := @OPTIMIZE_OPTION@
# When ENABLE_PROFILING is enabled, the llvm source base is built with profile
# information to allow gprof to be used to get execution frequencies.
#ENABLE_PROFILING = 1
# When ENABLE_DOCS is disabled, docs/ will not be built.
ENABLE_DOCS = @ENABLE_DOCS@
# When ENABLE_DOXYGEN is enabled, the doxygen documentation will be built
ENABLE_DOXYGEN = @ENABLE_DOXYGEN@
# Do we want to enable threads?
ENABLE_THREADS := @LLVM_ENABLE_THREADS@
# Do we want to enable zlib?
ENABLE_ZLIB := @LLVM_ENABLE_ZLIB@
# Do we want to build with position independent code?
ENABLE_PIC := @ENABLE_PIC@
# Do we want to build a shared library and link the tools with it?
ENABLE_SHARED := @ENABLE_SHARED@
# Do we want to link the stdc++ into a shared library? (Cygming)
ENABLE_EMBED_STDCXX := @ENABLE_EMBED_STDCXX@
# Use -fvisibility-inlines-hidden?
ENABLE_VISIBILITY_INLINES_HIDDEN := @ENABLE_VISIBILITY_INLINES_HIDDEN@
# Do we want to allow timestamping information into builds?
ENABLE_TIMESTAMPS := @ENABLE_TIMESTAMPS@
# This option tells the Makefiles to produce verbose output.
# It essentially prints the commands that make is executing
#VERBOSE = 1
# Enable JIT for this platform
TARGET_HAS_JIT = @TARGET_HAS_JIT@
# Shared library extension for host platform.
SHLIBEXT = @SHLIBEXT@
# Executable file extension for host platform.
EXEEXT = @EXEEXT@
# Things we just assume are "there"
ECHO := echo
# Get the options for causing archives to link all their content instead of
# just missing symbols, and the inverse of that. This is used for certain LLVM
# tools that permit loadable modules. It ensures that the LLVM symbols will be
# available to those loadable modules.
LINKALL := @LINKALL@
NOLINKALL := @NOLINKALL@
# Get the value of HUGE_VAL_SANITY which will be either "yes" or "no" depending
# on the check.
HUGE_VAL_SANITY = @HUGE_VAL_SANITY@
# Bindings that we should build
BINDINGS_TO_BUILD := @BINDINGS_TO_BUILD@
OCAML_LIBDIR := @OCAML_LIBDIR@
# When compiling under Mingw/Cygwin, executables such as tblgen
# expect Windows paths, whereas the build system uses Unix paths.
# The function SYSPATH transforms Unix paths into Windows paths.
ifneq (,$(findstring -mno-cygwin, $(CXX)))
SYSPATH = $(shell echo $(1) | cygpath -m -f -)
else
SYSPATH = $(1)
endif
# Location of the plugin header file for gold.
BINUTILS_INCDIR := @BINUTILS_INCDIR@
# Optional flags supported by the compiler
# -Wmissing-field-initializers
MISSING_FIELD_INITIALIZERS = @MISSING_FIELD_INITIALIZERS@
# -Wno-variadic-macros
NO_VARIADIC_MACROS = @NO_VARIADIC_MACROS@
# -Wcovered-switch-default
COVERED_SWITCH_DEFAULT = @COVERED_SWITCH_DEFAULT@
# -Wno-uninitialized
NO_UNINITIALIZED = @NO_UNINITIALIZED@
# -Wno-maybe-uninitialized
NO_MAYBE_UNINITIALIZED = @NO_MAYBE_UNINITIALIZED@
# -Wno-comment
NO_COMMENT = @NO_COMMENT@
# Was polly found in tools/polly?
LLVM_HAS_POLLY = @LLVM_HAS_POLLY@
# Flags supported by the linker.
# bfd ld / gold --version-script=file
HAVE_LINK_VERSION_SCRIPT = @HAVE_LINK_VERSION_SCRIPT@
# Flags to control using libxml2
LIBXML2_LIBS := @LIBXML2_LIBS@
LIBXML2_INC := @LIBXML2_INC@
# Flags to control building support for Intel JIT Events API
USE_INTEL_JITEVENTS := @USE_INTEL_JITEVENTS@
INTEL_JITEVENTS_INCDIR := @INTEL_JITEVENTS_INCDIR@
INTEL_JITEVENTS_LIBDIR := @INTEL_JITEVENTS_LIBDIR@
# Flags to control building support for OProfile JIT API
USE_OPROFILE := @USE_OPROFILE@
ifeq ($(USE_INTEL_JITEVENTS), 1)
OPTIONAL_COMPONENTS += IntelJITEvents
endif
ifeq ($(USE_OPROFILE), 1)
OPTIONAL_COMPONENTS += OProfileJIT
endif

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +0,0 @@
#!/bin/bash
die() {
echo "$@" 1>&2
exit 1
}
clean() {
echo $1 | sed -e 's/\\//g'
}
### NOTE: ############################################################
### These variables specify the tool versions we want to use.
### Periods should be escaped with backslash for use by grep.
###
### If you update these, please also update docs/GettingStarted.rst
want_autoconf_version='2\.60'
want_autoheader_version=$want_autoconf_version
want_aclocal_version='1\.9\.6'
### END NOTE #########################################################
outfile=configure
configfile=configure.ac
want_autoconf_version_clean=$(clean $want_autoconf_version)
want_autoheader_version_clean=$(clean $want_autoheader_version)
want_aclocal_version_clean=$(clean $want_aclocal_version)
test -d autoconf && test -f autoconf/$configfile && cd autoconf
test -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
autoconf --version | grep $want_autoconf_version > /dev/null
test $? -eq 0 || die "Your autoconf was not detected as being $want_autoconf_version_clean"
aclocal --version | grep '^aclocal.*'$want_aclocal_version > /dev/null
test $? -eq 0 || die "Your aclocal was not detected as being $want_aclocal_version_clean"
autoheader --version | grep '^autoheader.*'$want_autoheader_version > /dev/null
test $? -eq 0 || die "Your autoheader was not detected as being $want_autoheader_version_clean"
echo ""
echo "### NOTE: ############################################################"
echo "### If you get *any* warnings from autoconf below you MUST fix the"
echo "### scripts in the m4 directory because there are future forward"
echo "### compatibility or platform support issues at risk. Please do NOT"
echo "### commit any configure script that was generated with warnings"
echo "### present. You should get just three 'Regenerating..' lines."
echo "######################################################################"
echo ""
echo "Regenerating aclocal.m4 with aclocal $want_aclocal_version_clean"
cwd=`pwd`
aclocal --force -I $cwd/m4 || die "aclocal failed"
echo "Regenerating configure with autoconf $want_autoconf_version_clean"
autoconf --force --warnings=all -o ../$outfile $configfile || die "autoconf failed"
cd ..
echo "Regenerating config.h.in with autoheader $want_autoheader_version_clean"
autoheader --warnings=all -I autoconf -I autoconf/m4 autoconf/$configfile || die "autoheader failed"
exit 0

View File

@ -1,7 +0,0 @@
{
global: main;
__progname;
environ;
local: *;
};

View File

@ -1,24 +0,0 @@
------------------------------------------------------------------------------
Autoconf Files
------------------------------------------------------------------------------
All autoconf files are licensed under the LLVM license with the following
additions:
llvm/autoconf/install-sh:
This script is licensed under the LLVM license, with the following
additional copyrights and restrictions:
Copyright 1991 by the Massachusetts Institute of Technology
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
Please see the source files for additional copyrights.

View File

@ -1,14 +0,0 @@
Upgrading autoconf
===============================================================================
If you are in the mood to upgrade autoconf, you should:
1. Consider not upgrading.
2. No really, this is a hassle, you don't want to do it.
3. Get the new version of autoconf and put it in <SRC>
4. configure/build/install autoconf with --prefix=<PFX>
5. Run autoupdate on all the m4 macros in llvm/autoconf/m4
6. Run autoupdate on llvm/autoconf/configure.ac
7. Regenerate configure script with AutoRegen.sh
8. If there are any warnings from AutoRegen.sh, fix them and go to step 7.
9. Test, test, test.

1770
autoconf/config.sub vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,322 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2004-09-10.20
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit 0;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit 0;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,42 +0,0 @@
# Check for the extension used for executables on build platform.
# This is necessary for cross-compiling where the build platform
# may differ from the host platform.
AC_DEFUN([AC_BUILD_EXEEXT],
[
AC_MSG_CHECKING([for executable suffix on build platform])
AC_CACHE_VAL(ac_cv_build_exeext,
[if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
ac_cv_build_exeext=.exe
else
ac_build_prefix=${build_alias}-
AC_CHECK_PROG(BUILD_CC, ${ac_build_prefix}gcc, ${ac_build_prefix}gcc)
if test -z "$BUILD_CC"; then
AC_CHECK_PROG(BUILD_CC, gcc, gcc)
if test -z "$BUILD_CC"; then
AC_CHECK_PROG(BUILD_CC, cc, cc, , , /usr/ucb/cc)
fi
fi
test -z "$BUILD_CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
ac_build_link='${BUILD_CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AS_MESSAGE_LOG_FD'
rm -f conftest*
echo 'int main () { return 0; }' > conftest.$ac_ext
ac_cv_build_exeext=
if AC_TRY_EVAL(ac_build_link); then
for file in conftest.*; do
case $file in
*.c | *.o | *.obj | *.dSYM) ;;
*) ac_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
esac
done
else
AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
fi
rm -f conftest*
test x"${ac_cv_build_exeext}" = x && ac_cv_build_exeext=blank
fi])
BUILD_EXEEXT=""
test x"${ac_cv_build_exeext}" != xblank && BUILD_EXEEXT=${ac_cv_build_exeext}
AC_MSG_RESULT(${ac_cv_build_exeext})
ac_build_exeext=$BUILD_EXEEXT
AC_SUBST(BUILD_EXEEXT)])

View File

@ -1,31 +0,0 @@
#
# Determine if the printf() functions have the %a format character.
# This is modified from:
# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html
AC_DEFUN([AC_C_PRINTF_A],
[AC_CACHE_CHECK([if printf has the %a format character],[llvm_cv_c_printf_a],
[AC_LANG_PUSH([C])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
#include <stdio.h>
#include <stdlib.h>
]],[[
volatile double A, B;
char Buffer[100];
A = 1;
A /= 10.0;
sprintf(Buffer, "%a", A);
B = atof(Buffer);
if (A != B)
return (1);
if (A != 0x1.999999999999ap-4)
return (1);
return (0);]])],
llvm_cv_c_printf_a=yes,
llvmac_cv_c_printf_a=no,
llvmac_cv_c_printf_a=no)
AC_LANG_POP([C])])
if test "$llvm_cv_c_printf_a" = "yes"; then
AC_DEFINE([HAVE_PRINTF_A],[1],[Define to have the %a format string])
fi
])

View File

@ -1,26 +0,0 @@
#
# Check for GNU Make. This is originally from
# http://www.gnu.org/software/ac-archive/htmldoc/check_gnu_make.html
#
AC_DEFUN([AC_CHECK_GNU_MAKE],
[AC_CACHE_CHECK([for GNU make],[llvm_cv_gnu_make_command],
dnl Search all the common names for GNU make
[llvm_cv_gnu_make_command=''
for a in "$MAKE" make gmake gnumake ; do
if test -z "$a" ; then continue ; fi ;
if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null )
then
llvm_cv_gnu_make_command=$a ;
break;
fi
done])
dnl If there was a GNU version, then set @ifGNUmake@ to the empty string,
dnl '#' otherwise
if test "x$llvm_cv_gnu_make_command" != "x" ; then
ifGNUmake='' ;
else
ifGNUmake='#' ;
AC_MSG_RESULT("Not found");
fi
AC_SUBST(ifGNUmake)
])

View File

@ -1,9 +0,0 @@
#
# Configure a Makefile without clobbering it if it exists and is not out of
# date. This macro is unique to LLVM.
#
AC_DEFUN([AC_CONFIG_MAKEFILE],
[AC_CONFIG_COMMANDS($1,
[${llvm_src}/autoconf/mkinstalldirs `dirname $1`
${SHELL} ${llvm_src}/autoconf/install-sh -m 0644 -c ${srcdir}/$1 $1])
])

View File

@ -1,14 +0,0 @@
#
# Provide the arguments and other processing needed for an LLVM project
#
AC_DEFUN([LLVM_CONFIG_PROJECT],
[AC_ARG_WITH([llvmsrc],
AS_HELP_STRING([--with-llvmsrc],[Location of LLVM Source Code]),
[llvm_src="$withval"],[llvm_src="]$1["])
AC_SUBST(LLVM_SRC,$llvm_src)
AC_ARG_WITH([llvmobj],
AS_HELP_STRING([--with-llvmobj],[Location of LLVM Object Code]),
[llvm_obj="$withval"],[llvm_obj="]$2["])
AC_SUBST(LLVM_OBJ,$llvm_obj)
AC_CONFIG_COMMANDS([setup],,[llvm_src="${LLVM_SRC}"])
])

View File

@ -1,2 +0,0 @@
AC_DEFUN([CXX_FLAG_CHECK],
[AC_SUBST($1, `$CXX -Werror patsubst($2, [^-Wno-], [-W]) -fsyntax-only -xc /dev/null 2>/dev/null && echo $2`)])

View File

@ -1,5 +0,0 @@
# Combine AC_DEFINE and AC_SUBST
AC_DEFUN([LLVM_DEFINE_SUBST], [
AC_DEFINE([$1], [$2], [$3])
AC_SUBST([$1], ['$2'])
])

View File

@ -1,118 +0,0 @@
dnl Check for a standard program that has a bin, include and lib directory
dnl
dnl Parameters:
dnl $1 - prefix directory to check
dnl $2 - program name to check
dnl $3 - header file to check
dnl $4 - library file to check
AC_DEFUN([CHECK_STD_PROGRAM],
[m4_define([allcapsname],translit($2,a-z,A-Z))
if test -n "$1" -a -d "$1" -a -n "$2" -a -d "$1/bin" -a -x "$1/bin/$2" ; then
AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"])
AC_SUBST(allcapsname(),[$1/bin/$2])
AC_SUBST(allcapsname()[_BIN],[$1/bin])
AC_SUBST(allcapsname()[_DIR],[$1])
if test -n "$3" -a -d "$1/include" -a -f "$1/include/$3" ; then
AC_SUBST(allcapsname()[_INC],[$1/include])
fi
if test -n "$4" -a -d "$1/lib" -a -f "$1/lib/$4" ; then
AC_SUBST(allcapsname()[_LIB],[$1/lib])
fi
fi
])
dnl Find a program via --with options, in the path, or well known places
dnl
dnl Parameters:
dnl $1 - program's executable name
dnl $2 - header file name to check (optional)
dnl $3 - library file name to check (optional)
dnl $4 - alternate (long) name for the program
AC_DEFUN([FIND_STD_PROGRAM],
[m4_define([allcapsname],translit($1,a-z,A-Z))
m4_define([stdprog_long_name],ifelse($4,,translit($1,[ !@#$%^&*()-+={}[]:;"',./?],[-]),translit($4,[ !@#$%^&*()-+={}[]:;"',./?],[-])))
AC_MSG_CHECKING([for ]stdprog_long_name()[ bin/lib/include locations])
AC_ARG_WITH($1,
AS_HELP_STRING([--with-]stdprog_long_name()[=DIR],
[Specify that the ]stdprog_long_name()[ install prefix is DIR]),
$1[pfxdir=$withval],$1[pfxdir=nada])
AC_ARG_WITH($1[-bin],
AS_HELP_STRING([--with-]stdprog_long_name()[-bin=DIR],
[Specify that the ]stdprog_long_name()[ binary is in DIR]),
$1[bindir=$withval],$1[bindir=nada])
AC_ARG_WITH($1[-lib],
AS_HELP_STRING([--with-]stdprog_long_name()[-lib=DIR],
[Specify that ]stdprog_long_name()[ libraries are in DIR]),
$1[libdir=$withval],$1[libdir=nada])
AC_ARG_WITH($1[-inc],
AS_HELP_STRING([--with-]stdprog_long_name()[-inc=DIR],
[Specify that the ]stdprog_long_name()[ includes are in DIR]),
$1[incdir=$withval],$1[incdir=nada])
eval pfxval=\$\{$1pfxdir\}
eval binval=\$\{$1bindir\}
eval incval=\$\{$1incdir\}
eval libval=\$\{$1libdir\}
if test "${pfxval}" != "nada" ; then
CHECK_STD_PROGRAM(${pfxval},$1,$2,$3)
elif test "${binval}" != "nada" ; then
if test "${libval}" != "nada" ; then
if test "${incval}" != "nada" ; then
if test -d "${binval}" ; then
if test -d "${incval}" ; then
if test -d "${libval}" ; then
AC_SUBST(allcapsname(),${binval}/$1)
AC_SUBST(allcapsname()[_BIN],${binval})
AC_SUBST(allcapsname()[_INC],${incval})
AC_SUBST(allcapsname()[_LIB],${libval})
AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"])
AC_MSG_RESULT([found via --with options])
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-libdir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-incdir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-bindir value must be a directory])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-incdir option must be specified])
fi
else
AC_MSG_RESULT([failed])
AC_MSG_ERROR([The --with-]$1[-libdir option must be specified])
fi
else
tmppfxdir=`which $1 2>&1`
if test -n "$tmppfxdir" -a -d "${tmppfxdir%*$1}" -a \
-d "${tmppfxdir%*$1}/.." ; then
tmppfxdir=`cd "${tmppfxdir%*$1}/.." ; pwd`
CHECK_STD_PROGRAM($tmppfxdir,$1,$2,$3)
AC_MSG_RESULT([found in PATH at ]$tmppfxdir)
else
checkresult="yes"
eval checkval=\$\{"USE_"allcapsname()\}
CHECK_STD_PROGRAM([/usr],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/usr/local],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/sw],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/opt],$1,$2,$3)
if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/],$1,$2,$3)
if test -z "${checkval}" ; then
checkresult="no"
fi
fi
fi
fi
fi
AC_MSG_RESULT($checkresult)
fi
fi
])

View File

@ -1,26 +0,0 @@
#
# Check for the ability to mmap a file.
#
AC_DEFUN([AC_FUNC_MMAP_FILE],
[AC_CACHE_CHECK(for mmap of files,
ac_cv_func_mmap_file,
[ AC_LANG_PUSH([C])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
]],[[
int fd;
fd = creat ("foo",0777);
fd = (int) mmap (0, 1, PROT_READ, MAP_SHARED, fd, 0);
unlink ("foo");
return (fd != (int) MAP_FAILED);]])],
[ac_cv_func_mmap_file=yes],[ac_cv_func_mmap_file=no],[ac_cv_func_mmap_file=no])
AC_LANG_POP([C])
])
if test "$ac_cv_func_mmap_file" = yes; then
AC_DEFINE([HAVE_MMAP_FILE],[],[Define if mmap() can map files into memory])
AC_SUBST(MMAP_FILE,[yes])
fi
])

View File

@ -1,21 +0,0 @@
#
# Check for anonymous mmap macros. This is modified from
# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html
#
AC_DEFUN([AC_HEADER_MMAP_ANONYMOUS],
[AC_CACHE_CHECK(for MAP_ANONYMOUS vs. MAP_ANON,
ac_cv_header_mmap_anon,
[ AC_LANG_PUSH([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>]],
[[mmap (0, 1, PROT_READ, MAP_ANONYMOUS, -1, 0); return (0);]])],
ac_cv_header_mmap_anon=yes,
ac_cv_header_mmap_anon=no)
AC_LANG_POP([C])
])
if test "$ac_cv_header_mmap_anon" = yes; then
AC_DEFINE([HAVE_MMAP_ANONYMOUS],[1],[Define if mmap() uses MAP_ANONYMOUS to map anonymous pages, or undefine if it uses MAP_ANON])
fi
])

View File

@ -1,18 +0,0 @@
#
# This function determins if the HUGE_VAL macro is compilable with the
# -pedantic switch or not. XCode < 2.4.1 doesn't get it right.
#
AC_DEFUN([AC_HUGE_VAL_CHECK],[
AC_CACHE_CHECK([for HUGE_VAL sanity], [ac_cv_huge_val_sanity],[
AC_LANG_PUSH([C++])
ac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -pedantic"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
[[double x = HUGE_VAL; return x != x;]])],
[ac_cv_huge_val_sanity=yes],[ac_cv_huge_val_sanity=no],
[ac_cv_huge_val_sanity=yes])
CXXFLAGS=$ac_save_CXXFLAGS
AC_LANG_POP([C++])
])
AC_SUBST(HUGE_VAL_SANITY,$ac_cv_huge_val_sanity)
])

View File

@ -1,109 +0,0 @@
#
# Get the linker version string.
#
# This macro is specific to LLVM.
#
AC_DEFUN([AC_LINK_GET_VERSION],
[AC_CACHE_CHECK([for linker version],[llvm_cv_link_version],
[
version_string="$(${LD:-ld} -v 2>&1 | head -1)"
# Check for ld64.
if (echo "$version_string" | grep -q "ld64"); then
llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)\( (.*)\)\{0,1\}#\1#")
else
llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#")
fi
])
AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version",
[Linker version detected at compile time.])
])
#
# Determine if the system can handle the -R option being passed to the linker.
#
# This macro is specific to LLVM.
#
AC_DEFUN([AC_LINK_USE_R],
[AC_CACHE_CHECK([for compiler -Wl,-R<path> option],[llvm_cv_link_use_r],
[ AC_LANG_PUSH([C])
oldcflags="$CFLAGS"
CFLAGS="$CFLAGS -Wl,-R."
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
[llvm_cv_link_use_r=yes],[llvm_cv_link_use_r=no])
CFLAGS="$oldcflags"
AC_LANG_POP([C])
])
if test "$llvm_cv_link_use_r" = yes ; then
AC_DEFINE([HAVE_LINK_R],[1],[Define if you can use -Wl,-R. to pass -R. to the linker, in order to add the current directory to the dynamic linker search path.])
fi
])
#
# Determine if the system can handle the -rdynamic option being passed
# to the compiler.
#
# This macro is specific to LLVM.
#
AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
[AC_CACHE_CHECK([for compiler -rdynamic option],
[llvm_cv_link_use_export_dynamic],
[ AC_LANG_PUSH([C])
oldcflags="$CFLAGS"
CFLAGS="$CFLAGS -rdynamic"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
[llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
CFLAGS="$oldcflags"
AC_LANG_POP([C])
])
if test "$llvm_cv_link_use_export_dynamic" = yes ; then
AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -rdynamic.])
fi
])
#
# Determine if the system can handle the --version-script option being
# passed to the linker.
#
# This macro is specific to LLVM.
#
AC_DEFUN([AC_LINK_VERSION_SCRIPT],
[AC_CACHE_CHECK([for compiler -Wl,--version-script option],
[llvm_cv_link_use_version_script],
[ AC_LANG_PUSH([C])
oldcflags="$CFLAGS"
# The following code is from the autoconf manual,
# "11.13: Limitations of Usual Tools".
# Create a temporary directory $tmp in $TMPDIR (default /tmp).
# Use mktemp if possible; otherwise fall back on mkdir,
# with $RANDOM to make collisions less likely.
: ${TMPDIR=/tmp}
{
tmp=`
(umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
` &&
test -n "$tmp" && test -d "$tmp"
} || {
tmp=$TMPDIR/foo$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || exit $?
echo "{" > "$tmp/export.map"
echo " global: main;" >> "$tmp/export.map"
echo " local: *;" >> "$tmp/export.map"
echo "};" >> "$tmp/export.map"
CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
[llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no])
rm "$tmp/export.map"
rmdir "$tmp"
CFLAGS="$oldcflags"
AC_LANG_POP([C])
])
if test "$llvm_cv_link_use_version_script" = yes ; then
AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1)
fi
])

View File

@ -1,17 +0,0 @@
#
# Some Linux machines run a 64-bit kernel with a 32-bit userspace. 'uname -m'
# shows these as x86_64. Ask the system 'gcc' what it thinks.
#
AC_DEFUN([AC_IS_LINUX_MIXED],
[AC_CACHE_CHECK(for 32-bit userspace on 64-bit system,llvm_cv_linux_mixed,
[ AC_LANG_PUSH([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#ifndef __x86_64__
error: Not x86-64 even if uname says so!
#endif
]])],
[llvm_cv_linux_mixed=no],
[llvm_cv_linux_mixed=yes])
AC_LANG_POP([C])
])
])

View File

@ -1,17 +0,0 @@
#
# When allocating RWX memory, check whether we need to use /dev/zero
# as the file descriptor or not.
#
AC_DEFUN([AC_NEED_DEV_ZERO_FOR_MMAP],
[AC_CACHE_CHECK([if /dev/zero is needed for mmap],
ac_cv_need_dev_zero_for_mmap,
[if test "$llvm_cv_os_type" = "Interix" ; then
ac_cv_need_dev_zero_for_mmap=yes
else
ac_cv_need_dev_zero_for_mmap=no
fi
])
if test "$ac_cv_need_dev_zero_for_mmap" = yes; then
AC_DEFINE([NEED_DEV_ZERO_FOR_MMAP],[1],
[Define if /dev/zero should be used when mapping RWX memory, or undefine if its not necessary])
fi])

View File

@ -1,31 +0,0 @@
dnl Check a program for version sanity. The test runs a program, passes it an
dnl argument to make it print out some identification string, and filters that
dnl output with a regular expression. If the output is non-empty, the program
dnl passes the sanity check.
dnl $1 - Name or full path of the program to run
dnl $2 - Argument to pass to print out identification string
dnl $3 - grep RE to match identification string
dnl $4 - set to 1 to make errors only a warning
AC_DEFUN([CHECK_PROGRAM_SANITY],
[
AC_MSG_CHECKING([sanity for program ]$1)
sanity="0"
sanity_path=`which $1 2>/dev/null`
if test "$?" -eq 0 -a -x "$sanity_path" ; then
sanity=`$1 $2 2>&1 | grep "$3"`
if test -z "$sanity" ; then
AC_MSG_RESULT([no])
sanity="0"
if test "$4" -eq 1 ; then
AC_MSG_WARN([Program ]$1[ failed to pass sanity check.])
else
AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
fi
else
AC_MSG_RESULT([yes])
sanity="1"
fi
else
AC_MSG_RESULT([not found])
fi
])

View File

@ -1,16 +0,0 @@
dnl
dnl AC_SINGLE_CXX_CHECK(CACHEVAR, FUNCTION, HEADER, PROGRAM)
dnl $1, $2, $3, $4,
AC_DEFUN([AC_SINGLE_CXX_CHECK],
[
AC_CACHE_CHECK([for $2 in $3], [$1],
[
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]][$3], [$4])],
[$1][[=yes]],
[$1][[=no]])
AC_LANG_POP([C++])
])
])

View File

@ -1,24 +0,0 @@
#
# Determine if the compiler accepts -fvisibility-inlines-hidden
#
# This macro is specific to LLVM.
#
AC_DEFUN([AC_CXX_USE_VISIBILITY_INLINES_HIDDEN],
[AC_CACHE_CHECK([for compiler -fvisibility-inlines-hidden option],
[llvm_cv_cxx_visibility_inlines_hidden],
[ AC_LANG_PUSH([C++])
oldcxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -O0 -fvisibility-inlines-hidden -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[template <typename T> struct X { void __attribute__((noinline)) f() {} };],
[X<int>().f();])],
[llvm_cv_cxx_visibility_inlines_hidden=yes],[llvm_cv_cxx_visibility_inlines_hidden=no])
CXXFLAGS="$oldcxxflags"
AC_LANG_POP([C++])
])
if test "$llvm_cv_cxx_visibility_inlines_hidden" = yes ; then
AC_SUBST([ENABLE_VISIBILITY_INLINES_HIDDEN],[1])
else
AC_SUBST([ENABLE_VISIBILITY_INLINES_HIDDEN],[0])
fi
])

View File

@ -1,353 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2004-09-07.08
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit 0
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit 0
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,150 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2004-02-15.20
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit 0
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit 0
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
# echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
# echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
# echo "chmod $dirmode $pathcomp"
lasterr=""
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,20 +0,0 @@
##===- bindings/Makefile -----------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL := ..
include $(LEVEL)/Makefile.config
PARALLEL_DIRS =
ifneq (,$(filter ocaml,$(BINDINGS_TO_BUILD)))
PARALLEL_DIRS += ocaml
endif
include $(LEVEL)/Makefile.common

View File

@ -81,7 +81,6 @@ func TestFactorial(t *testing.T) {
pass := NewPassManager()
defer pass.Dispose()
pass.Add(engine.TargetData())
pass.AddConstantPropagationPass()
pass.AddInstructionCombiningPass()
pass.AddPromoteMemoryToRegisterPass()

View File

@ -121,13 +121,6 @@ func NewTargetData(rep string) (td TargetData) {
return
}
// Adds target data information to a pass manager. This does not take ownership
// of the target data.
// See the method llvm::PassManagerBase::add.
func (pm PassManager) Add(td TargetData) {
C.LLVMAddTargetData(td.C, pm.C)
}
// Converts target data to a target layout string. The string must be disposed
// with LLVMDisposeMessage.
// See the constructor llvm::TargetData::TargetData.
@ -261,17 +254,19 @@ func (t Target) CreateTargetMachine(Triple string, CPU string, Features string,
return
}
// CreateTargetData returns a new TargetData describing the TargetMachine's
// data layout. The returned TargetData is owned by the caller, who is
// responsible for disposing of it by calling the TargetData.Dispose method.
func (tm TargetMachine) CreateTargetData() TargetData {
return TargetData{C.LLVMCreateTargetDataLayout(tm.C)}
}
// Triple returns the triple describing the machine (arch-vendor-os).
func (tm TargetMachine) Triple() string {
cstr := C.LLVMGetTargetMachineTriple(tm.C)
return C.GoString(cstr)
}
// TargetData returns the TargetData for the machine.
func (tm TargetMachine) TargetData() TargetData {
return TargetData{C.LLVMGetTargetMachineData(tm.C)}
}
func (tm TargetMachine) EmitToMemoryBuffer(m Module, ft CodeGenFileType) (MemoryBuffer, error) {
var errstr *C.char
var mb MemoryBuffer

View File

@ -1,20 +0,0 @@
##===- bindings/ocaml/Makefile -----------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL := ../..
DIRS = llvm bitreader bitwriter irreader analysis target executionengine \
transforms linker backends all_backends
ExtraMakefiles = $(PROJ_OBJ_DIR)/Makefile.ocaml
ocamldoc:
$(Verb) for i in $(DIRS) ; do \
$(MAKE) -C $$i ocamldoc; \
done
include $(LEVEL)/Makefile.common

View File

@ -1,483 +0,0 @@
##===- bindings/ocaml/Makefile.ocaml -----------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# An OCaml library is a unique project type in the context of LLVM, so rules are
# here rather than in Makefile.rules.
#
# Reference materials on installing OCaml libraries:
#
# https://fedoraproject.org/wiki/Packaging/OCaml
# http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.txt
#
##===----------------------------------------------------------------------===##
include $(LEVEL)/Makefile.config
# We have our own rules for building static libraries.
NO_BUILD_ARCHIVE = 1
# CFLAGS needs to be set before Makefile.rules is included.
CXX.Flags += -I"$(shell $(OCAMLFIND) c -where)"
C.Flags += -I"$(shell $(OCAMLFIND) c -where)"
ifeq ($(ENABLE_SHARED),1)
LINK_COMPONENTS := all
endif
include $(LEVEL)/Makefile.common
# Used in out-of-tree builds of OCaml bindings only.
ifdef SYSTEM_LLVM_CONFIG
LLVM_CONFIG = $(SYSTEM_LLVM_CONFIG)
LLVMLibsOptions += $(shell $(LLVM_CONFIG) --ldflags)
endif
# Intentionally ignore PROJ_prefix here. We want the ocaml stdlib. However, the
# user can override this with OCAML_LIBDIR or configure --with-ocaml-libdir=.
PROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR)
OcamlDir := $(LibDir)/ocaml
# Info from llvm-config and similar
ifndef IS_CLEANING_TARGET
ifdef UsedComponents
UsedLibs = $(shell $(LLVM_CONFIG) --libs --system-libs $(UsedComponents))
UsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents))
endif
endif
# How do we link OCaml executables with LLVM?
# 1) If this is a --enable-shared build, build stub libraries. This also allows
# to use LLVM from toplevels.
# 2) If this is a --disable-shared build, embed ocamlc options for building
# a custom runtime and a static executable. It is not possible to use LLVM
# from toplevels.
ifneq ($(ObjectsO),)
ifeq ($(ENABLE_SHARED),1)
OCAMLSTUBS := 1
OCAMLSTUBFLAGS := $(patsubst %,-cclib %, $(LLVMLibsOptions) -l$(LIBRARYNAME))
endif
endif
# Avoid the need for LD_LIBRARY_PATH
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
ifneq ($(HOST_OS),Darwin)
OCAMLRPATH := $(RPATH) -Wl,'$$ORIGIN/../../lib'
endif
endif
# See http://caml.inria.fr/mantis/view.php?id=6642
OCAMLORIGIN := -ccopt -L'$$CAMLORIGIN/..' \
-ccopt $(RPATH) -ccopt -Wl,'$$CAMLORIGIN/..'
# Tools
OCAMLCFLAGS += -I $(OcamlDir) $(addprefix -package ,$(FindlibPackages))
ifndef IS_CLEANING_TARGET
ifneq ($(ObjectsO),)
OCAMLAFLAGS += $(patsubst %,-cclib %, \
$(filter-out -L$(LibDir),-l$(LIBRARYNAME) \
$(shell $(LLVM_CONFIG) --ldflags)) \
$(UsedLibs) $(ExtraLibs))
else
OCAMLAFLAGS += $(patsubst %,-cclib %, \
$(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \
$(UsedLibs) $(ExtraLibs))
endif
endif
ifneq ($(DEBUG_SYMBOLS),1)
OCAMLDEBUGFLAG := -g
endif
Compile.CMI := $(strip $(OCAMLFIND) c -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
Compile.CMO := $(strip $(OCAMLFIND) c -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
Compile.CMX := $(strip $(OCAMLFIND) opt -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
ifdef OCAMLSTUBS
# -dllib is engaged with ocamlc builds, $(OCAMLSTUBFLAGS) in ocamlc -custom builds.
Archive.CMA := $(strip $(OCAMLFIND) c -a -dllib -l$(LIBRARYNAME) $(OCAMLSTUBFLAGS) \
$(OCAMLDEBUGFLAG) $(OCAMLORIGIN) -o)
else
Archive.CMA := $(strip $(OCAMLFIND) c -a -custom $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \
$(OCAMLORIGIN) -o)
endif
ifdef OCAMLSTUBS
Archive.CMXA := $(strip $(OCAMLFIND) opt -a $(OCAMLSTUBFLAGS) $(OCAMLDEBUGFLAG) \
$(OCAMLORIGIN) -o)
else
Archive.CMXA := $(strip $(OCAMLFIND) opt -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \
$(OCAMLORIGIN) -o)
endif
# Source files
ifndef OcamlSources1
OcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml))
endif
ifndef OcamlHeaders1
OcamlHeaders1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.mli))
endif
OcamlSources2 := $(filter-out $(ExcludeSources),$(OcamlSources1))
OcamlHeaders2 := $(filter-out $(ExcludeHeaders),$(OcamlHeaders1))
OcamlSources := $(OcamlSources2:$(PROJ_SRC_DIR)/%=$(ObjDir)/%)
OcamlHeaders := $(OcamlHeaders2:$(PROJ_SRC_DIR)/%=$(ObjDir)/%)
# Intermediate files
ObjectsCMI := $(OcamlSources:%.ml=%.cmi)
ObjectsCMO := $(OcamlSources:%.ml=%.cmo)
ObjectsCMX := $(OcamlSources:%.ml=%.cmx)
ifdef LIBRARYNAME
LibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma
LibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa
endif
ifdef TOOLNAME
ToolEXE := $(ObjDir)/$(TOOLNAME)$(EXEEXT)
endif
# Output files
# The .cmo files are the only intermediates; all others are to be installed.
OutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi)
OutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx)
OutputLibs := $(UsedLibNames:%=$(OcamlDir)/%)
ifdef LIBRARYNAME
LibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a
OutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma)
OutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa)
endif
ifdef OCAMLSTUBS
SharedLib := $(OcamlDir)/dll$(LIBRARYNAME)$(SHLIBEXT)
endif
ifdef TOOLNAME
ifdef EXAMPLE_TOOL
OutputEXE := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
else
OutputEXE := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
endif
endif
# Installation targets
DestLibs := $(UsedLibNames:%=$(PROJ_libocamldir)/%)
ifdef LIBRARYNAME
DestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a
DestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma
DestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa
endif
ifdef OCAMLSTUBS
DestSharedLib := $(PROJ_libocamldir)/dll$(LIBRARYNAME)$(SHLIBEXT)
endif
##===- Dependencies -------------------------------------------------------===##
# Copy the sources into the intermediate directory because older ocamlc doesn't
# support -o except when linking (outputs are placed next to inputs).
$(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir
$(Verb) $(CP) -f $< $@
$(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir
$(Verb) $(CP) -f $< $@
$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi)
ifdef LIBRARYNAME
$(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \
$(OcamlDir)/.dir $(ObjDir)/.dir
$(Verb) $(OCAMLFIND) dep $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@
-include $(ObjDir)/$(LIBRARYNAME).ocamldep
endif
ifdef TOOLNAME
$(ObjDir)/$(TOOLNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \
$(OcamlDir)/.dir $(ObjDir)/.dir
$(Verb) $(OCAMLFIND) dep $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@
-include $(ObjDir)/$(TOOLNAME).ocamldep
endif
##===- Build static library from C sources --------------------------------===##
ifdef LibraryA
all-local:: $(LibraryA)
clean-local:: clean-a
install-local:: install-a
uninstall-local:: uninstall-a
$(LibraryA): $(ObjectsO) $(OcamlDir)/.dir
$(Echo) "Building $(BuildMode) $(notdir $@)"
-$(Verb) $(RM) -f $@
$(Verb) $(Archive) $@ $(ObjectsO)
$(Verb) $(Ranlib) $@
clean-a::
-$(Verb) $(RM) -f $(LibraryA)
install-a:: $(LibraryA)
$(Echo) "Installing $(BuildMode) $(DestA)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(INSTALL) $(LibraryA) $(DestA)
$(Verb)
uninstall-a::
$(Echo) "Uninstalling $(DestA)"
-$(Verb) $(RM) -f $(DestA)
endif
##===- Build stub library from C sources ----------------------------------===##
ifdef SharedLib
all-local:: $(SharedLib)
clean-local:: clean-shared
install-local:: install-shared
uninstall-local:: uninstall-shared
$(SharedLib): $(ObjectsO) $(OcamlDir)/.dir
$(Echo) "Building $(BuildMode) $(notdir $@)"
$(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) -o $@ $(ObjectsO) \
$(LLVMLibsOptions)
clean-shared::
-$(Verb) $(RM) -f $(SharedLib)
install-shared:: $(SharedLib)
$(Echo) "Installing $(BuildMode) $(DestSharedLib)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(INSTALL) $(SharedLib) $(DestSharedLib)
$(Verb)
uninstall-shared::
$(Echo) "Uninstalling $(DestSharedLib)"
-$(Verb) $(RM) -f $(DestSharedLib)
endif
##===- Deposit dependent libraries adjacent to OCaml libs -----------------===##
ifndef SYSTEM_LLVM_CONFIG
all-local:: build-deplibs
clean-local:: clean-deplibs
install-local:: install-deplibs
uninstall-local:: uninstall-deplibs
build-deplibs: $(OutputLibs)
$(OcamlDir)/%.so: $(LibDir)/%.so
$(Verb) ln -sf $< $@
$(OcamlDir)/%.a: $(LibDir)/%.a
$(Verb) ln -sf $< $@
$(OcamlDir)/%.o: $(LibDir)/%.o
$(Verb) ln -sf $< $@
clean-deplibs:
$(Verb) $(RM) -f $(OutputLibs)
install-deplibs:
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) for i in $(DestLibs:$(PROJ_libocamldir)/%=%); do \
ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \
done
uninstall-deplibs:
$(Verb) $(RM) -f $(DestLibs)
endif
##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===##
ifneq ($(OcamlHeaders),)
all-local:: build-cmis
clean-local:: clean-cmis
install-local:: install-cmis
uninstall-local:: uninstall-cmis
build-cmis: $(OutputsCMI)
$(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir
$(Verb) $(CP) -f $< $@
$(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir
$(Echo) "Compiling $(notdir $<) for $(BuildMode) build"
$(Verb) $(Compile.CMI) $@ $<
clean-cmis::
-$(Verb) $(RM) -f $(OutputsCMI)
# Also install the .mli's (headers) as documentation.
install-cmis: $(OutputsCMI) $(OcamlHeaders)
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \
$(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
$(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \
done
$(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \
$(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
$(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \
done
uninstall-cmis::
$(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \
$(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
$(RM) -f "$(PROJ_libocamldir)/$$i"; \
done
$(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \
$(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
$(RM) -f "$(PROJ_libocamldir)/$$i"; \
done
endif
##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===##
$(ObjDir)/%.cmo: $(ObjDir)/%.ml
$(Echo) "Compiling $(notdir $<) for $(BuildMode) build"
$(Verb) $(Compile.CMO) $@ $<
ifdef LIBRARYNAME
all-local:: $(OutputCMA)
clean-local:: clean-cma
install-local:: install-cma
uninstall-local:: uninstall-cma
$(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir
$(Verb) $(CP) -f $< $@
$(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir
$(Echo) "Archiving $(notdir $@) for $(BuildMode) build"
$(Verb) $(Archive.CMA) $@ $(ObjectsCMO)
clean-cma::
$(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%)
install-cma:: $(OutputCMA)
$(Echo) "Installing $(BuildMode) $(DestCMA)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)"
uninstall-cma::
$(Echo) "Uninstalling $(DestCMA)"
-$(Verb) $(RM) -f $(DestCMA)
endif
##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===##
# The ocamlopt compiler is supported on a set of targets disjoint from LLVM's.
# If unavailable, 'configure' will set HAVE_OCAMLOPT to 0 in Makefile.config.
ifeq ($(HAVE_OCAMLOPT),1)
$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx
$(Verb) $(CP) -f $< $@
$(ObjDir)/%.cmx: $(ObjDir)/%.ml
$(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build"
$(Verb) $(Compile.CMX) $@ $<
ifdef LIBRARYNAME
all-local:: $(OutputCMXA) $(OutputsCMX)
clean-local:: clean-cmxa
install-local:: install-cmxa
uninstall-local:: uninstall-cmxa
$(OutputCMXA): $(LibraryCMXA)
$(Verb) $(CP) -f $< $@
$(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a)
$(LibraryCMXA): $(ObjectsCMX)
$(Echo) "Archiving $(notdir $@) for $(BuildMode) build"
$(Verb) $(Archive.CMXA) $@ $(ObjectsCMX)
$(Verb) $(RM) -f $(@:.cmxa=.o)
clean-cmxa::
$(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.a) $(OutputsCMX)
install-cmxa:: $(OutputCMXA) $(OutputsCMX)
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Echo) "Installing $(BuildMode) $(DestCMXA)"
$(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA)
$(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)"
$(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a)
$(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \
$(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
$(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \
done
uninstall-cmxa::
$(Echo) "Uninstalling $(DestCMXA)"
$(Verb) $(RM) -f $(DestCMXA)
$(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)"
$(Verb) $(RM) -f $(DestCMXA:.cmxa=.a)
$(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \
$(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
$(RM) -f $(PROJ_libocamldir)/$$i; \
done
endif
endif
##===- Generate documentation ---------------------------------------------===##
$(ObjDir)/$(LIBRARYNAME).odoc: $(ObjectsCMI)
$(Echo) "Documenting $(notdir $@)"
$(Verb) $(OCAMLFIND) doc -I $(ObjDir) -I $(OcamlDir) -dump $@ $(OcamlHeaders)
ocamldoc: $(ObjDir)/$(LIBRARYNAME).odoc
##===- Debugging gunk -----------------------------------------------------===##
printvars:: printcamlvars
printcamlvars::
$(Echo) "LLVM_CONFIG : " '$(LLVM_CONFIG)'
$(Echo) "OCAMLCFLAGS : " '$(OCAMLCFLAGS)'
$(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)'
$(Echo) "OCAMLRPATH : " '$(OCAMLRPATH)'
$(Echo) "OCAMLSTUBS : " '$(OCAMLSTUBS)'
$(Echo) "OCAMLSTUBFLAGS : " '$(OCAMLSTUBFLAGS)'
$(Echo) "OCAMLFIND : " '$(OCAMLFIND)'
$(Echo) "Compile.CMI : " '$(Compile.CMI)'
$(Echo) "Compile.CMO : " '$(Compile.CMO)'
$(Echo) "Archive.CMA : " '$(Archive.CMA)'
$(Echo) "Compile.CMX : " '$(Compile.CMX)'
$(Echo) "Archive.CMXA : " '$(Archive.CMXA)'
$(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)'
$(Echo) "LibraryA : " '$(LibraryA)'
$(Echo) "LibraryCMA : " '$(LibraryCMA)'
$(Echo) "LibraryCMXA : " '$(LibraryCMXA)'
$(Echo) "SharedLib : " '$(SharedLib)'
$(Echo) "OcamlSources1: " '$(OcamlSources1)'
$(Echo) "OcamlSources2: " '$(OcamlSources2)'
$(Echo) "OcamlSources : " '$(OcamlSources)'
$(Echo) "OcamlHeaders1: " '$(OcamlHeaders1)'
$(Echo) "OcamlHeaders2: " '$(OcamlHeaders2)'
$(Echo) "OcamlHeaders : " '$(OcamlHeaders)'
$(Echo) "ObjectsCMI : " '$(ObjectsCMI)'
$(Echo) "ObjectsCMO : " '$(ObjectsCMO)'
$(Echo) "ObjectsCMX : " '$(ObjectsCMX)'
$(Echo) "OCAML_LIBDIR : " '$(OCAML_LIBDIR)'
$(Echo) "DestA : " '$(DestA)'
$(Echo) "DestCMA : " '$(DestCMA)'
$(Echo) "DestCMXA : " '$(DestCMXA)'
$(Echo) "DestSharedLib: " '$(DestSharedLib)'
$(Echo) "UsedLibs : " '$(UsedLibs)'
$(Echo) "UsedLibNames : " '$(UsedLibNames)'
$(Echo) "ExtraLibs : " '$(ExtraLibs)'
.PHONY: printcamlvars build-cmis \
clean-a clean-cmis clean-cma clean-cmxa \
install-a install-cmis install-cma install-cmxa \
install-exe \
uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa \
uninstall-exe

View File

@ -1,21 +0,0 @@
##===- bindings/ocaml/all_backends/Makefile ----------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_all_backends interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
include $(LEVEL)/Makefile.config
LIBRARYNAME := llvm_all_backends
UsedComponents := $(TARGETS_TO_BUILD)
UsedOcamlInterfaces :=
include ../Makefile.ocaml

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/analysis/Makefile --------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_analysis interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_analysis
UsedComponents := analysis
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -16,6 +16,7 @@
\*===----------------------------------------------------------------------===*/
#include "llvm-c/Analysis.h"
#include "llvm-c/Core.h"
#include "caml/alloc.h"
#include "caml/mlvalues.h"
#include "caml/memory.h"

View File

@ -1,61 +0,0 @@
##===- bindings/ocaml/backends/Makefile --------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the master makefile for backend-specific bindings. It works by
# creating a stub makefile for each configured target, e.g. Makefile.ARM, and
# invoking it to compile the corresponding library, e.g. Llvm_ARM.
#
# This scheme allows to keep changes to Makefile.ocaml minimal.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
ExtraMakefiles = $(PROJ_OBJ_DIR)/Makefile.common
include $(LEVEL)/Makefile.config
include $(LEVEL)/Makefile.common
all-local:: all-backends
clean-local:: clean-backends
install-local:: install-backends
uninstall-local:: uninstall-backends
stubs:
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(ECHO) "TARGET := $$i" > Makefile.$$i; \
$(ECHO) "include Makefile.common" >> Makefile.$$i; \
done
all-backends: stubs
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(MAKE) -f Makefile.$$i all; \
done
clean-backends: stubs
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(MAKE) -f Makefile.$$i clean; \
$(RM) -f Makefile.$$i; \
done
install-backends: stubs
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(MAKE) -f Makefile.$$i install; \
done
uninstall-backends: stubs
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(MAKE) -f Makefile.$$i uninstall; \
done
ocamldoc: stubs
$(Verb) for i in $(TARGETS_TO_BUILD); do \
$(MAKE) -f Makefile.$$i ocamldoc; \
done
.PHONY: all-backends clean-backends install-backends uninstall-backends ocamldoc

View File

@ -1,65 +0,0 @@
##===- bindings/ocaml/backends/Makefile.common -------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the slave makefile for backend-specific bindings. This makefile should
# be included after defining TARGET. It will then substitute @TARGET@ for
# the value of TARGET in various *.in files and build an OCaml library in
# a regular way.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_$(TARGET)
UsedComponents := $(TARGET)
UsedOcamlInterfaces := llvm
include $(LEVEL)/Makefile.config
SOURCES := $(TARGET)_ocaml.c
OcamlHeaders1 := $(PROJ_SRC_DIR)/llvm_$(TARGET).mli
OcamlSources1 := $(PROJ_SRC_DIR)/llvm_$(TARGET).ml
include ../Makefile.ocaml
$(ObjDir)/llvm_$(TARGET).ml: $(PROJ_SRC_DIR)/llvm_backend.ml.in $(ObjDir)/.dir
$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' $< > $@
$(ObjDir)/llvm_$(TARGET).mli: $(PROJ_SRC_DIR)/llvm_backend.mli.in $(ObjDir)/.dir
$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' $< > $@
$(ObjDir)/$(TARGET)_ocaml.o: $(PROJ_SRC_DIR)/backend_ocaml.c $(ObjDir)/.dir
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Verb) $(Compile.C) -DTARGET=$(TARGET) $< -o $@
##===- OCamlFind Package --------------------------------------------------===##
all-local:: copy-meta
install-local:: install-meta
uninstall-local:: uninstall-meta
DestMETA := $(PROJ_libocamldir)/META.llvm_$(TARGET)
# Easy way of generating META in the objdir
copy-meta: $(OcamlDir)/META.llvm_$(TARGET)
$(OcamlDir)/META.llvm_$(TARGET): META.llvm_backend.in
$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' \
-e 's/@PACKAGE_VERSION@/$(LLVMVersion)/' $< > $@
install-meta:: $(OcamlDir)/META.llvm_$(TARGET)
$(Echo) "Install $(BuildMode) $(DestMETA)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(DataInstall) $< "$(DestMETA)"
uninstall-meta::
$(Echo) "Uninstalling $(DestMETA)"
-$(Verb) $(RM) -f "$(DestMETA)"
.PHONY: copy-meta install-meta uninstall-meta

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/bitreader/Makefile -------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_bitreader interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_bitreader
UsedComponents := bitreader
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -13,6 +13,7 @@
\*===----------------------------------------------------------------------===*/
#include "llvm-c/BitReader.h"
#include "llvm-c/Core.h"
#include "caml/alloc.h"
#include "caml/fail.h"
#include "caml/memory.h"
@ -25,7 +26,7 @@ CAMLprim LLVMModuleRef llvm_get_module(LLVMContextRef C, LLVMMemoryBufferRef Mem
LLVMModuleRef M;
if (LLVMGetBitcodeModuleInContext2(C, MemBuf, &M))
llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
return M;
}
@ -35,7 +36,7 @@ CAMLprim LLVMModuleRef llvm_parse_bitcode(LLVMContextRef C, LLVMMemoryBufferRef
LLVMModuleRef M;
if (LLVMParseBitcodeInContext2(C, MemBuf, &M))
llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
return M;
}

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/bitwriter/Makefile -------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_bitwriter interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_bitwriter
UsedComponents := bitwriter
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -1,20 +0,0 @@
##===- bindings/ocaml/executionengine/Makefile -------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_executionengine interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_executionengine
UsedComponents := executionengine mcjit native
UsedOcamlInterfaces := llvm llvm_target
FindlibPackages := ctypes
include ../Makefile.ocaml

View File

@ -17,6 +17,7 @@
#include <string.h>
#include <assert.h>
#include "llvm-c/Core.h"
#include "llvm-c/ExecutionEngine.h"
#include "llvm-c/Target.h"
#include "caml/alloc.h"

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/irreader/Makefile --------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_irreader interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_irreader
UsedComponents := irreader
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/linker/Makefile ----------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_target interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_linker
UsedComponents := linker
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -15,6 +15,7 @@
|* *|
\*===----------------------------------------------------------------------===*/
#include "llvm-c/Core.h"
#include "llvm-c/Linker.h"
#include "caml/alloc.h"
#include "caml/memory.h"
@ -26,7 +27,7 @@ void llvm_raise(value Prototype, char *Message);
/* llmodule -> llmodule -> unit */
CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
if (LLVMLinkModules2(Dst, Src))
llvm_raise(*caml_named_value("Llvm_linker.Error"), "Linking failed");
llvm_raise(*caml_named_value("Llvm_linker.Error"), LLVMCreateMessage("Linking failed"));
return Val_unit;
}

View File

@ -1,43 +0,0 @@
##===- bindings/ocaml/llvm/Makefile ------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm
UsedComponents := core
UsedOcamlLibs := llvm
ExtraLibs := -lstdc++
include ../Makefile.ocaml
all-local:: copy-meta
install-local:: install-meta
uninstall-local:: uninstall-meta
DestMETA := $(PROJ_libocamldir)/META.llvm
# Easy way of generating META in the objdir
copy-meta: $(OcamlDir)/META.llvm
$(OcamlDir)/META.llvm: META.llvm
$(Verb) $(CP) -f $< $@
install-meta:: $(OcamlDir)/META.llvm
$(Echo) "Install $(BuildMode) $(DestMETA)"
$(Verb) $(MKDIR) $(PROJ_libocamldir)
$(Verb) $(DataInstall) $< "$(DestMETA)"
uninstall-meta::
$(Echo) "Uninstalling $(DestMETA)"
-$(Verb) $(RM) -f "$(DestMETA)"
.PHONY: copy-meta install-meta uninstall-meta

View File

@ -283,6 +283,14 @@ module ValueKind = struct
| Instruction of Opcode.t
end
module DiagnosticSeverity = struct
type t =
| Error
| Warning
| Remark
| Note
end
exception IoError of string
let () = Callback.register_exception "Llvm.IoError" (IoError "")
@ -304,6 +312,20 @@ type ('a, 'b) llrev_pos =
| At_start of 'a
| After of 'b
(*===-- Context error handling --------------------------------------------===*)
module Diagnostic = struct
type t
external description : t -> string = "llvm_get_diagnostic_description"
external severity : t -> DiagnosticSeverity.t
= "llvm_get_diagnostic_severity"
end
external set_diagnostic_handler
: llcontext -> (Diagnostic.t -> unit) option -> unit
= "llvm_set_diagnostic_handler"
(*===-- Contexts ----------------------------------------------------------===*)
external create_context : unit -> llcontext = "llvm_create_context"
external dispose_context : llcontext -> unit = "llvm_dispose_context"
@ -461,6 +483,8 @@ external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"
external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
external mdnull : llcontext -> llvalue = "llvm_mdnull"
external get_mdstring : llvalue -> string option = "llvm_get_mdstring"
external get_mdnode_operands : llvalue -> llvalue array
= "llvm_get_mdnode_operands"
external get_named_metadata : llmodule -> string -> llvalue array
= "llvm_get_namedmd"
external add_named_metadata_operand : llmodule -> string -> llvalue -> unit

View File

@ -15,7 +15,7 @@
(** {6 Abstract types}
These abstract types correlate directly to the LLVM VMCore classes. *)
These abstract types correlate directly to the LLVMCore classes. *)
(** The top-level container for all LLVM global data. See the
[llvm::LLVMContext] class. *)
@ -352,6 +352,16 @@ module ValueKind : sig
| Instruction of Opcode.t
end
(** The kind of [Diagnostic], the result of [Diagnostic.severity d].
See [llvm::DiagnosticSeverity]. *)
module DiagnosticSeverity : sig
type t =
| Error
| Warning
| Remark
| Note
end
(** {6 Iteration} *)
@ -398,6 +408,22 @@ val reset_fatal_error_handler : unit -> unit
See the function [llvm::cl::ParseCommandLineOptions()]. *)
val parse_command_line_options : ?overview:string -> string array -> unit
(** {6 Context error handling} *)
module Diagnostic : sig
type t
(** [description d] returns a textual description of [d]. *)
val description : t -> string
(** [severity d] returns the severity of [d]. *)
val severity : t -> DiagnosticSeverity.t
end
(** [set_diagnostic_handler c h] set the diagnostic handler of [c] to [h].
See the method [llvm::LLVMContext::setDiagnosticHandler]. *)
val set_diagnostic_handler : llcontext -> (Diagnostic.t -> unit) option -> unit
(** {6 Contexts} *)
(** [create_context ()] creates a context for storing the "global" state in
@ -408,7 +434,7 @@ val create_context : unit -> llcontext
[llvm::LLVMContext::~LLVMContext]. *)
val dispose_context : llcontext -> unit
(** See the function [llvm::getGlobalContext]. *)
(** See the function [LLVMGetGlobalContext]. *)
val global_context : unit -> llcontext
(** [mdkind_id context name] returns the MDKind ID that corresponds to the
@ -826,6 +852,10 @@ val mdnull : llcontext -> llvalue
See the method [llvm::MDString::getString] *)
val get_mdstring : llvalue -> string option
(** [get_mdnode_operands v] returns the operands in the MDNode. *)
(* See the method [llvm::MDNode::getOperand] *)
val get_mdnode_operands : llvalue -> llvalue array
(** [get_named_metadata m name] returns all the MDNodes belonging to the named
metadata (if any).
See the method [llvm::NamedMDNode::getOperand]. *)

View File

@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "llvm-c/Core.h"
#include "llvm-c/Support.h"
#include "caml/alloc.h"
#include "caml/custom.h"
#include "caml/memory.h"
@ -114,6 +115,49 @@ static value alloc_variant(int tag, void *Value) {
return alloc_variant(0, pfun(Kid)); \
}
/*===-- Context error handling --------------------------------------------===*/
void llvm_diagnostic_handler_trampoline(LLVMDiagnosticInfoRef DI,
void *DiagnosticContext) {
caml_callback(*((value *)DiagnosticContext), (value)DI);
}
/* Diagnostic.t -> string */
CAMLprim value llvm_get_diagnostic_description(value Diagnostic) {
return llvm_string_of_message(
LLVMGetDiagInfoDescription((LLVMDiagnosticInfoRef)Diagnostic));
}
/* Diagnostic.t -> DiagnosticSeverity.t */
CAMLprim value llvm_get_diagnostic_severity(value Diagnostic) {
return Val_int(LLVMGetDiagInfoSeverity((LLVMDiagnosticInfoRef)Diagnostic));
}
static void llvm_remove_diagnostic_handler(LLVMContextRef C) {
if (LLVMContextGetDiagnosticHandler(C) ==
llvm_diagnostic_handler_trampoline) {
value *Handler = (value *)LLVMContextGetDiagnosticContext(C);
remove_global_root(Handler);
free(Handler);
}
}
/* llcontext -> (Diagnostic.t -> unit) option -> unit */
CAMLprim value llvm_set_diagnostic_handler(LLVMContextRef C, value Handler) {
llvm_remove_diagnostic_handler(C);
if (Handler == Val_int(0)) {
LLVMContextSetDiagnosticHandler(C, NULL, NULL);
} else {
value *DiagnosticContext = malloc(sizeof(value));
if (DiagnosticContext == NULL)
caml_raise_out_of_memory();
caml_register_global_root(DiagnosticContext);
*DiagnosticContext = Field(Handler, 0);
LLVMContextSetDiagnosticHandler(C, llvm_diagnostic_handler_trampoline,
DiagnosticContext);
}
return Val_unit;
}
/*===-- Contexts ----------------------------------------------------------===*/
@ -124,6 +168,7 @@ CAMLprim LLVMContextRef llvm_create_context(value Unit) {
/* llcontext -> unit */
CAMLprim value llvm_dispose_context(LLVMContextRef C) {
llvm_remove_diagnostic_handler(C);
LLVMContextDispose(C);
return Val_unit;
}
@ -689,6 +734,17 @@ CAMLprim value llvm_get_mdstring(LLVMValueRef V) {
CAMLreturn(Val_int(0));
}
CAMLprim value llvm_get_mdnode_operands(LLVMValueRef V) {
CAMLparam0();
CAMLlocal1(Operands);
unsigned int n;
n = LLVMGetMDNodeNumOperands(V);
Operands = alloc(n, 0);
LLVMGetMDNodeOperands(V, (LLVMValueRef *) Operands);
CAMLreturn(Operands);
}
/* llmodule -> string -> llvalue array */
CAMLprim value llvm_get_namedmd(LLVMModuleRef M, value Name)
{

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/target/Makefile ----------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_target interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
LIBRARYNAME := llvm_target
UsedComponents := target
UsedOcamlInterfaces := llvm
include ../Makefile.ocaml

View File

@ -54,9 +54,6 @@ module DataLayout = struct
external of_string : string -> t = "llvm_datalayout_of_string"
external as_string : t -> string = "llvm_datalayout_as_string"
external add_to_pass_manager : [<Llvm.PassManager.any]
Llvm.PassManager.t -> t -> unit
= "llvm_datalayout_add_to_pass_manager"
external byte_order : t -> Endian.t = "llvm_datalayout_byte_order"
external pointer_size : t -> int = "llvm_datalayout_pointer_size"
external intptr_type : Llvm.llcontext -> t -> Llvm.lltype

View File

@ -67,12 +67,6 @@ module DataLayout : sig
See the method [llvm::DataLayout::getStringRepresentation]. *)
val as_string : t -> string
(** [add_to_pass_manager pm dl] adds the data layout [dl] to
the pass manager [pm].
See the method [llvm::PassManagerBase::add]. *)
val add_to_pass_manager : [<Llvm.PassManager.any] Llvm.PassManager.t ->
t -> unit
(** Returns the byte order of a target, either [Endian.Big] or
[Endian.Little].
See the method [llvm::DataLayout::isLittleEndian]. *)
@ -200,13 +194,13 @@ module TargetMachine : sig
[llvm::TargetMachine::getCPU]. *)
val cpu : t -> string
(** Returns the data layout of this target machine. *)
val data_layout : t -> DataLayout.t
(** Returns the feature string used while creating this target machine. See
[llvm::TargetMachine::getFeatureString]. *)
val features : t -> string
(** Returns the data layout of this target machine. *)
val data_layout : t -> DataLayout.t
(** Adds the target-specific analysis passes to the pass manager.
See [llvm::TargetMachine::addAnalysisPasses]. *)
val add_analysis_passes : [< Llvm.PassManager.any ] Llvm.PassManager.t -> t -> unit

View File

@ -15,6 +15,7 @@
|* *|
\*===----------------------------------------------------------------------===*/
#include "llvm-c/Core.h"
#include "llvm-c/Target.h"
#include "llvm-c/TargetMachine.h"
#include "caml/alloc.h"
@ -64,13 +65,6 @@ CAMLprim value llvm_datalayout_as_string(value TD) {
return Copy;
}
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> DataLayout.t -> unit */
CAMLprim value llvm_datalayout_add_to_pass_manager(LLVMPassManagerRef PM,
value DL) {
LLVMAddTargetData(DataLayout_val(DL), PM);
return Val_unit;
}
/* DataLayout.t -> Endian.t */
CAMLprim value llvm_datalayout_byte_order(value DL) {
return Val_int(LLVMByteOrder(DataLayout_val(DL)));
@ -304,21 +298,8 @@ CAMLprim value llvm_targetmachine_features(value Machine) {
/* TargetMachine.t -> DataLayout.t */
CAMLprim value llvm_targetmachine_data_layout(value Machine) {
CAMLparam1(Machine);
CAMLlocal1(DataLayout);
char *TargetDataCStr;
/* LLVMGetTargetMachineData returns a pointer owned by the TargetMachine,
so it is impossible to wrap it with llvm_alloc_target_data, which assumes
that OCaml owns the pointer. */
LLVMTargetDataRef OrigDataLayout;
OrigDataLayout = LLVMGetTargetMachineData(TargetMachine_val(Machine));
TargetDataCStr = LLVMCopyStringRepOfTargetData(OrigDataLayout);
DataLayout = llvm_alloc_data_layout(LLVMCreateTargetData(TargetDataCStr));
LLVMDisposeMessage(TargetDataCStr);
CAMLreturn(DataLayout);
return llvm_alloc_data_layout(LLVMCreateTargetDataLayout(
TargetMachine_val(Machine)));
}
/* bool -> TargetMachine.t -> unit */

View File

@ -1,18 +0,0 @@
##===- bindings/ocaml/transforms/Makefile ------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
DIRS = ipo passmgr_builder scalar_opts utils vectorize
ocamldoc:
$(Verb) for i in $(DIRS) ; do \
$(MAKE) -C $$i ocamldoc; \
done
include $(LEVEL)/Makefile.common

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/transforms/ipo/Makefile --------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_ipo interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../../..
LIBRARYNAME := llvm_ipo
UsedComponents := ipo
UsedOcamlInterfaces := llvm
include ../../Makefile.ocaml

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/transforms/passmgr_builder/Makefile --*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_passmgr_builder interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../../..
LIBRARYNAME := llvm_passmgr_builder
UsedComponents := ipo
UsedOcamlInterfaces := llvm
include ../../Makefile.ocaml

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/transforms/scalar_opts/Makefile ------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_scalar_opts interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../../..
LIBRARYNAME := llvm_scalar_opts
UsedComponents := scalaropts
UsedOcamlInterfaces := llvm
include ../../Makefile.ocaml

View File

@ -127,17 +127,17 @@ external add_sccp
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_sccp"
(** See the [llvm::createScalarReplAggregatesPass] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates"
(** See the [llvm::createScalarReplAggregatesPassSSA] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation_ssa
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates_ssa"
(** See the [llvm::createScalarReplAggregatesWithThreshold] function. *)
(** See the [llvm::createSROAPass] function. *)
external add_scalar_repl_aggregation_with_threshold
: int -> [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_scalar_repl_aggregates_with_threshold"

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/transforms/utils/Makefile ------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_vectorize interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../../..
LIBRARYNAME := llvm_transform_utils
UsedComponents := transformutils
UsedOcamlInterfaces := llvm
include ../../Makefile.ocaml

View File

@ -1,19 +0,0 @@
##===- bindings/ocaml/transforms/vectorize/Makefile --------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_vectorize interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../../..
LIBRARYNAME := llvm_vectorize
UsedComponents := vectorize
UsedOcamlInterfaces := llvm
include ../../Makefile.ocaml

View File

@ -1,12 +0,0 @@
##===- cmake/Makefile --------------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ..
DIRS := modules
include $(LEVEL)/Makefile.common

View File

@ -11,9 +11,10 @@ include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(CheckCompilerVersion)
include(HandleLLVMStdlib)
if( UNIX AND NOT BEOS )
if( UNIX AND NOT (BEOS OR HAIKU) )
# Used by check_symbol_exists:
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
@ -66,6 +67,7 @@ check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
@ -107,6 +109,16 @@ if( NOT PURE_WINDOWS )
check_library_exists(rt clock_gettime "" HAVE_LIBRT)
endif()
if(HAVE_LIBPTHREAD)
# We want to find pthreads library and at the moment we do want to
# have it reported as '-l<lib>' instead of '-pthread'.
# TODO: switch to -pthread once the rest of the build system can deal with it.
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_HAVE_PTHREAD_ARG Off)
find_package(Threads REQUIRED)
set(PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
endif()
# Don't look for these libraries on Windows. Also don't look for them if we're
# using MSan, since uninstrmented third party code may call MSan interceptors
# like strlen, leading to false positives.
@ -135,9 +147,15 @@ if( NOT PURE_WINDOWS AND NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
endif()
endif()
check_library_exists(xar xar_open "" HAVE_LIBXAR)
if(HAVE_LIBXAR)
set(XAR_LIB xar)
endif()
# function checks
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE_UNWIND_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
@ -150,6 +168,9 @@ if( HAVE_SETJMP_H )
check_symbol_exists(siglongjmp setjmp.h HAVE_SIGLONGJMP)
check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP)
endif()
if( HAVE_SIGNAL_H )
check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
endif()
if( HAVE_SYS_UIO_H )
check_symbol_exists(writev sys/uio.h HAVE_WRITEV)
endif()
@ -395,12 +416,12 @@ else ()
set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter)
# We don't have an ASM parser for all architectures yet.
if (EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/CMakeLists.txt)
if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/CMakeLists.txt)
set(LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser)
endif ()
# We don't have an disassembler for all architectures yet.
if (EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/CMakeLists.txt)
if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/CMakeLists.txt)
set(LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler)
endif ()
endif ()
@ -446,21 +467,6 @@ else()
set(HAVE_DIA_SDK 0)
endif( MSVC )
if( PURE_WINDOWS )
CHECK_CXX_SOURCE_COMPILES("
#include <windows.h>
#include <imagehlp.h>
extern \"C\" void foo(PENUMLOADED_MODULES_CALLBACK);
extern \"C\" void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID));
int main(){return 0;}"
HAVE_ELMCB_PCSTR)
if( HAVE_ELMCB_PCSTR )
set(WIN32_ELMCB_PCSTR "PCSTR")
else()
set(WIN32_ELMCB_PCSTR "PSTR")
endif()
endif( PURE_WINDOWS )
# FIXME: Signal handler return type, currently hardcoded to 'void'
set(RETSIGTYPE void)
@ -526,7 +532,7 @@ else()
if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND")
message(STATUS "Go bindings disabled.")
else()
execute_process(COMMAND ${GO_EXECUTABLE} run ${CMAKE_SOURCE_DIR}/bindings/go/conftest.go
execute_process(COMMAND ${GO_EXECUTABLE} run ${PROJECT_SOURCE_DIR}/bindings/go/conftest.go
RESULT_VARIABLE GO_CONFTEST)
if(GO_CONFTEST STREQUAL "0")
set(LLVM_BINDINGS "${LLVM_BINDINGS} go")

3
autoconf/config.guess → cmake/config.guess vendored Executable file → Normal file
View File

@ -1203,6 +1203,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*) # Haiku running on x86_64.
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;

View File

@ -8,9 +8,9 @@ function(llvm_update_compile_flags name)
set(update_src_props ON)
endif()
# LLVM_REQUIRES_EH is an internal flag that individual
# targets can use to force EH
if((LLVM_REQUIRES_EH OR LLVM_ENABLE_EH) AND NOT CLANG_CL)
# LLVM_REQUIRES_EH is an internal flag that individual targets can use to
# force EH
if(LLVM_REQUIRES_EH OR LLVM_ENABLE_EH)
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
@ -328,11 +328,13 @@ endfunction(set_windows_version_resource_properties)
# May specify header files for IDE generators.
# SONAME
# Should set SONAME link flags and create symlinks
# PLUGIN_TOOL
# The tool (i.e. cmake target) that this plugin will link against
# )
function(llvm_add_library name)
cmake_parse_arguments(ARG
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
"OUTPUT_NAME"
"OUTPUT_NAME;PLUGIN_TOOL"
"ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
${ARGN})
list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
@ -350,11 +352,15 @@ function(llvm_add_library name)
if(ARG_SHARED OR ARG_STATIC)
message(WARNING "MODULE with SHARED|STATIC doesn't make sense.")
endif()
if(NOT LLVM_ENABLE_PLUGINS)
# Plugins that link against a tool are allowed even when plugins in general are not
if(NOT LLVM_ENABLE_PLUGINS AND NOT (ARG_PLUGIN_TOOL AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS))
message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
return()
endif()
else()
if(ARG_PLUGIN_TOOL)
message(WARNING "PLUGIN_TOOL without MODULE doesn't make sense.")
endif()
if(BUILD_SHARED_LIBS AND NOT ARG_STATIC)
set(ARG_SHARED TRUE)
endif()
@ -468,7 +474,10 @@ function(llvm_add_library name)
endif()
endif()
if (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS)
if(ARG_MODULE AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS AND ARG_PLUGIN_TOOL AND (WIN32 OR CYGWIN))
# On DLL platforms symbols are imported from the tool by linking against it.
set(llvm_libs ${ARG_PLUGIN_TOOL})
elseif (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS)
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
@ -487,27 +496,18 @@ function(llvm_add_library name)
get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
endif()
if(CMAKE_VERSION VERSION_LESS 2.8.12)
# Link libs w/o keywords, assuming PUBLIC.
target_link_libraries(${name}
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
elseif(ARG_STATIC)
target_link_libraries(${name} INTERFACE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
if(ARG_STATIC)
set(libtype INTERFACE)
else()
# We can use PRIVATE since SO knows its dependent libs.
target_link_libraries(${name} PRIVATE
set(libtype PRIVATE)
endif()
target_link_libraries(${name} ${libtype}
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
endif()
if(LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
@ -670,10 +670,78 @@ macro(add_llvm_executable name)
if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO)
llvm_externalize_debuginfo(${name})
endif()
if (PTHREAD_LIB)
# libpthreads overrides some standard library symbols, so main
# executable must be linked with it in order to provide consistent
# API for all shared libaries loaded by this executable.
target_link_libraries(${name} ${PTHREAD_LIB})
endif()
endmacro(add_llvm_executable name)
function(export_executable_symbols target)
if (NOT MSVC) # MSVC's linker doesn't support exporting all symbols.
if (LLVM_EXPORTED_SYMBOL_FILE)
# The symbol file should contain the symbols we want the executable to
# export
set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
elseif (LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
# Extract the symbols to export from the static libraries that the
# executable links against.
set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
set(exported_symbol_file ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target}.symbols)
# We need to consider not just the direct link dependencies, but also the
# transitive link dependencies. Do this by starting with the set of direct
# dependencies, then the dependencies of those dependencies, and so on.
get_target_property(new_libs ${target} LINK_LIBRARIES)
set(link_libs ${new_libs})
while(NOT "${new_libs}" STREQUAL "")
foreach(lib ${new_libs})
if(TARGET ${lib})
get_target_property(lib_type ${lib} TYPE)
if("${lib_type}" STREQUAL "STATIC_LIBRARY")
list(APPEND static_libs ${lib})
else()
list(APPEND other_libs ${lib})
endif()
get_target_property(transitive_libs ${lib} INTERFACE_LINK_LIBRARIES)
foreach(transitive_lib ${transitive_libs})
list(FIND link_libs ${transitive_lib} idx)
if(TARGET ${transitive_lib} AND idx EQUAL -1)
list(APPEND newer_libs ${transitive_lib})
list(APPEND link_libs ${transitive_lib})
endif()
endforeach(transitive_lib)
endif()
endforeach(lib)
set(new_libs ${newer_libs})
set(newer_libs "")
endwhile()
if (MSVC)
set(mangling microsoft)
else()
set(mangling itanium)
endif()
add_custom_command(OUTPUT ${exported_symbol_file}
COMMAND ${PYTHON_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/extract_symbols.py --mangling=${mangling} ${static_libs} -o ${exported_symbol_file}
WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
DEPENDS ${LLVM_MAIN_SRC_DIR}/utils/extract_symbols.py ${static_libs}
VERBATIM
COMMENT "Generating export list for ${target}")
add_llvm_symbol_exports( ${target} ${exported_symbol_file} )
# If something links against this executable then we want a
# transitive link against only the libraries whose symbols
# we aren't exporting.
set_target_properties(${target} PROPERTIES INTERFACE_LINK_LIBRARIES "${other_libs}")
# The default import library suffix that cmake uses for cygwin/mingw is
# ".dll.a", but for clang.exe that causes a collision with libclang.dll,
# where the import libraries of both get named libclang.dll.a. Use a suffix
# of ".exe.a" to avoid this.
if(CYGWIN OR MINGW)
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".exe.a")
endif()
elseif(NOT (WIN32 OR CYGWIN))
# On Windows auto-exporting everything doesn't work because of the limit on
# the size of the exported symbol table, but on other platforms we can do
# it without any trouble.
set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
if (APPLE)
set_property(TARGET ${target} APPEND_STRING PROPERTY
@ -702,7 +770,7 @@ macro(add_llvm_tool name)
if( LLVM_BUILD_TOOLS )
install(TARGETS ${name}
EXPORT LLVMExports
RUNTIME DESTINATION bin
RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR}
COMPONENT ${name})
if (NOT CMAKE_CONFIGURATION_TYPES)
@ -732,11 +800,16 @@ macro(add_llvm_example name)
set_target_properties(${name} PROPERTIES FOLDER "Examples")
endmacro(add_llvm_example name)
# This is a macro that is used to create targets for executables that are needed
# for development, but that are not intended to be installed by default.
macro(add_llvm_utility name)
if ( NOT LLVM_BUILD_UTILS )
set(EXCLUDE_FROM_ALL ON)
endif()
add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
set_target_properties(${name} PROPERTIES FOLDER "Utils")
if( LLVM_INSTALL_UTILS )
if( LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS )
install (TARGETS ${name}
RUNTIME DESTINATION bin
COMPONENT ${name})
@ -767,8 +840,8 @@ function(canonicalize_tool_name name output)
endfunction(canonicalize_tool_name)
# Custom add_subdirectory wrapper
# Takes in a project name (i.e. LLVM), the the subdirectory name, and an
# and an optional path if it differs from the name.
# Takes in a project name (i.e. LLVM), the subdirectory name, and an optional
# path if it differs from the name.
macro(add_llvm_subdirectory project type name)
set(add_llvm_external_dir "${ARGN}")
if("${add_llvm_external_dir}" STREQUAL "")
@ -850,13 +923,13 @@ function(create_llvm_tool_options)
create_subdirectory_options(LLVM TOOL)
endfunction(create_llvm_tool_options)
function(add_llvm_implicit_projects)
function(llvm_add_implicit_projects project)
set(list_of_implicit_subdirs "")
file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
foreach(dir ${sub-dirs})
if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
canonicalize_tool_name(${dir} name)
if (LLVM_TOOL_${name}_BUILD)
if (${project}_TOOL_${name}_BUILD)
get_filename_component(fn "${dir}" NAME)
list(APPEND list_of_implicit_subdirs "${fn}")
endif()
@ -864,8 +937,12 @@ function(add_llvm_implicit_projects)
endforeach()
foreach(external_proj ${list_of_implicit_subdirs})
add_llvm_external_project("${external_proj}")
add_llvm_subdirectory(${project} TOOL "${external_proj}" ${ARGN})
endforeach()
endfunction(llvm_add_implicit_projects)
function(add_llvm_implicit_projects)
llvm_add_implicit_projects(LLVM)
endfunction(add_llvm_implicit_projects)
# Generic support for adding a unittest.
@ -889,7 +966,10 @@ function(add_unittest test_suite test_name)
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO ${ARGN})
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
target_link_libraries(${test_name} gtest_main gtest)
# libpthreads overrides some standard library symbols, so main
# executable must be linked with it in order to provide consistent
# API for all shared libaries loaded by this executable.
target_link_libraries(${test_name} gtest_main gtest ${PTHREAD_LIB})
add_dependencies(${test_suite} ${test_name})
get_target_property(test_suite_folder ${test_suite} FOLDER)
@ -913,13 +993,8 @@ function(llvm_add_go_executable binary pkgpath)
set(cppflags "${cppflags} -I${d}")
endforeach(d)
set(ldflags "${CMAKE_EXE_LINKER_FLAGS}")
if (LLVM_LINK_LLVM_DYLIB)
set(linkmode "dylib")
else()
set(linkmode "component-libs")
endif()
add_custom_command(OUTPUT ${binpath}
COMMAND ${CMAKE_BINARY_DIR}/bin/llvm-go "go=${GO_EXECUTABLE}" "cc=${cc}" "cxx=${cxx}" "cppflags=${cppflags}" "ldflags=${ldflags}" "linkmode=${linkmode}"
COMMAND ${CMAKE_BINARY_DIR}/bin/llvm-go "go=${GO_EXECUTABLE}" "cc=${cc}" "cxx=${cxx}" "cppflags=${cppflags}" "ldflags=${ldflags}"
${ARG_GOFLAGS} build -o ${binpath} ${pkgpath}
DEPENDS llvm-config ${CMAKE_BINARY_DIR}/bin/llvm-go${CMAKE_EXECUTABLE_SUFFIX}
${llvmlibs} ${ARG_DEPENDS}
@ -984,6 +1059,8 @@ function(configure_lit_site_cfg input output)
set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!")
configure_file(${input} ${output} @ONLY)
endfunction()
@ -1009,7 +1086,7 @@ function(add_lit_target target comment)
add_custom_target(${target}
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
COMMENT "${comment}"
${cmake_3_2_USES_TERMINAL}
USES_TERMINAL
)
else()
add_custom_target(${target}
@ -1049,21 +1126,27 @@ endfunction()
function(add_lit_testsuites project directory)
if (NOT CMAKE_CONFIGURATION_TYPES)
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
file(GLOB_RECURSE litCfg ${directory}/lit*.cfg)
set(lit_suites)
foreach(f ${litCfg})
get_filename_component(dir ${f} DIRECTORY)
set(lit_suites ${lit_suites} ${dir})
endforeach()
list(REMOVE_DUPLICATES lit_suites)
foreach(dir ${lit_suites})
string(REPLACE ${directory} "" name_slash ${dir})
# Search recursively for test directories by assuming anything not
# in a directory called Inputs contains tests.
file(GLOB_RECURSE to_process LIST_DIRECTORIES true ${directory}/*)
foreach(lit_suite ${to_process})
if(NOT IS_DIRECTORY ${lit_suite})
continue()
endif()
string(FIND ${lit_suite} Inputs is_inputs)
if (NOT is_inputs EQUAL -1)
continue()
endif()
# Create a check- target for the directory.
string(REPLACE ${directory} "" name_slash ${lit_suite})
if (name_slash)
string(REPLACE "/" "-" name_slash ${name_slash})
string(REPLACE "\\" "-" name_dashes ${name_slash})
string(TOLOWER "${project}${name_dashes}" name_var)
add_lit_target("check-${name_var}" "Running lit suite ${dir}"
${dir}
add_lit_target("check-${name_var}" "Running lit suite ${lit_suite}"
${lit_suite}
PARAMS ${ARG_PARAMS}
DEPENDS ${ARG_DEPENDS}
ARGS ${ARG_ARGS}
@ -1127,7 +1210,7 @@ function(llvm_install_symlink name dest)
set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
install(SCRIPT ${INSTALL_SYMLINK}
CODE "install_symlink(${full_name} ${full_dest} bin)"
CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
COMPONENT ${component})
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
@ -1186,6 +1269,10 @@ function(llvm_externalize_debuginfo name)
return()
endif()
if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP)
set(strip_command COMMAND xcrun strip -Sxl $<TARGET_FILE:${name}>)
endif()
if(APPLE)
if(CMAKE_CXX_FLAGS MATCHES "-flto"
OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
@ -1196,7 +1283,8 @@ function(llvm_externalize_debuginfo name)
endif()
add_custom_command(TARGET ${name} POST_BUILD
COMMAND xcrun dsymutil $<TARGET_FILE:${name}>
COMMAND xcrun strip -Sl $<TARGET_FILE:${name}>)
${strip_command}
)
else()
message(FATAL_ERROR "LLVM_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
endif()

View File

@ -73,7 +73,13 @@ function(add_ocaml_library name)
get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
foreach(system_lib ${system_libs})
list(APPEND ocaml_flags "-l${system_lib}" )
if (system_lib MATCHES "^-")
# If it's an option, pass it without changes.
list(APPEND ocaml_flags "${system_lib}" )
else()
# Otherwise assume it's a library name we need to link with.
list(APPEND ocaml_flags "-l${system_lib}" )
endif()
endforeach()
string(REPLACE ";" " " ARG_CFLAGS "${ARG_CFLAGS}")

View File

@ -1,4 +1,4 @@
set(LLVM_INSTALL_PACKAGE_DIR share/llvm/cmake)
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
@ -29,6 +29,7 @@ set(LLVM_CONFIG_LIBRARY_DIRS
"${LLVM_LIBRARY_DIR}"
)
set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}")
set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake")
configure_file(
@ -60,6 +61,7 @@ endforeach(p)
set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
configure_file(
@ -90,6 +92,5 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
PATTERN LLVMConfigVersion.cmake EXCLUDE
PATTERN LLVM-Config.cmake EXCLUDE
PATTERN GetHostTriple.cmake EXCLUDE
PATTERN VersionFromVCS.cmake EXCLUDE
PATTERN CheckAtomic.cmake EXCLUDE)
endif()

View File

@ -18,6 +18,22 @@ int main() {
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics)
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}")
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics64)
# This isn't necessary on MSVC, so avoid command-line switch annoyance
# by only running on GCC-like hosts.
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
@ -38,6 +54,27 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif()
# Check for 64 bit atomic operations.
if(MSVC)
set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True)
else()
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
endif()
# If not, check if the library exists, and atomics work with it.
if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if(HAVE_CXX_LIBATOMICS64)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!")
endif()
else()
message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
endif()
endif()
## TODO: This define is only used for the legacy atomic operations in
## llvm's Atomic.h, which should be replaced. Other code simply
## assumes C++11 <atomic> works.

View File

@ -0,0 +1,52 @@
# Check if the host compiler is new enough. LLVM requires at least GCC 4.7,
# MSVC 2013, or Clang 3.1.
include(CheckCXXSourceCompiles)
if(NOT DEFINED LLVM_COMPILER_CHECKED)
set(LLVM_COMPILER_CHECKED ON)
if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "Host GCC version must be at least 4.7!")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
endif()
set(CLANG_CL 1)
elseif(NOT LLVM_ENABLE_LIBCXX)
# Otherwise, test that we aren't using too old of a version of libstdc++
# with the Clang compiler. This is tricky as there is no real way to
# check the version of libstdc++ directly. Instead we test for a known
# bug in libstdc++4.6 that is fixed in libstdc++4.7.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
check_cxx_source_compiles("
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }"
LLVM_NO_OLD_LIBSTDCXX)
if(NOT LLVM_NO_OLD_LIBSTDCXX)
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Visual Studio must be at least 2013")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.31101)
message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
" due to miscompiles from earlier versions")
endif()
endif()
endif()
endif()

View File

@ -1,4 +1,4 @@
function(llvm_create_cross_target_internal target_name toochain buildtype)
function(llvm_create_cross_target_internal target_name toolchain buildtype)
if(NOT DEFINED LLVM_${target_name}_BUILD)
set(LLVM_${target_name}_BUILD "${CMAKE_BINARY_DIR}/${target_name}")

View File

@ -0,0 +1,39 @@
# CMake project that writes Subversion revision information to a header.
#
# Input variables:
# SRC - Source directory
# HEADER_FILE - The header file to write
#
# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
# "SECOND" are substituted with the names specified in the input variables.
# Chop off cmake/modules/GetSVN.cmake
get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${LLVM_DIR}/cmake/modules")
include(VersionFromVCS)
# Handle strange terminals
set(ENV{TERM} "dumb")
function(append_info name path)
add_version_info_from_vcs(REVISION ${path})
string(STRIP "${REVISION}" REVISION)
file(APPEND "${HEADER_FILE}.txt"
"#define ${name} \"${REVISION}\"\n")
endfunction()
append_info(${NAME} "${SOURCE_DIR}")
# Copy the file only if it has changed.
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${HEADER_FILE}.txt" "${HEADER_FILE}")
file(REMOVE "${HEADER_FILE}.txt")

View File

@ -15,7 +15,7 @@ function( get_host_triple var )
set( value "i686-pc-mingw32" )
endif()
else( MSVC )
set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess)
set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
execute_process(COMMAND sh ${config_guess}
RESULT_VARIABLE TT_RV
OUTPUT_VARIABLE TT_OUT

View File

@ -6,53 +6,19 @@
# else.
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
include(CheckCompilerVersion)
include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "Host GCC version must be at least 4.7!")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
endif()
set(CLANG_CL 1)
elseif(NOT LLVM_ENABLE_LIBCXX)
# Otherwise, test that we aren't using too old of a version of libstdc++
# with the Clang compiler. This is tricky as there is no real way to
# check the version of libstdc++ directly. Instead we test for a known
# bug in libstdc++4.6 that is fixed in libstdc++4.7.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
check_cxx_source_compiles("
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }"
LLVM_NO_OLD_LIBSTDCXX)
if(NOT LLVM_NO_OLD_LIBSTDCXX)
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Visual Studio must be at least 2013")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.31101)
message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
" due to miscompiles from earlier versions")
endif()
endif()
if (CMAKE_LINKER MATCHES "lld-link.exe")
# Pass /MANIFEST:NO so that CMake doesn't run mt.exe on our binaries. Adding
# manifests with mt.exe breaks LLD's symbol tables and takes as much time as
# the link. See PR24476.
append("/MANIFEST:NO"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
if( LLVM_ENABLE_ASSERTIONS )
@ -78,6 +44,11 @@ if( LLVM_ENABLE_ASSERTIONS )
endif()
endif()
if(LLVM_ENABLE_EXPENSIVE_CHECKS)
add_definitions(-DEXPENSIVE_CHECKS)
add_definitions(-D_GLIBCXX_DEBUG)
endif()
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" )
@ -195,7 +166,8 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
# TODO: support other platforms and toolchains.
if( LLVM_BUILD_32_BITS )
message(STATUS "Building 32 bits executables and libraries.")
add_llvm_definitions( -m32 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")
@ -255,14 +227,12 @@ if( MSVC )
include(ChooseMSVCCRT)
if( NOT (${CMAKE_VERSION} VERSION_LESS 2.8.11) )
# set stack reserved size to ~10MB
# CMake previously automatically set this value for MSVC builds, but the
# behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
# value (1 MB) which is not enough for us in tasks such as parsing recursive
# C++ templates in Clang.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
endif()
# set stack reserved size to ~10MB
# CMake previously automatically set this value for MSVC builds, but the
# behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
# value (1 MB) which is not enough for us in tasks such as parsing recursive
# C++ templates in Clang.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
if( MSVC11 )
add_llvm_definitions(-D_VARIADIC_MAX=10)
@ -279,6 +249,12 @@ if( MSVC )
-D_SCL_SECURE_NO_WARNINGS
)
# Tell MSVC to use the Unicode version of the Win32 APIs instead of ANSI.
add_llvm_definitions(
-DUNICODE
-D_UNICODE
)
set(msvc_warning_flags
# Disabled warnings.
-wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
@ -320,6 +296,7 @@ if( MSVC )
# C4592 is disabled because of false positives in Visual Studio 2015
# Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
-wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
-wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
# Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
# support the 'aligned' attribute in the way that clang sources requires (for
@ -328,7 +305,7 @@ if( MSVC )
# When we switch to requiring a version of MSVC that supports the 'alignas'
# specifier (MSVC 2015?) this warning can be re-enabled.
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
# Promoted warnings.
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
@ -363,17 +340,32 @@ if( MSVC )
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# /Zc:strictStrings is incompatible with VS12's (Visual Studio 2013's)
# debug mode headers. Instead of only enabling them in VS2013's debug mode,
# we'll just enable them for Visual Studio 2015 (VS 14, MSVC_VERSION 1900)
# and up.
if (NOT (MSVC_VERSION LESS 1900))
# Disable string literal const->non-const type conversion.
# "When specified, the compiler requires strict const-qualification
# conformance for pointers initialized by using string literals."
append("/Zc:strictStrings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif(NOT (MSVC_VERSION LESS 1900))
# "Generate Intrinsic Functions".
append("/Oi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# "Enforce type conversion rules".
append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# clang-cl and cl by default produce non-deterministic binaries because
# link.exe /incremental requires a timestamp in the .obj file. clang-cl
# has the flag /Brepro to force deterministic binaries, so pass that when
# LLVM_ENABLE_TIMESTAMPS is turned off.
# has the flag /Brepro to force deterministic binaries. We want to pass that
# whenever you're building with clang unless you're passing /incremental.
# This checks CMAKE_CXX_COMPILER_ID in addition to check_cxx_compiler_flag()
# because cl.exe does not emit an error on flags it doesn't understand,
# letting check_cxx_compiler_flag() claim it understands all flags.
check_cxx_compiler_flag("/Brepro" SUPPORTS_BREPRO)
append_if(SUPPORTS_BREPRO "/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (SUPPORTS_BREPRO)
# Check if /INCREMENTAL is passed to the linker and complain that it
# won't work with /Brepro.
@ -381,14 +373,13 @@ if( MSVC )
string(TOUPPER "${CMAKE_MODULE_LINKER_FLAGS}" upper_module_flags)
string(TOUPPER "${CMAKE_SHARED_LINKER_FLAGS}" upper_shared_flags)
string(FIND "${upper_exe_flags}" "/INCREMENTAL" exe_index)
string(FIND "${upper_module_flags}" "/INCREMENTAL" module_index)
string(FIND "${upper_shared_flags}" "/INCREMENTAL" shared_index)
string(FIND "${upper_exe_flags} ${upper_module_flags} ${upper_shared_flags}"
"/INCREMENTAL" linker_flag_idx)
if (${exe_index} GREATER -1 OR
${module_index} GREATER -1 OR
${shared_index} GREATER -1)
message(FATAL_ERROR "LLVM_ENABLE_TIMESTAMPS not compatible with /INCREMENTAL linking")
if (${linker_flag_idx} GREATER -1)
message(WARNING "/Brepro not compatible with /INCREMENTAL linking - builds will be non-deterministic")
else()
append("/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif()
endif()
@ -454,9 +445,7 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
endif()
endif (LLVM_ENABLE_WARNINGS)
append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT LLVM_ENABLE_TIMESTAMPS)
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
endif ()
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
if (LLVM_ENABLE_CXX1Y)
check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
@ -476,7 +465,21 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
endif()
if (LLVM_ENABLE_MODULES)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules")
set(module_flags "-fmodules -fmodules-cache-path=module.cache")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# On Darwin -fmodules does not imply -fcxx-modules.
set(module_flags "${module_flags} -fcxx-modules")
endif()
if (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
set(module_flags "${module_flags} -Xclang -fmodules-local-submodule-visibility")
endif()
if (LLVM_ENABLE_MODULE_DEBUGGING AND
((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR
(uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")))
set(module_flags "${module_flags} -gmodules")
endif()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${module_flags}")
# Check that we can build code with modules enabled, and that repeatedly
# including <cassert> still manages to respect NDEBUG properly.
CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
@ -487,8 +490,7 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
CXX_SUPPORTS_MODULES)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
if (CXX_SUPPORTS_MODULES)
append_if(CXX_SUPPORTS_MODULES "-fmodules" CMAKE_C_FLAGS)
append_if(CXX_SUPPORTS_MODULES "-fmodules -fcxx-modules" CMAKE_CXX_FLAGS)
append("${module_flags}" CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
endif()
@ -514,10 +516,6 @@ macro(append_common_sanitizer_flags)
if (CMAKE_LINKER MATCHES "lld-link.exe")
# Use DWARF debug info with LLD.
append("-gdwarf" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Pass /MANIFEST:NO so that CMake doesn't run mt.exe on our binaries.
# Adding manifests with mt.exe breaks LLD's symbol tables. See PR24476.
append("/MANIFEST:NO"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
else()
# Enable codeview otherwise.
append("/Z7" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
@ -580,7 +578,7 @@ add_llvm_definitions( -D__STDC_LIMIT_MACROS )
# clang doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND
CMAKE_GENERATOR STREQUAL "Ninja")
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
@ -602,15 +600,6 @@ if(NOT CYGWIN AND NOT WIN32)
endif()
endif()
if(CYGWIN OR MINGW)
# Prune --out-implib from executables. It doesn't make sense even
# with --export-all-symbols.
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
endif()
if(MSVC)
# Remove flags here, for exceptions and RTTI.
# Each target property or source property should be responsible to control
@ -629,12 +618,46 @@ endif()
option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation (experimental)" Off)
mark_as_advanced(LLVM_BUILD_INSTRUMENTED)
append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate"
append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation (experimental)" Off)
mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)
append_if(LLVM_BUILD_INSTRUMENTED_COVERAGE "-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}' -fcoverage-mapping"
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
set(LLVM_ENABLE_LTO OFF CACHE STRING "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO")
string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
append("-flto=thin" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
elseif(uppercase_LLVM_ENABLE_LTO STREQUAL "FULL")
append("-flto=full" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
elseif(LLVM_ENABLE_LTO)
append("-flto" CMAKE_CXX_FLAGS CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
# This option makes utils/extract_symbols.py be used to determine the list of
# symbols to export from LLVM tools. This is necessary when using MSVC if you
# want to allow plugins, though note that the plugin has to explicitly link
# against (exactly one) tool so we can't unilaterally turn on
# LLVM_ENABLE_PLUGINS when it's enabled.
option(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS "Export symbols from LLVM tools so that plugins can import them" OFF)
if(BUILD_SHARED_LIBS AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
message(FATAL_ERROR "BUILD_SHARED_LIBS not compatible with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS")
endif()
if(LLVM_LINK_LLVM_DYLIB AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
message(FATAL_ERROR "LLVM_LINK_LLVM_DYLIB not compatible with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS")
endif()
# Plugin support
# FIXME: Make this configurable.
if(WIN32 OR CYGWIN)

View File

@ -7,6 +7,8 @@ set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
set(LLVM_VERSION_PATCH @LLVM_VERSION_PATCH@)
set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
set(LLVM_BUILD_TYPE @CMAKE_BUILD_TYPE@)
set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)
@ -39,7 +41,10 @@ set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
set(LLVM_BUILD_32_BITS @LLVM_BUILD_32_BITS@)
set(LLVM_ENABLE_PLUGINS @LLVM_ENABLE_PLUGINS@)
set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS @LLVM_EXPORT_SYMBOLS_FOR_PLUGINS@)
set(LLVM_PLUGIN_EXT @LLVM_PLUGIN_EXT@)
set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
@ -49,11 +54,15 @@ set(LLVM_LIBDIR_SUFFIX @LLVM_LIBDIR_SUFFIX@)
set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
set(LLVM_LIBRARY_DIR "@LLVM_CONFIG_LIBRARY_DIRS@")
set(LLVM_DEFINITIONS "@LLVM_DEFINITIONS@")
set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@")
set(LLVM_BINARY_DIR "@LLVM_CONFIG_BINARY_DIR@")
set(LLVM_TOOLS_BINARY_DIR "@LLVM_CONFIG_TOOLS_BINARY_DIR@")
set(LLVM_TOOLS_INSTALL_DIR "@LLVM_TOOLS_INSTALL_DIR@")
if(NOT TARGET LLVMSupport)
set(LLVM_EXPORTED_TARGETS "@LLVM_EXPORTS@")
include("@LLVM_CONFIG_EXPORTS_FILE@")
endif()

View File

@ -2,12 +2,12 @@ include(ExternalProject)
# llvm_ExternalProject_BuildCmd(out_var target)
# Utility function for constructing command lines for external project targets
function(llvm_ExternalProject_BuildCmd out_var target)
function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
if (CMAKE_GENERATOR MATCHES "Make")
# Use special command for Makefiles to support parallelism.
set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
set(${out_var} "$(MAKE)" "-C" "${BINARY_DIR}" "${target}" PARENT_SCOPE)
else()
set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
set(${out_var} ${CMAKE_COMMAND} --build ${bin_dir} --target ${target}
--config $<CONFIGURATION> PARENT_SCOPE)
endif()
endfunction()
@ -19,6 +19,8 @@ endfunction()
# Exclude this project from the all target
# NO_INSTALL
# Don't generate install targets for this project
# ALWAYS_CLEAN
# Always clean the sub-project before building
# CMAKE_ARGS arguments...
# Optional cmake arguments to pass when configuring the project
# TOOLCHAIN_TOOLS targets...
@ -27,11 +29,15 @@ endfunction()
# Targets that this project depends on
# EXTRA_TARGETS targets...
# Extra targets in the subproject to generate targets for
# PASSTHROUGH_PREFIXES prefix...
# Extra variable prefixes (name is always included) to pass down
# )
function(llvm_ExternalProject_Add name source_dir)
cmake_parse_arguments(ARG "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL"
cmake_parse_arguments(ARG
"USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
"SOURCE_DIR"
"CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS" ${ARGN})
"CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES"
${ARGN})
canonicalize_tool_name(${name} nameCanon)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang lld)
@ -52,6 +58,10 @@ function(llvm_ExternalProject_Add name source_dir)
endif()
endforeach()
if(ARG_ALWAYS_CLEAN)
set(always_clean clean)
endif()
list(FIND TOOLCHAIN_TOOLS clang FOUND_CLANG)
if(FOUND_CLANG GREATER -1)
set(CLANG_IN_TOOLCHAIN On)
@ -61,23 +71,6 @@ function(llvm_ExternalProject_Add name source_dir)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
set(cmake_3_1_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL 1)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
set(cmake_3_4_USES_TERMINAL_OPTIONS
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
)
set(cmake_3_4_USES_TERMINAL USES_TERMINAL 1)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.1.20141116)
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-stamps/)
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-bins/)
@ -85,18 +78,21 @@ function(llvm_ExternalProject_Add name source_dir)
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
COMMENT "Clobbering ${name} build and stamp directories"
${cmake_3_2_USES_TERMINAL}
USES_TERMINAL
)
# Find all variables that start with COMPILER_RT and populate a variable with
# them.
# Find all variables that start with a prefix and propagate them through
get_cmake_property(variableNames VARIABLES)
foreach(variableName ${variableNames})
if(variableName MATCHES "^${nameCanon}")
string(REPLACE ";" "\;" value "${${variableName}}")
list(APPEND PASSTHROUGH_VARIABLES
-D${variableName}=${value})
endif()
list(APPEND ARG_PASSTHROUGH_PREFIXES ${nameCanon})
foreach(prefix ${ARG_PASSTHROUGH_PREFIXES})
foreach(variableName ${variableNames})
if(variableName MATCHES "^${prefix}")
string(REPLACE ";" "\;" value "${${variableName}}")
list(APPEND PASSTHROUGH_VARIABLES
-D${variableName}=${value})
endif()
endforeach()
endforeach()
if(ARG_USE_TOOLCHAIN)
@ -120,7 +116,7 @@ function(llvm_ExternalProject_Add name source_dir)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
if(ARG_EXCLUDE_FROM_ALL)
set(exclude ${cmake_3_1_EXCLUDE_FROM_ALL})
set(exclude EXCLUDE_FROM_ALL 1)
endif()
ExternalProject_Add(${name}
@ -134,33 +130,35 @@ function(llvm_ExternalProject_Add name source_dir)
CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS}
${compiler_args}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR}
-DLLVM_CONFIG_PATH=$<TARGET_FILE:llvm-config>
-DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${ARG_CMAKE_ARGS}
${PASSTHROUGH_VARIABLES}
INSTALL_COMMAND ""
STEP_TARGETS configure build
${cmake_3_4_USES_TERMINAL_OPTIONS}
BUILD_ALWAYS 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
)
if(ARG_USE_TOOLCHAIN)
ExternalProject_Add_Step(${name} force-rebuild
COMMENT "Forcing rebuild becaues tools have changed"
DEPENDERS configure
DEPENDS ${TOOLCHAIN_BINS}
${cmake_3_4_USES_TERMINAL} )
endif()
if(ARG_USE_TOOLCHAIN)
set(force_deps DEPENDS ${TOOLCHAIN_BINS})
endif()
llvm_ExternalProject_BuildCmd(run_clean clean)
llvm_ExternalProject_BuildCmd(run_clean clean ${BINARY_DIR})
ExternalProject_Add_Step(${name} clean
COMMAND ${run_clean}
COMMENT "Cleaning ${name}..."
DEPENDEES configure
${force_deps}
WORKING_DIRECTORY ${BINARY_DIR}
${cmake_3_4_USES_TERMINAL}
EXCLUDE_FROM_MAIN 1
USES_TERMINAL 1
)
ExternalProject_Add_StepTargets(${name} clean)
@ -179,17 +177,17 @@ function(llvm_ExternalProject_Add name source_dir)
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
${cmake_3_2_USES_TERMINAL})
USES_TERMINAL)
endif()
# Add top-level targets
foreach(target ${ARG_EXTRA_TARGETS})
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target})
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target} ${BINARY_DIR})
add_custom_target(${target}
COMMAND ${build_runtime_cmd}
DEPENDS ${name}-configure
WORKING_DIRECTORY ${BINARY_DIR}
VERBATIM
${cmake_3_2_USES_TERMINAL})
USES_TERMINAL)
endforeach()
endfunction()

View File

@ -1,151 +0,0 @@
##===- cmake/modules/Makefile ------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../..
include $(LEVEL)/Makefile.common
PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
ifeq ($(DISABLE_ASSERTIONS),1)
LLVM_ENABLE_ASSERTIONS := 0
else
LLVM_ENABLE_ASSERTIONS := 1
endif
ifeq ($(ENABLE_ABI_BREAKING_CHECKS),1)
LLVM_ABI_BREAKING_CHECKS := FORCE_ON
else
LLVM_ABI_BREAKING_CHECKS := FORCE_OFF
endif
ifeq ($(REQUIRES_EH),1)
LLVM_ENABLE_EH := 1
else
LLVM_ENABLE_EH := 0
endif
ifeq ($(REQUIRES_RTTI),1)
LLVM_ENABLE_RTTI := 1
else
LLVM_ENABLE_RTTI := 0
endif
ifndef LLVM_LIBS_TO_EXPORT
$(error LLVM_LIBS_TO_EXPORT cannot be empty)
endif
OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
LLVM_CONFIG_CODE := \
\# Compute the CMake directory from the LLVMConfig.cmake file location.\n\
get_filename_component(_LLVM_CMAKE_DIR "$${CMAKE_CURRENT_LIST_FILE}" PATH)\n\
\# Compute the installation prefix from the LLVMConfig.cmake file location.\n\
get_filename_component(LLVM_INSTALL_PREFIX "$${CMAKE_CURRENT_LIST_FILE}" PATH)\n
# Compute number of levels (typically 3 - ``share/llvm/cmake/``) to PROJ_prefix
# from PROJ_cmake, then emit the appropriate number of calls to
# get_filename_components(). Note this assumes there are no spaces in the
# cmake_path_suffix variable.
cmake_path_suffix := $(subst $(PROJ_prefix),,$(subst $(DESTDIR),,$(PROJ_cmake)))
cmake_path_dirs := $(subst /, ,$(cmake_path_suffix))
LLVM_CONFIG_CODE += $(foreach __not_used,$(cmake_path_dirs),get_filename_component(LLVM_INSTALL_PREFIX "$${LLVM_INSTALL_PREFIX}" PATH)\n)
LLVM_CONFIG_CODE += set(_LLVM_LIBRARY_DIR "$${LLVM_INSTALL_PREFIX}\/lib")
$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in Makefile $(LLVMBuildCMakeFrag)
$(Echo) 'Generating LLVM CMake package config file'
$(Verb) ( \
cat $< | sed \
-e 's/@LLVM_CONFIG_CODE@/$(LLVM_CONFIG_CODE)/' \
-e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
-e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
-e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
-e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
-e 's/@LLVM_COMMON_DEPENDS@//' \
-e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \
-e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
-e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
-e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
-e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
-e 's/@LLVM_ABI_BREAKING_CHECKS@/'"$(LLVM_ABI_BREAKING_CHECKS)"'/' \
-e 's/@LLVM_ENABLE_ASSERTIONS@/'"$(LLVM_ENABLE_ASSERTIONS)"'/' \
-e 's/@LLVM_ENABLE_EH@/'"$(LLVM_ENABLE_EH)"'/' \
-e 's/@LLVM_ENABLE_RTTI@/'"$(LLVM_ENABLE_RTTI)"'/' \
-e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
-e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
-e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
-e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
-e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
-e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
-e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
-e 's/@LLVM_LIBDIR_SUFFIX@//' \
-e 's#@LLVM_CONFIG_INCLUDE_DIRS@#$${LLVM_INSTALL_PREFIX}/include#' \
-e 's#@LLVM_CONFIG_LIBRARY_DIRS@#$${_LLVM_LIBRARY_DIR}#' \
-e 's#@LLVM_CONFIG_CMAKE_DIR@#$${_LLVM_CMAKE_DIR}#' \
-e 's#@LLVM_CONFIG_TOOLS_BINARY_DIR@#$${LLVM_INSTALL_PREFIX}/bin#' \
-e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
-e 's/@all_llvm_lib_deps@//' \
&& \
( grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" | \
grep -v LLVMBUILD_LIB_DEPS_gtest ) && \
echo 'unset(_LLVM_CMAKE_DIR)' && \
echo 'unset(_LLVM_LIBRARY_DIR)' \
) > $@
$(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in Makefile
$(Echo) 'Generating LLVM CMake package version file'
$(Verb) cat $< | sed \
-e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
-e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
-e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
-e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
> $@
$(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag) Makefile
$(Echo) 'Generating LLVM CMake target exports file'
$(Verb) ( \
echo '# LLVM CMake target exports. Do not include directly.' && \
for lib in $(LLVM_LIBS_TO_EXPORT); do \
echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "$${_LLVM_LIBRARY_DIR}/'lib$$lib.a'")' ; \
done && \
cat "$(LLVMBuildCMakeExportsFrag)" && \
echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
) > $@
all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
SKIPSRCMODS := \
CheckAtomic.cmake \
GetHostTriple.cmake \
LLVMBuildExports.cmake \
LLVMConfig.cmake \
LLVMConfigVersion.cmake \
LLVMExports.cmake \
VersionFromVCS.cmake
SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
$(PROJ_cmake):
$(Echo) Making install directory: $@
$(Verb) $(MKDIR) $@
$(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
$(Echo) Installing cmake modules: $(notdir $<)
$(Verb) $(DataInstall) $< $(PROJ_cmake)
$(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
$(Echo) Installing cmake modules: $(notdir $<)
$(Verb) $(DataInstall) $< $(PROJ_cmake)
install-local:: $(INSTSRCMODS) $(INSTOBJMODS)

View File

@ -141,7 +141,7 @@ macro(add_tablegen target project)
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${target}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
endmacro()

View File

@ -1,45 +1,57 @@
# Adds version control information to the variable VERS. For
# determining the Version Control System used (if any) it inspects the
# existence of certain subdirectories under CMAKE_CURRENT_SOURCE_DIR.
# existence of certain subdirectories under SOURCE_DIR (if provided as an
# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
function(add_version_info_from_vcs VERS)
SET(SOURCE_DIR ${ARGV1})
if("${SOURCE_DIR}" STREQUAL "")
SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
string(REPLACE "svn" "" result "${${VERS}}")
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn" )
if( EXISTS "${SOURCE_DIR}/.svn" )
set(result "${result}svn")
# FindSubversion does not work with symlinks. See PR 8437
if( NOT IS_SYMLINK "${CMAKE_CURRENT_SOURCE_DIR}" )
if( NOT IS_SYMLINK "${SOURCE_DIR}" )
find_package(Subversion)
endif()
if( Subversion_FOUND )
subversion_wc_info( ${CMAKE_CURRENT_SOURCE_DIR} Project )
subversion_wc_info( ${SOURCE_DIR} Project )
if( Project_WC_REVISION )
set(SVN_REVISION ${Project_WC_REVISION} PARENT_SCOPE)
set(result "${result}-r${Project_WC_REVISION}")
endif()
if( Project_WC_URL )
set(LLVM_REPOSITORY ${Project_WC_URL} PARENT_SCOPE)
endif()
endif()
elseif( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git )
elseif( EXISTS ${SOURCE_DIR}/.git )
set(result "${result}git")
# Try to get a ref-id
if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/svn )
if( EXISTS ${SOURCE_DIR}/.git/svn )
find_program(git_executable NAMES git git.exe git.cmd)
if( git_executable )
set(is_git_svn_rev_exact false)
execute_process(COMMAND ${git_executable} svn log --limit=1 --oneline
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
execute_process(COMMAND
${git_executable} svn info
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if( git_result EQUAL 0 )
string(REGEX MATCH r[0-9]+ git_svn_rev ${git_output})
string(LENGTH "${git_svn_rev}" rev_length)
math(EXPR rev_length "${rev_length}-1")
string(SUBSTRING "${git_svn_rev}" 1 ${rev_length} git_svn_rev_number)
string(REGEX MATCH "URL: ([^ \n]*)" svn_url ${git_output})
if(svn_url)
set(LLVM_REPOSITORY ${CMAKE_MATCH_1} PARENT_SCOPE)
endif()
string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
"\\2" git_svn_rev_number "${git_output}")
set(SVN_REVISION ${git_svn_rev_number} PARENT_SCOPE)
set(git_svn_rev "-svn-${git_svn_rev}")
# Determine if the HEAD points directly at a subversion revision.
execute_process(COMMAND ${git_executable} svn find-rev HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
@ -54,10 +66,11 @@ function(add_version_info_from_vcs VERS)
endif()
execute_process(COMMAND
${git_executable} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if( git_result EQUAL 0 AND NOT is_git_svn_rev_exact )
string(STRIP "${git_output}" git_ref_id)
set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE)
@ -65,6 +78,7 @@ function(add_version_info_from_vcs VERS)
else()
set(result "${result}${git_svn_rev}")
endif()
endif()
endif()
endif()

View File

@ -1,39 +1,26 @@
# Toolchain config for iOS.
#
# Usage:
# mkdir build; cd build
# cmake ..; make
# mkdir ios; cd ios
# cmake -DLLVM_IOS_TOOLCHAIN_DIR=/path/to/ios/ndk \
# -DCMAKE_TOOLCHAIN_FILE=../../cmake/platforms/iOS.cmake ../..
# make <target>
SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_SYSTEM_VERSION 13)
SET(CMAKE_CXX_COMPILER_WORKS True)
SET(CMAKE_C_COMPILER_WORKS True)
SET(DARWIN_TARGET_OS_NAME ios)
IF(NOT DEFINED ENV{SDKROOT})
execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
OUTPUT_VARIABLE SDKROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
execute_process(COMMAND xcodebuild -version -sdk $ENV{SDKROOT} Path
OUTPUT_VARIABLE SDKROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
if(NOT CMAKE_OSX_SYSROOT)
execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
OUTPUT_VARIABLE SDKROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT EXISTS ${SDKROOT})
MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
ENDIF()
IF(NOT EXISTS ${SDKROOT})
MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
ENDIF()
set(CMAKE_OSX_SYSROOT ${SDKROOT})
message(STATUS "Using SDKROOT ${SDKROOT}")
set(CMAKE_OSX_SYSROOT ${SDKROOT})
endif()
IF(NOT CMAKE_C_COMPILER)
execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -41,7 +28,7 @@ IF(NOT CMAKE_C_COMPILER)
ENDIF()
IF(NOT CMAKE_CXX_COMPILER)
execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang++
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -49,7 +36,7 @@ IF(NOT CMAKE_CXX_COMPILER)
ENDIF()
IF(NOT CMAKE_AR)
execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ar
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ar
OUTPUT_VARIABLE CMAKE_AR_val
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -58,22 +45,10 @@ IF(NOT CMAKE_AR)
ENDIF()
IF(NOT CMAKE_RANLIB)
execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ranlib
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ranlib
OUTPUT_VARIABLE CMAKE_RANLIB_val
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib")
message(STATUS "Using ranlib ${CMAKE_RANLIB}")
ENDIF()
IF (NOT DEFINED IOS_MIN_TARGET)
execute_process(COMMAND xcodebuild -sdk ${SDKROOT} -version SDKVersion
OUTPUT_VARIABLE IOS_MIN_TARGET
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
SET(IOS_COMMON_FLAGS "-mios-version-min=${IOS_MIN_TARGET}")
SET(CMAKE_C_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
SET(CMAKE_CXX_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
SET(CMAKE_LINK_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)

19471
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,29 @@ The AMDGPU back-end provides ISA code generation for AMD GPUs, starting with
the R600 family up until the current Volcanic Islands (GCN Gen 3).
Conventions
===========
Address Spaces
--------------
The AMDGPU back-end uses the following address space mapping:
============= ============================================
Address Space Memory Space
============= ============================================
0 Private
1 Global
2 Constant
3 Local
4 Generic (Flat)
5 Region
============= ============================================
The terminology in the table, aside from the region memory space, is from the
OpenCL standard.
Assembler
=========
@ -65,14 +88,14 @@ wait for.
.. code-block:: nasm
// Wait for all counters to be 0
; Wait for all counters to be 0
s_waitcnt 0
// Equivalent to s_waitcnt 0. Counter names can also be delimited by
// '&' or ','.
; Equivalent to s_waitcnt 0. Counter names can also be delimited by
; '&' or ','.
s_waitcnt vmcnt(0) expcnt(0) lgkcmt(0)
// Wait for vmcnt counter to be 1.
; Wait for vmcnt counter to be 1.
s_waitcnt vmcnt(1)
VOP1, VOP2, VOP3, VOPC Instructions
@ -153,7 +176,10 @@ Here is an example of a minimal amd_kernel_code_t specification:
.hsa_code_object_version 1,0
.hsa_code_object_isa
.text
.hsatext
.globl hello_world
.p2align 8
.amdgpu_hsa_kernel hello_world
hello_world:
@ -173,5 +199,7 @@ Here is an example of a minimal amd_kernel_code_t specification:
s_waitcnt lgkmcnt(0)
v_mov_b32 v1, s0
v_mov_b32 v2, s1
flat_store_dword v0, v[1:2]
flat_store_dword v[1:2], v0
s_endpgm
.Lfunc_end0:
.size hello_world, .Lfunc_end0-hello_world

174
docs/AdvancedBuilds.rst Normal file
View File

@ -0,0 +1,174 @@
=============================
Advanced Build Configurations
=============================
.. contents::
:local:
Introduction
============
`CMake <http://www.cmake.org/>`_ is a cross-platform build-generator tool. CMake
does not build the project, it generates the files needed by your build tool
(GNU make, Visual Studio, etc.) for building LLVM.
If **you are a new contributor**, please start with the :doc:`GettingStarted` or
:doc:`CMake` pages. This page is intended for users doing more complex builds.
Many of the examples below are written assuming specific CMake Generators.
Unless otherwise explicitly called out these commands should work with any CMake
generator.
Bootstrap Builds
================
The Clang CMake build system supports bootstrap (aka multi-stage) builds. At a
high level a multi-stage build is a chain of builds that pass data from one
stage into the next. The most common and simple version of this is a traditional
bootstrap build.
In a simple two-stage bootstrap build, we build clang using the system compiler,
then use that just-built clang to build clang again. In CMake this simplest form
of a bootstrap build can be configured with a single option,
CLANG_ENABLE_BOOTSTRAP.
.. code-block:: console
$ cmake -G Ninja -DCLANG_ENABLE_BOOTSTRAP=On <path to source>
$ ninja stage2
This command itself isn't terribly useful because it assumes default
configurations for each stage. The next series of examples utilize CMake cache
scripts to provide more complex options.
The clang build system refers to builds as stages. A stage1 build is a standard
build using the compiler installed on the host, and a stage2 build is built
using the stage1 compiler. This nomenclature holds up to more stages too. In
general a stage*n* build is built using the output from stage*n-1*.
Apple Clang Builds (A More Complex Bootstrap)
=============================================
Apple's Clang builds are a slightly more complicated example of the simple
bootstrapping scenario. Apple Clang is built using a 2-stage build.
The stage1 compiler is a host-only compiler with some options set. The stage1
compiler is a balance of optimization vs build time because it is a throwaway.
The stage2 compiler is the fully optimized compiler intended to ship to users.
Setting up these compilers requires a lot of options. To simplify the
configuration the Apple Clang build settings are contained in CMake Cache files.
You can build an Apple Clang compiler using the following commands:
.. code-block:: console
$ cmake -G Ninja -C <path to clang>/cmake/caches/Apple-stage1.cmake <path to source>
$ ninja stage2-distribution
This CMake invocation configures the stage1 host compiler, and sets
CLANG_BOOTSTRAP_CMAKE_ARGS to pass the Apple-stage2.cmake cache script to the
stage2 configuration step.
When you build the stage2-distribution target it builds the minimal stage1
compiler and required tools, then configures and builds the stage2 compiler
based on the settings in Apple-stage2.cmake.
This pattern of using cache scripts to set complex settings, and specifically to
make later stage builds include cache scripts is common in our more advanced
build configurations.
Multi-stage PGO
===============
Profile-Guided Optimizations (PGO) is a really great way to optimize the code
clang generates. Our multi-stage PGO builds are a workflow for generating PGO
profiles that can be used to optimize clang.
At a high level, the way PGO works is that you build an instrumented compiler,
then you run the instrumented compiler against sample source files. While the
instrumented compiler runs it will output a bunch of files containing
performance counters (.profraw files). After generating all the profraw files
you use llvm-profdata to merge the files into a single profdata file that you
can feed into the LLVM_PROFDATA_FILE option.
Our PGO.cmake cache script automates that whole process. You can use it by
running:
.. code-block:: console
$ cmake -G Ninja -C <path_to_clang>/cmake/caches/PGO.cmake <source dir>
$ ninja stage2-instrumented-generate-profdata
If you let that run for a few hours or so, it will place a profdata file in your
build directory. This takes a really long time because it builds clang twice,
and you *must* have compiler-rt in your build tree.
This process uses any source files under the perf-training directory as training
data as long as the source files are marked up with LIT-style RUN lines.
After it finishes you can use “find . -name clang.profdata” to find it, but it
should be at a path something like:
.. code-block:: console
<build dir>/tools/clang/stage2-instrumented-bins/utils/perf-training/clang.profdata
You can feed that file into the LLVM_PROFDATA_FILE option when you build your
optimized compiler.
The PGO came cache has a slightly different stage naming scheme than other
multi-stage builds. It generates three stages; stage1, stage2-instrumented, and
stage2. Both of the stage2 builds are built using the stage1 compiler.
The PGO came cache generates the following additional targets:
**stage2-instrumented**
Builds a stage1 x86 compiler, runtime, and required tools (llvm-config,
llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.
**stage2-instrumented-generate-profdata**
Depends on "stage2-instrumented" and will use the instrumented compiler to
generate profdata based on the training files in <clang>/utils/perf-training
**stage2**
Depends of "stage2-instrumented-generate-profdata" and will use the stage1
compiler with the stage2 profdata to build a PGO-optimized compiler.
**stage2-check-llvm**
Depends on stage2 and runs check-llvm using the stage2 compiler.
**stage2-check-clang**
Depends on stage2 and runs check-clang using the stage2 compiler.
**stage2-check-all**
Depends on stage2 and runs check-all using the stage2 compiler.
**stage2-test-suite**
Depends on stage2 and runs the test-suite using the stage3 compiler (requires
in-tree test-suite).
3-Stage Non-Determinism
=======================
In the ancient lore of compilers non-determinism is like the multi-headed hydra.
Whenever it's head pops up, terror and chaos ensue.
Historically one of the tests to verify that a compiler was deterministic would
be a three stage build. The idea of a three stage build is you take your sources
and build a compiler (stage1), then use that compiler to rebuild the sources
(stage2), then you use that compiler to rebuild the sources a third time
(stage3) with an identical configuration to the stage2 build. At the end of
this, you have a stage2 and stage3 compiler that should be bit-for-bit
identical.
You can perform one of these 3-stage builds with LLVM & clang using the
following commands:
.. code-block:: console
$ cmake -G Ninja -C <path_to_clang>/cmake/caches/3-stage.cmake <source dir>
$ ninja stage3
After the build you can compare the stage2 & stage3 compilers. We have a bot
setup `here <http://lab.llvm.org:8011/builders/clang-3stage-ubuntu>`_ that runs
this build and compare configuration.

View File

@ -31,8 +31,7 @@ well together.
This document contains information necessary to successfully implement this
interface, use it, and to test both sides. It also explains some of the finer
points about what exactly results mean. If you feel that something is unclear
or should be added, please `let me know <mailto:sabre@nondot.org>`_.
points about what exactly results mean.
``AliasAnalysis`` Class Overview
================================

View File

@ -8,17 +8,13 @@ LLVM Atomic Instructions and Concurrency Guide
Introduction
============
Historically, LLVM has not had very strong support for concurrency; some minimal
intrinsics were provided, and ``volatile`` was used in some cases to achieve
rough semantics in the presence of concurrency. However, this is changing;
there are now new instructions which are well-defined in the presence of threads
and asynchronous signals, and the model for existing instructions has been
clarified in the IR.
LLVM supports instructions which are well-defined in the presence of threads and
asynchronous signals.
The atomic instructions are designed specifically to provide readable IR and
optimized code generation for the following:
* The new C++11 ``<atomic>`` header. (`C++11 draft available here
* The C++11 ``<atomic>`` header. (`C++11 draft available here
<http://www.open-std.org/jtc1/sc22/wg21/>`_.) (`C11 draft available here
<http://www.open-std.org/jtc1/sc22/wg14/>`_.)
@ -371,7 +367,7 @@ Predicates for optimizer writers to query:
that they return true for any operation which is volatile or at least
Monotonic.
* ``isAtLeastAcquire()``/``isAtLeastRelease()``: These are predicates on
* ``isStrongerThan`` / ``isAtLeastOrStrongerThan``: These are predicates on
orderings. They can be useful for passes that are aware of atomics, for
example to do DSE across a single atomic access, but not across a
release-acquire pair (see MemoryDependencyAnalysis for an example of this)
@ -402,7 +398,7 @@ operations:
MemoryDependencyAnalysis (which is also used by other passes like GVN).
* Folding a load: Any atomic load from a constant global can be constant-folded,
because it cannot be observed. Similar reasoning allows scalarrepl with
because it cannot be observed. Similar reasoning allows sroa with
atomic loads and stores.
Atomics and Codegen
@ -417,19 +413,28 @@ The MachineMemOperand for all atomic operations is currently marked as volatile;
this is not correct in the IR sense of volatile, but CodeGen handles anything
marked volatile very conservatively. This should get fixed at some point.
Common architectures have some way of representing at least a pointer-sized
lock-free ``cmpxchg``; such an operation can be used to implement all the other
atomic operations which can be represented in IR up to that size. Backends are
expected to implement all those operations, but not operations which cannot be
implemented in a lock-free manner. It is expected that backends will give an
error when given an operation which cannot be implemented. (The LLVM code
generator is not very helpful here at the moment, but hopefully that will
change.)
One very important property of the atomic operations is that if your backend
supports any inline lock-free atomic operations of a given size, you should
support *ALL* operations of that size in a lock-free manner.
When the target implements atomic ``cmpxchg`` or LL/SC instructions (as most do)
this is trivial: all the other operations can be implemented on top of those
primitives. However, on many older CPUs (e.g. ARMv5, SparcV8, Intel 80386) there
are atomic load and store instructions, but no ``cmpxchg`` or LL/SC. As it is
invalid to implement ``atomic load`` using the native instruction, but
``cmpxchg`` using a library call to a function that uses a mutex, ``atomic
load`` must *also* expand to a library call on such architectures, so that it
can remain atomic with regards to a simultaneous ``cmpxchg``, by using the same
mutex.
AtomicExpandPass can help with that: it will expand all atomic operations to the
proper ``__atomic_*`` libcalls for any size above the maximum set by
``setMaxAtomicSizeInBitsSupported`` (which defaults to 0).
On x86, all atomic loads generate a ``MOV``. SequentiallyConsistent stores
generate an ``XCHG``, other stores generate a ``MOV``. SequentiallyConsistent
fences generate an ``MFENCE``, other fences do not cause any code to be
generated. cmpxchg uses the ``LOCK CMPXCHG`` instruction. ``atomicrmw xchg``
generated. ``cmpxchg`` uses the ``LOCK CMPXCHG`` instruction. ``atomicrmw xchg``
uses ``XCHG``, ``atomicrmw add`` and ``atomicrmw sub`` use ``XADD``, and all
other ``atomicrmw`` operations generate a loop with ``LOCK CMPXCHG``. Depending
on the users of the result, some ``atomicrmw`` operations can be translated into
@ -450,10 +455,151 @@ atomic constructs. Here are some lowerings it can do:
``emitStoreConditional()``
* large loads/stores -> ll-sc/cmpxchg
by overriding ``shouldExpandAtomicStoreInIR()``/``shouldExpandAtomicLoadInIR()``
* strong atomic accesses -> monotonic accesses + fences
by using ``setInsertFencesForAtomic()`` and overriding ``emitLeadingFence()``
and ``emitTrailingFence()``
* strong atomic accesses -> monotonic accesses + fences by overriding
``shouldInsertFencesForAtomic()``, ``emitLeadingFence()``, and
``emitTrailingFence()``
* atomic rmw -> loop with cmpxchg or load-linked/store-conditional
by overriding ``expandAtomicRMWInIR()``
* expansion to __atomic_* libcalls for unsupported sizes.
For an example of all of these, look at the ARM backend.
Libcalls: __atomic_*
====================
There are two kinds of atomic library calls that are generated by LLVM. Please
note that both sets of library functions somewhat confusingly share the names of
builtin functions defined by clang. Despite this, the library functions are
not directly related to the builtins: it is *not* the case that ``__atomic_*``
builtins lower to ``__atomic_*`` library calls and ``__sync_*`` builtins lower
to ``__sync_*`` library calls.
The first set of library functions are named ``__atomic_*``. This set has been
"standardized" by GCC, and is described below. (See also `GCC's documentation
<https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary>`_)
LLVM's AtomicExpandPass will translate atomic operations on data sizes above
``MaxAtomicSizeInBitsSupported`` into calls to these functions.
There are four generic functions, which can be called with data of any size or
alignment::
void __atomic_load(size_t size, void *ptr, void *ret, int ordering)
void __atomic_store(size_t size, void *ptr, void *val, int ordering)
void __atomic_exchange(size_t size, void *ptr, void *val, void *ret, int ordering)
bool __atomic_compare_exchange(size_t size, void *ptr, void *expected, void *desired, int success_order, int failure_order)
There are also size-specialized versions of the above functions, which can only
be used with *naturally-aligned* pointers of the appropriate size. In the
signatures below, "N" is one of 1, 2, 4, 8, and 16, and "iN" is the appropriate
integer type of that size; if no such integer type exists, the specialization
cannot be used::
iN __atomic_load_N(iN *ptr, iN val, int ordering)
void __atomic_store_N(iN *ptr, iN val, int ordering)
iN __atomic_exchange_N(iN *ptr, iN val, int ordering)
bool __atomic_compare_exchange_N(iN *ptr, iN *expected, iN desired, int success_order, int failure_order)
Finally there are some read-modify-write functions, which are only available in
the size-specific variants (any other sizes use a ``__atomic_compare_exchange``
loop)::
iN __atomic_fetch_add_N(iN *ptr, iN val, int ordering)
iN __atomic_fetch_sub_N(iN *ptr, iN val, int ordering)
iN __atomic_fetch_and_N(iN *ptr, iN val, int ordering)
iN __atomic_fetch_or_N(iN *ptr, iN val, int ordering)
iN __atomic_fetch_xor_N(iN *ptr, iN val, int ordering)
iN __atomic_fetch_nand_N(iN *ptr, iN val, int ordering)
This set of library functions have some interesting implementation requirements
to take note of:
- They support all sizes and alignments -- including those which cannot be
implemented natively on any existing hardware. Therefore, they will certainly
use mutexes in for some sizes/alignments.
- As a consequence, they cannot be shipped in a statically linked
compiler-support library, as they have state which must be shared amongst all
DSOs loaded in the program. They must be provided in a shared library used by
all objects.
- The set of atomic sizes supported lock-free must be a superset of the sizes
any compiler can emit. That is: if a new compiler introduces support for
inline-lock-free atomics of size N, the ``__atomic_*`` functions must also have a
lock-free implementation for size N. This is a requirement so that code
produced by an old compiler (which will have called the ``__atomic_*`` function)
interoperates with code produced by the new compiler (which will use native
the atomic instruction).
Note that it's possible to write an entirely target-independent implementation
of these library functions by using the compiler atomic builtins themselves to
implement the operations on naturally-aligned pointers of supported sizes, and a
generic mutex implementation otherwise.
Libcalls: __sync_*
==================
Some targets or OS/target combinations can support lock-free atomics, but for
various reasons, it is not practical to emit the instructions inline.
There's two typical examples of this.
Some CPUs support multiple instruction sets which can be swiched back and forth
on function-call boundaries. For example, MIPS supports the MIPS16 ISA, which
has a smaller instruction encoding than the usual MIPS32 ISA. ARM, similarly,
has the Thumb ISA. In MIPS16 and earlier versions of Thumb, the atomic
instructions are not encodable. However, those instructions are available via a
function call to a function with the longer encoding.
Additionally, a few OS/target pairs provide kernel-supported lock-free
atomics. ARM/Linux is an example of this: the kernel `provides
<https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt>`_ a
function which on older CPUs contains a "magically-restartable" atomic sequence
(which looks atomic so long as there's only one CPU), and contains actual atomic
instructions on newer multicore models. This sort of functionality can typically
be provided on any architecture, if all CPUs which are missing atomic
compare-and-swap support are uniprocessor (no SMP). This is almost always the
case. The only common architecture without that property is SPARC -- SPARCV8 SMP
systems were common, yet it doesn't support any sort of compare-and-swap
operation.
In either of these cases, the Target in LLVM can claim support for atomics of an
appropriate size, and then implement some subset of the operations via libcalls
to a ``__sync_*`` function. Such functions *must* not use locks in their
implementation, because unlike the ``__atomic_*`` routines used by
AtomicExpandPass, these may be mixed-and-matched with native instructions by the
target lowering.
Further, these routines do not need to be shared, as they are stateless. So,
there is no issue with having multiple copies included in one binary. Thus,
typically these routines are implemented by the statically-linked compiler
runtime support library.
LLVM will emit a call to an appropriate ``__sync_*`` routine if the target
ISelLowering code has set the corresponding ``ATOMIC_CMPXCHG``, ``ATOMIC_SWAP``,
or ``ATOMIC_LOAD_*`` operation to "Expand", and if it has opted-into the
availability of those library functions via a call to ``initSyncLibcalls()``.
The full set of functions that may be called by LLVM is (for ``N`` being 1, 2,
4, 8, or 16)::
iN __sync_val_compare_and_swap_N(iN *ptr, iN expected, iN desired)
iN __sync_lock_test_and_set_N(iN *ptr, iN val)
iN __sync_fetch_and_add_N(iN *ptr, iN val)
iN __sync_fetch_and_sub_N(iN *ptr, iN val)
iN __sync_fetch_and_and_N(iN *ptr, iN val)
iN __sync_fetch_and_or_N(iN *ptr, iN val)
iN __sync_fetch_and_xor_N(iN *ptr, iN val)
iN __sync_fetch_and_nand_N(iN *ptr, iN val)
iN __sync_fetch_and_max_N(iN *ptr, iN val)
iN __sync_fetch_and_umax_N(iN *ptr, iN val)
iN __sync_fetch_and_min_N(iN *ptr, iN val)
iN __sync_fetch_and_umin_N(iN *ptr, iN val)
This list doesn't include any function for atomic load or store; all known
architectures support atomic loads and stores directly (possibly by emitting a
fence on either side of a normal load or store.)
There's also, somewhat separately, the possibility to lower ``ATOMIC_FENCE`` to
``__sync_synchronize()``. This may happen or not happen independent of all the
above, controlled purely by ``setOperationAction(ISD::ATOMIC_FENCE, ...)``.

View File

@ -467,10 +467,11 @@ Native Object File Wrapper Format
=================================
Bitcode files for LLVM IR may also be wrapped in a native object file
(i.e. ELF, COFF, Mach-O). The bitcode must be stored in a section of the
object file named ``.llvmbc``. This wrapper format is useful for accommodating
LTO in compilation pipelines where intermediate objects must be native object
files which contain metadata in other sections.
(i.e. ELF, COFF, Mach-O). The bitcode must be stored in a section of the object
file named ``__LLVM,__bitcode`` for MachO and ``.llvmbc`` for the other object
formats. This wrapper format is useful for accommodating LTO in compilation
pipelines where intermediate objects must be native object files which contain
metadata in other sections.
Not all tools support this format.
@ -689,6 +690,7 @@ global variable. The operand fields are:
.. _linkage type:
* *linkage*: An encoding of the linkage type for this variable:
* ``external``: code 0
* ``weak``: code 1
* ``appending``: code 2
@ -713,20 +715,30 @@ global variable. The operand fields are:
.. _visibility:
* *visibility*: If present, an encoding of the visibility of this variable:
* ``default``: code 0
* ``hidden``: code 1
* ``protected``: code 2
.. _bcthreadlocal:
* *threadlocal*: If present, an encoding of the thread local storage mode of the
variable:
* ``not thread local``: code 0
* ``thread local; default TLS model``: code 1
* ``localdynamic``: code 2
* ``initialexec``: code 3
* ``localexec``: code 4
* *unnamed_addr*: If present and non-zero, indicates that the variable has
``unnamed_addr``
.. _bcunnamedaddr:
* *unnamed_addr*: If present, an encoding of the ``unnamed_addr`` attribute of this
variable:
* not ``unnamed_addr``: code 0
* ``unnamed_addr``: code 1
* ``local_unnamed_addr``: code 2
.. _bcdllstorageclass:
@ -736,6 +748,8 @@ global variable. The operand fields are:
* ``dllimport``: code 1
* ``dllexport``: code 2
* *comdat*: An encoding of the COMDAT of this function
.. _FUNCTION:
MODULE_CODE_FUNCTION Record
@ -756,6 +770,7 @@ function. The operand fields are:
* ``anyregcc``: code 13
* ``preserve_mostcc``: code 14
* ``preserve_allcc``: code 15
* ``swiftcc`` : code 16
* ``cxx_fast_tlscc``: code 17
* ``x86_stdcallcc``: code 64
* ``x86_fastcallcc``: code 65
@ -782,8 +797,8 @@ function. The operand fields are:
* *gc*: If present and nonzero, the 1-based garbage collector index in the table
of `MODULE_CODE_GCNAME`_ entries.
* *unnamed_addr*: If present and non-zero, indicates that the function has
``unnamed_addr``
* *unnamed_addr*: If present, an encoding of the
:ref:`unnamed_addr<bcunnamedaddr>` attribute of this function
* *prologuedata*: If non-zero, the value index of the prologue data for this function,
plus 1.
@ -802,7 +817,7 @@ function. The operand fields are:
MODULE_CODE_ALIAS Record
^^^^^^^^^^^^^^^^^^^^^^^^
``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass]``
``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass, threadlocal, unnamed_addr]``
The ``ALIAS`` record (code 9) marks the definition of an alias. The operand
fields are
@ -818,6 +833,12 @@ fields are
* *dllstorageclass*: If present, an encoding of the
:ref:`dllstorageclass<bcdllstorageclass>` of the alias
* *threadlocal*: If present, an encoding of the
:ref:`thread local property<bcthreadlocal>` of the alias
* *unnamed_addr*: If present, an encoding of the
:ref:`unnamed_addr<bcunnamedaddr>` attribute of this alias
MODULE_CODE_PURGEVALS Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,115 +0,0 @@
=======
Bitsets
=======
This is a mechanism that allows IR modules to co-operatively build pointer
sets corresponding to addresses within a given set of globals. One example
of a use case for this is to allow a C++ program to efficiently verify (at
each call site) that a vtable pointer is in the set of valid vtable pointers
for the type of the class or its derived classes.
To use the mechanism, a client creates a global metadata node named
``llvm.bitsets``. Each element is a metadata node with three elements:
1. a metadata object representing an identifier for the bitset
2. either a global variable or a function
3. a byte offset into the global (generally zero for functions)
Each bitset must exclusively contain either global variables or functions.
.. admonition:: Limitation
The current implementation only supports functions as members of bitsets on
the x86-32 and x86-64 architectures.
This will cause a link-time optimization pass to generate bitsets from the
memory addresses referenced from the elements of the bitset metadata. The
pass will lay out referenced global variables consecutively, so their
definitions must be available at LTO time.
A bit set containing functions is transformed into a jump table, which
is a block of code consisting of one branch instruction for each of the
functions in the bit set that branches to the target function, and redirect
any taken function addresses to the corresponding jump table entry. In the
object file's symbol table, the jump table entries take the identities of
the original functions, so that addresses taken outside the module will pass
any verification done inside the module.
Jump tables may call external functions, so their definitions need not
be available at LTO time. Note that if an externally defined function is a
member of a bitset, there is no guarantee that its identity within the module
will be the same as its identity outside of the module, as the former will
be the jump table entry if a jump table is necessary.
The `GlobalLayoutBuilder`_ class is responsible for laying out the globals
efficiently to minimize the sizes of the underlying bitsets. An intrinsic,
:ref:`llvm.bitset.test <bitset.test>`, generates code to test whether a
given pointer is a member of a bitset.
:Example:
::
target datalayout = "e-p:32:32"
@a = internal global i32 0
@b = internal global i32 0
@c = internal global i32 0
@d = internal global [2 x i32] [i32 0, i32 0]
define void @e() {
ret void
}
define void @f() {
ret void
}
declare void @g()
!llvm.bitsets = !{!0, !1, !2, !3, !4, !5, !6}
!0 = !{!"bitset1", i32* @a, i32 0}
!1 = !{!"bitset1", i32* @b, i32 0}
!2 = !{!"bitset2", i32* @b, i32 0}
!3 = !{!"bitset2", i32* @c, i32 0}
!4 = !{!"bitset2", i32* @d, i32 4}
!5 = !{!"bitset3", void ()* @e, i32 0}
!6 = !{!"bitset3", void ()* @g, i32 0}
declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone
define i1 @foo(i32* %p) {
%pi8 = bitcast i32* %p to i8*
%x = call i1 @llvm.bitset.test(i8* %pi8, metadata !"bitset1")
ret i1 %x
}
define i1 @bar(i32* %p) {
%pi8 = bitcast i32* %p to i8*
%x = call i1 @llvm.bitset.test(i8* %pi8, metadata !"bitset2")
ret i1 %x
}
define i1 @baz(void ()* %p) {
%pi8 = bitcast void ()* %p to i8*
%x = call i1 @llvm.bitset.test(i8* %pi8, metadata !"bitset3")
ret i1 %x
}
define void @main() {
%a1 = call i1 @foo(i32* @a) ; returns 1
%b1 = call i1 @foo(i32* @b) ; returns 1
%c1 = call i1 @foo(i32* @c) ; returns 0
%a2 = call i1 @bar(i32* @a) ; returns 0
%b2 = call i1 @bar(i32* @b) ; returns 1
%c2 = call i1 @bar(i32* @c) ; returns 1
%d02 = call i1 @bar(i32* getelementptr ([2 x i32]* @d, i32 0, i32 0)) ; returns 0
%d12 = call i1 @bar(i32* getelementptr ([2 x i32]* @d, i32 0, i32 1)) ; returns 1
%e = call i1 @baz(void ()* @e) ; returns 1
%f = call i1 @baz(void ()* @f) ; returns 0
%g = call i1 @baz(void ()* @g) ; returns 1
ret void
}
.. _GlobalLayoutBuilder: http://llvm.org/klaus/llvm/blob/master/include/llvm/Transforms/IPO/LowerBitSets.h

View File

@ -1,338 +0,0 @@
====================================
Building LLVM With Autotools
====================================
.. contents::
:local:
.. warning::
Building LLVM with autoconf is deprecated as of 3.8. The autoconf build
system will be removed in 3.9. Please migrate to using CMake. For more
information see: `Building LLVM with CMake <CMake.html>`_
Overview
========
This document details how to use the LLVM autotools based build system to
configure and build LLVM from source. The normal developer process using CMake
is detailed `here <GettingStarted.html#check-here>`_.
A Quick Summary
---------------
#. Configure and build LLVM and Clang:
* ``cd where-you-want-to-build-llvm``
* ``mkdir build`` (for building without polluting the source dir)
* ``cd build``
* ``../llvm/configure [options]``
Some common options:
* ``--prefix=directory`` --- Specify for *directory* the full pathname of
where you want the LLVM tools and libraries to be installed (default
``/usr/local``).
* ``--enable-optimized`` --- Compile with optimizations enabled (default
is NO).
* ``--enable-assertions`` --- Compile with assertion checks enabled
(default is YES).
* ``make [-j]`` --- The ``-j`` specifies the number of jobs (commands) to run
simultaneously. This builds both LLVM and Clang for Debug+Asserts mode.
The ``--enable-optimized`` configure option is used to specify a Release
build.
* ``make check-all`` --- This run the regression tests to ensure everything
is in working order.
* If you get an "internal compiler error (ICE)" or test failures, see
`here <GettingStarted.html#check-here>`_.
Local LLVM Configuration
------------------------
Once checked out from the Subversion repository, the LLVM suite source code must
be configured via the ``configure`` script. This script sets variables in the
various ``*.in`` files, most notably ``llvm/Makefile.config`` and
``llvm/include/Config/config.h``. It also populates *OBJ_ROOT* with the
Makefiles needed to begin building LLVM.
The following environment variables are used by the ``configure`` script to
configure the build system:
+------------+-----------------------------------------------------------+
| Variable | Purpose |
+============+===========================================================+
| CC | Tells ``configure`` which C compiler to use. By default, |
| | ``configure`` will check ``PATH`` for ``clang`` and GCC C |
| | compilers (in this order). Use this variable to override |
| | ``configure``\'s default behavior. |
+------------+-----------------------------------------------------------+
| CXX | Tells ``configure`` which C++ compiler to use. By |
| | default, ``configure`` will check ``PATH`` for |
| | ``clang++`` and GCC C++ compilers (in this order). Use |
| | this variable to override ``configure``'s default |
| | behavior. |
+------------+-----------------------------------------------------------+
The following options can be used to set or enable LLVM specific options:
``--enable-optimized``
Enables optimized compilation (debugging symbols are removed and GCC
optimization flags are enabled). Note that this is the default setting if you
are using the LLVM distribution. The default behavior of a Subversion
checkout is to use an unoptimized build (also known as a debug build).
``--enable-debug-runtime``
Enables debug symbols in the runtime libraries. The default is to strip debug
symbols from the runtime libraries.
``--enable-jit``
Compile the Just In Time (JIT) compiler functionality. This is not available
on all platforms. The default is dependent on platform, so it is best to
explicitly enable it if you want it.
``--enable-targets=target-option``
Controls which targets will be built and linked into llc. The default value
for ``target_options`` is "all" which builds and links all available targets.
The "host" target is selected as the target of the build host. You can also
specify a comma separated list of target names that you want available in llc.
The target names use all lower case. The current set of targets is:
``aarch64, arm, arm64, cpp, hexagon, mips, mipsel, mips64, mips64el, msp430,
powerpc, nvptx, r600, sparc, systemz, x86, x86_64, xcore``.
``--enable-doxygen``
Look for the doxygen program and enable construction of doxygen based
documentation from the source code. This is disabled by default because
generating the documentation can take a long time and producess 100s of
megabytes of output.
To configure LLVM, follow these steps:
#. Change directory into the object root directory:
.. code-block:: console
% cd OBJ_ROOT
#. Run the ``configure`` script located in the LLVM source tree:
.. code-block:: console
% $LLVM_SRC_DIR/configure --prefix=/install/path [other options]
Compiling the LLVM Suite Source Code
------------------------------------
Once you have configured LLVM, you can build it. There are three types of
builds:
Debug Builds
These builds are the default when one is using a Subversion checkout and
types ``gmake`` (unless the ``--enable-optimized`` option was used during
configuration). The build system will compile the tools and libraries with
debugging information. To get a Debug Build using the LLVM distribution the
``--disable-optimized`` option must be passed to ``configure``.
Release (Optimized) Builds
These builds are enabled with the ``--enable-optimized`` option to
``configure`` or by specifying ``ENABLE_OPTIMIZED=1`` on the ``gmake`` command
line. For these builds, the build system will compile the tools and libraries
with GCC optimizations enabled and strip debugging information from the
libraries and executables it generates. Note that Release Builds are default
when using an LLVM distribution.
Profile Builds
These builds are for use with profiling. They compile profiling information
into the code for use with programs like ``gprof``. Profile builds must be
started by specifying ``ENABLE_PROFILING=1`` on the ``gmake`` command line.
Once you have LLVM configured, you can build it by entering the *OBJ_ROOT*
directory and issuing the following command:
.. code-block:: console
% gmake
If the build fails, please `check here <GettingStarted.html#check-here>`_
to see if you are using a version of GCC that is known not to compile LLVM.
If you have multiple processors in your machine, you may wish to use some of the
parallel build options provided by GNU Make. For example, you could use the
command:
.. code-block:: console
% gmake -j2
There are several special targets which are useful when working with the LLVM
source code:
``gmake clean``
Removes all files generated by the build. This includes object files,
generated C/C++ files, libraries, and executables.
``gmake dist-clean``
Removes everything that ``gmake clean`` does, but also removes files generated
by ``configure``. It attempts to return the source tree to the original state
in which it was shipped.
``gmake install``
Installs LLVM header files, libraries, tools, and documentation in a hierarchy
under ``$PREFIX``, specified with ``$LLVM_SRC_DIR/configure --prefix=[dir]``, which
defaults to ``/usr/local``.
``gmake -C runtime install-bytecode``
Assuming you built LLVM into $OBJDIR, when this command is run, it will
install bitcode libraries into the GCC front end's bitcode library directory.
If you need to update your bitcode libraries, this is the target to use once
you've built them.
Please see the `Makefile Guide <MakefileGuide.html>`_ for further details on
these ``make`` targets and descriptions of other targets available.
It is also possible to override default values from ``configure`` by declaring
variables on the command line. The following are some examples:
``gmake ENABLE_OPTIMIZED=1``
Perform a Release (Optimized) build.
``gmake ENABLE_OPTIMIZED=1 DISABLE_ASSERTIONS=1``
Perform a Release (Optimized) build without assertions enabled.
``gmake ENABLE_OPTIMIZED=0``
Perform a Debug build.
``gmake ENABLE_PROFILING=1``
Perform a Profiling build.
``gmake VERBOSE=1``
Print what ``gmake`` is doing on standard output.
``gmake TOOL_VERBOSE=1``
Ask each tool invoked by the makefiles to print out what it is doing on
the standard output. This also implies ``VERBOSE=1``.
Every directory in the LLVM object tree includes a ``Makefile`` to build it and
any subdirectories that it contains. Entering any directory inside the LLVM
object tree and typing ``gmake`` should rebuild anything in or below that
directory that is out of date.
This does not apply to building the documentation.
LLVM's (non-Doxygen) documentation is produced with the
`Sphinx <http://sphinx-doc.org/>`_ documentation generation system.
There are some HTML documents that have not yet been converted to the new
system (which uses the easy-to-read and easy-to-write
`reStructuredText <http://sphinx-doc.org/rest.html>`_ plaintext markup
language).
The generated documentation is built in the ``$LLVM_SRC_DIR/docs`` directory using
a special makefile.
For instructions on how to install Sphinx, see
`Sphinx Introduction for LLVM Developers
<http://lld.llvm.org/sphinx_intro.html>`_.
After following the instructions there for installing Sphinx, build the LLVM
HTML documentation by doing the following:
.. code-block:: console
$ cd $LLVM_SRC_DIR/docs
$ make -f Makefile.sphinx
This creates a ``_build/html`` sub-directory with all of the HTML files, not
just the generated ones.
This directory corresponds to ``llvm.org/docs``.
For example, ``_build/html/SphinxQuickstartTemplate.html`` corresponds to
``llvm.org/docs/SphinxQuickstartTemplate.html``.
The :doc:`SphinxQuickstartTemplate` is useful when creating a new document.
Cross-Compiling LLVM
--------------------
It is possible to cross-compile LLVM itself. That is, you can create LLVM
executables and libraries to be hosted on a platform different from the platform
where they are built (a Canadian Cross build). To configure a cross-compile,
supply the configure script with ``--build`` and ``--host`` options that are
different. The values of these options must be legal target triples that your
GCC compiler supports.
The result of such a build is executables that are not runnable on on the build
host (--build option) but can be executed on the compile host (--host option).
Check :doc:`HowToCrossCompileLLVM` and `Clang docs on how to cross-compile in general
<http://clang.llvm.org/docs/CrossCompilation.html>`_ for more information
about cross-compiling.
The Location of LLVM Object Files
---------------------------------
The LLVM build system is capable of sharing a single LLVM source tree among
several LLVM builds. Hence, it is possible to build LLVM for several different
platforms or configurations using the same source tree.
This is accomplished in the typical autoconf manner:
* Change directory to where the LLVM object files should live:
.. code-block:: console
% cd OBJ_ROOT
* Run the ``configure`` script found in the LLVM source directory:
.. code-block:: console
% $LLVM_SRC_DIR/configure
The LLVM build will place files underneath *OBJ_ROOT* in directories named after
the build type:
Debug Builds with assertions enabled (the default)
Tools
``OBJ_ROOT/Debug+Asserts/bin``
Libraries
``OBJ_ROOT/Debug+Asserts/lib``
Release Builds
Tools
``OBJ_ROOT/Release/bin``
Libraries
``OBJ_ROOT/Release/lib``
Profile Builds
Tools
``OBJ_ROOT/Profile/bin``
Libraries
``OBJ_ROOT/Profile/lib``

View File

@ -12,12 +12,20 @@ Introduction
does not build the project, it generates the files needed by your build tool
(GNU make, Visual Studio, etc.) for building LLVM.
If **you are a new contributor**, please start with the :doc:`GettingStarted`
page. This page is geared for existing contributors moving from the
legacy configure/make system.
If you are really anxious about getting a functional LLVM build, go to the
`Quick start`_ section. If you are a CMake novice, start with `Basic CMake usage`_
and then go back to the `Quick start`_ section once you know what you are doing. The
`Options and variables`_ section is a reference for customizing your build. If
you already have experience with CMake, this is the recommended starting point.
This page is geared towards users of the LLVM CMake build. If you're looking for
information about modifying the LLVM CMake build system you may want to see the
:doc:`CMakePrimer` page. It has a basic overview of the CMake language.
.. _Quick start:
Quick start
@ -26,10 +34,7 @@ Quick start
We use here the command-line, non-interactive CMake interface.
#. `Download <http://www.cmake.org/cmake/resources/software.html>`_ and install
CMake. Version 2.8.8 is the minimum required, but if you're using the Ninja
backend, CMake v3.2 or newer is required to `get interactive output
<http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20141117/244797.html>`_
when running :doc:`Lit <CommandGuide/lit>`.
CMake. Version 3.4.3 is the minimum required.
#. Open a shell. Your development tools must be reachable from this shell
through the PATH environment variable.
@ -259,6 +264,9 @@ LLVM-specific variables
link against LLVM libraries and make use of C++ exceptions in your own code
that need to propagate through LLVM code. Defaults to OFF.
**LLVM_ENABLE_EXPENSIVE_CHECKS**:BOOL
Enable additional time/memory expensive checking. Defaults to OFF.
**LLVM_ENABLE_PIC**:BOOL
Add the ``-fPIC`` flag to the compiler command-line, if the compiler supports
this flag. Some systems, like Windows, do not need this flag. Defaults to ON.
@ -328,6 +336,14 @@ LLVM-specific variables
will not be used. If the variable for an external project does not point
to a valid path, then that project will not be built.
**LLVM_EXTERNAL_PROJECTS**:STRING
Semicolon-separated list of additional external projects to build as part of
llvm. For each project LLVM_EXTERNAL_<NAME>_SOURCE_DIR have to be specified
with the path for the source code of the project. Example:
``-DLLVM_EXTERNAL_PROJECTS="Foo;Bar"
-DLLVM_EXTERNAL_FOO_SOURCE_DIR=/src/foo
-DLLVM_EXTERNAL_BAR_SOURCE_DIR=/src/bar``.
**LLVM_USE_OPROFILE**:BOOL
Enable building OProfile JIT support. Defaults to OFF.
@ -347,6 +363,11 @@ LLVM-specific variables
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
and ``Address;Undefined``. Defaults to empty string.
**LLVM_ENABLE_LTO**:STRING
Add ``-flto`` or ``-flto=`` flags to the compile and link command
lines, enabling link-time optimization. Possible values are ``Off``,
``On``, ``Thin`` and ``Full``. Defaults to OFF.
**LLVM_PARALLEL_COMPILE_JOBS**:STRING
Define the maximum number of concurrent compilation jobs.
@ -354,10 +375,12 @@ LLVM-specific variables
Define the maximum number of concurrent link jobs.
**LLVM_BUILD_DOCS**:BOOL
Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to
be built as part of the normal build. If the ``install`` target is run then
this also enables all built documentation targets to be installed. Defaults to
OFF.
Adds all *enabled* documentation targets (i.e. Doxgyen and Sphinx targets) as
dependencies of the default build targets. This results in all of the (enabled)
documentation targets being as part of a normal build. If the ``install``
target is run then this also enables all built documentation targets to be
installed. Defaults to OFF. To enable a particular documentation target, see
see LLVM_ENABLE_SPHINX and LLVM_ENABLE_DOXYGEN.
**LLVM_ENABLE_DOXYGEN**:BOOL
Enables the generation of browsable HTML documentation using doxygen.
@ -409,7 +432,7 @@ LLVM-specific variables
Defaults to OFF.
**LLVM_ENABLE_SPHINX**:BOOL
If enabled CMake will search for the ``sphinx-build`` executable and will make
If specified, CMake will search for the ``sphinx-build`` executable and will make
the ``SPHINX_OUTPUT_HTML`` and ``SPHINX_OUTPUT_MAN`` CMake options available.
Defaults to OFF.
@ -463,6 +486,47 @@ LLVM-specific variables
If you want to build LLVM as a shared library, you should use the
``LLVM_BUILD_LLVM_DYLIB`` option.
**LLVM_OPTIMIZED_TABLEGEN**:BOOL
If enabled and building a debug or asserts build the CMake build system will
generate a Release build tree to build a fully optimized tablegen for use
during the build. Enabling this option can significantly speed up build times
especially when building LLVM in Debug configurations.
CMake Caches
============
Recently LLVM and Clang have been adding some more complicated build system
features. Utilizing these new features often involves a complicated chain of
CMake variables passed on the command line. Clang provides a collection of CMake
cache scripts to make these features more approachable.
CMake cache files are utilized using CMake's -C flag:
.. code-block:: console
$ cmake -C <path to cache file> <path to sources>
CMake cache scripts are processed in an isolated scope, only cached variables
remain set when the main configuration runs. CMake cached variables do not reset
variables that are already set unless the FORCE option is specified.
A few notes about CMake Caches:
- Order of command line arguments is important
- -D arguments specified before -C are set before the cache is processed and
can be read inside the cache file
- -D arguments specified after -C are set after the cache is processed and
are unset inside the cache file
- All -D arguments will override cache file settings
- CMAKE_TOOLCHAIN_FILE is evaluated after both the cache file and the command
line arguments
- It is recommended that all -D options should be specified *before* -C
For more information about some of the advanced build configurations supported
via Cache files see :doc:`AdvancedBuilds`.
Executing the test suite
========================
@ -502,7 +566,7 @@ and uses them to build a simple application ``simple-tool``.
.. code-block:: cmake
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 3.4.3)
project(SimpleProject)
find_package(LLVM REQUIRED CONFIG)
@ -532,16 +596,16 @@ The ``find_package(...)`` directive when used in CONFIG mode (as in the above
example) will look for the ``LLVMConfig.cmake`` file in various locations (see
cmake manual for details). It creates a ``LLVM_DIR`` cache entry to save the
directory where ``LLVMConfig.cmake`` is found or allows the user to specify the
directory (e.g. by passing ``-DLLVM_DIR=/usr/share/llvm/cmake`` to
directory (e.g. by passing ``-DLLVM_DIR=/usr/lib/cmake/llvm`` to
the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
This file is available in two different locations.
* ``<INSTALL_PREFIX>/share/llvm/cmake/LLVMConfig.cmake`` where
* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
On Linux typically this is ``/usr/share/llvm/cmake/LLVMConfig.cmake``.
On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
* ``<LLVM_BUILD_ROOT>/share/llvm/cmake/LLVMConfig.cmake`` where
* ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only
available when building LLVM with CMake.**

465
docs/CMakePrimer.rst Normal file
View File

@ -0,0 +1,465 @@
============
CMake Primer
============
.. contents::
:local:
.. warning::
Disclaimer: This documentation is written by LLVM project contributors `not`
anyone affiliated with the CMake project. This document may contain
inaccurate terminology, phrasing, or technical details. It is provided with
the best intentions.
Introduction
============
The LLVM project and many of the core projects built on LLVM build using CMake.
This document aims to provide a brief overview of CMake for developers modifying
LLVM projects or building their own projects on top of LLVM.
The official CMake language references is available in the cmake-language
manpage and `cmake-language online documentation
<https://cmake.org/cmake/help/v3.4/manual/cmake-language.7.html>`_.
10,000 ft View
==============
CMake is a tool that reads script files in its own language that describe how a
software project builds. As CMake evaluates the scripts it constructs an
internal representation of the software project. Once the scripts have been
fully processed, if there are no errors, CMake will generate build files to
actually build the project. CMake supports generating build files for a variety
of command line build tools as well as for popular IDEs.
When a user runs CMake it performs a variety of checks similar to how autoconf
worked historically. During the checks and the evaluation of the build
description scripts CMake caches values into the CMakeCache. This is useful
because it allows the build system to skip long-running checks during
incremental development. CMake caching also has some drawbacks, but that will be
discussed later.
Scripting Overview
==================
CMake's scripting language has a very simple grammar. Every language construct
is a command that matches the pattern _name_(_args_). Commands come in three
primary types: language-defined (commands implemented in C++ in CMake), defined
functions, and defined macros. The CMake distribution also contains a suite of
CMake modules that contain definitions for useful functionality.
The example below is the full CMake build for building a C++ "Hello World"
program. The example uses only CMake language-defined functions.
.. code-block:: cmake
cmake_minimum_required(VERSION 3.2)
project(HelloWorld)
add_executable(HelloWorld HelloWorld.cpp)
The CMake language provides control flow constructs in the form of foreach loops
and if blocks. To make the example above more complicated you could add an if
block to define "APPLE" when targeting Apple platforms:
.. code-block:: cmake
cmake_minimum_required(VERSION 3.2)
project(HelloWorld)
add_executable(HelloWorld HelloWorld.cpp)
if(APPLE)
target_compile_definitions(HelloWorld PUBLIC APPLE)
endif()
Variables, Types, and Scope
===========================
Dereferencing
-------------
In CMake variables are "stringly" typed. All variables are represented as
strings throughout evaluation. Wrapping a variable in ``${}`` dereferences it
and results in a literal substitution of the name for the value. CMake refers to
this as "variable evaluation" in their documentation. Dereferences are performed
*before* the command being called receives the arguments. This means
dereferencing a list results in multiple separate arguments being passed to the
command.
Variable dereferences can be nested and be used to model complex data. For
example:
.. code-block:: cmake
set(var_name var1)
set(${var_name} foo) # same as "set(var1 foo)"
set(${${var_name}}_var bar) # same as "set(foo_var bar)"
Dereferencing an unset variable results in an empty expansion. It is a common
pattern in CMake to conditionally set variables knowing that it will be used in
code paths that the variable isn't set. There are examples of this throughout
the LLVM CMake build system.
An example of variable empty expansion is:
.. code-block:: cmake
if(APPLE)
set(extra_sources Apple.cpp)
endif()
add_executable(HelloWorld HelloWorld.cpp ${extra_sources})
In this example the ``extra_sources`` variable is only defined if you're
targeting an Apple platform. For all other targets the ``extra_sources`` will be
evaluated as empty before add_executable is given its arguments.
One big "Gotcha" with variable dereferencing is that ``if`` commands implicitly
dereference values. This has some unexpected results. For example:
.. code-block:: cmake
if("${SOME_VAR}" STREQUAL "MSVC")
In this code sample MSVC will be implicitly dereferenced, which will result in
the if command comparing the value of the dereferenced variables ``SOME_VAR``
and ``MSVC``. A common workaround to this solution is to prepend strings being
compared with an ``x``.
.. code-block:: cmake
if("x${SOME_VAR}" STREQUAL "xMSVC")
This works because while ``MSVC`` is a defined variable, ``xMSVC`` is not. This
pattern is uncommon, but it does occur in LLVM's CMake scripts.
.. note::
Once the LLVM project upgrades its minimum CMake version to 3.1 or later we
can prevent this behavior by setting CMP0054 to new. For more information on
CMake policies please see the cmake-policies manpage or the `cmake-policies
online documentation
<https://cmake.org/cmake/help/v3.4/manual/cmake-policies.7.html>`_.
Lists
-----
In CMake lists are semi-colon delimited strings, and it is strongly advised that
you avoid using semi-colons in lists; it doesn't go smoothly. A few examples of
defining lists:
.. code-block:: cmake
# Creates a list with members a, b, c, and d
set(my_list a b c d)
set(my_list "a;b;c;d")
# Creates a string "a b c d"
set(my_string "a b c d")
Lists of Lists
--------------
One of the more complicated patterns in CMake is lists of lists. Because a list
cannot contain an element with a semi-colon to construct a list of lists you
make a list of variable names that refer to other lists. For example:
.. code-block:: cmake
set(list_of_lists a b c)
set(a 1 2 3)
set(b 4 5 6)
set(c 7 8 9)
With this layout you can iterate through the list of lists printing each value
with the following code:
.. code-block:: cmake
foreach(list_name IN LISTS list_of_lists)
foreach(value IN LISTS ${list_name})
message(${value})
endforeach()
endforeach()
You'll notice that the inner foreach loop's list is doubly dereferenced. This is
because the first dereference turns ``list_name`` into the name of the sub-list
(a, b, or c in the example), then the second dereference is to get the value of
the list.
This pattern is used throughout CMake, the most common example is the compiler
flags options, which CMake refers to using the following variable expansions:
CMAKE_${LANGUAGE}_FLAGS and CMAKE_${LANGUAGE}_FLAGS_${CMAKE_BUILD_TYPE}.
Other Types
-----------
Variables that are cached or specified on the command line can have types
associated with them. The variable's type is used by CMake's UI tool to display
the right input field. The variable's type generally doesn't impact evaluation.
One of the few examples is PATH variables, which CMake does have some special
handling for. You can read more about the special handling in `CMake's set
documentation
<https://cmake.org/cmake/help/v3.5/command/set.html#set-cache-entry>`_.
Scope
-----
CMake inherently has a directory-based scoping. Setting a variable in a
CMakeLists file, will set the variable for that file, and all subdirectories.
Variables set in a CMake module that is included in a CMakeLists file will be
set in the scope they are included from, and all subdirectories.
When a variable that is already set is set again in a subdirectory it overrides
the value in that scope and any deeper subdirectories.
The CMake set command provides two scope-related options. PARENT_SCOPE sets a
variable into the parent scope, and not the current scope. The CACHE option sets
the variable in the CMakeCache, which results in it being set in all scopes. The
CACHE option will not set a variable that already exists in the CACHE unless the
FORCE option is specified.
In addition to directory-based scope, CMake functions also have their own scope.
This means variables set inside functions do not bleed into the parent scope.
This is not true of macros, and it is for this reason LLVM prefers functions
over macros whenever reasonable.
.. note::
Unlike C-based languages, CMake's loop and control flow blocks do not have
their own scopes.
Control Flow
============
CMake features the same basic control flow constructs you would expect in any
scripting language, but there are a few quarks because, as with everything in
CMake, control flow constructs are commands.
If, ElseIf, Else
----------------
.. note::
For the full documentation on the CMake if command go
`here <https://cmake.org/cmake/help/v3.4/command/if.html>`_. That resource is
far more complete.
In general CMake if blocks work the way you'd expect:
.. code-block:: cmake
if(<condition>)
.. do stuff
elseif(<condition>)
.. do other stuff
else()
.. do other other stuff
endif()
The single most important thing to know about CMake's if blocks coming from a C
background is that they do not have their own scope. Variables set inside
conditional blocks persist after the ``endif()``.
Loops
-----
The most common form of the CMake ``foreach`` block is:
.. code-block:: cmake
foreach(var ...)
.. do stuff
endforeach()
The variable argument portion of the ``foreach`` block can contain dereferenced
lists, values to iterate, or a mix of both:
.. code-block:: cmake
foreach(var foo bar baz)
message(${var})
endforeach()
# prints:
# foo
# bar
# baz
set(my_list 1 2 3)
foreach(var ${my_list})
message(${var})
endforeach()
# prints:
# 1
# 2
# 3
foreach(var ${my_list} out_of_bounds)
message(${var})
endforeach()
# prints:
# 1
# 2
# 3
# out_of_bounds
There is also a more modern CMake foreach syntax. The code below is equivalent
to the code above:
.. code-block:: cmake
foreach(var IN ITEMS foo bar baz)
message(${var})
endforeach()
# prints:
# foo
# bar
# baz
set(my_list 1 2 3)
foreach(var IN LISTS my_list)
message(${var})
endforeach()
# prints:
# 1
# 2
# 3
foreach(var IN LISTS my_list ITEMS out_of_bounds)
message(${var})
endforeach()
# prints:
# 1
# 2
# 3
# out_of_bounds
Similar to the conditional statements, these generally behave how you would
expect, and they do not have their own scope.
CMake also supports ``while`` loops, although they are not widely used in LLVM.
Modules, Functions and Macros
=============================
Modules
-------
Modules are CMake's vehicle for enabling code reuse. CMake modules are just
CMake script files. They can contain code to execute on include as well as
definitions for commands.
In CMake macros and functions are universally referred to as commands, and they
are the primary method of defining code that can be called multiple times.
In LLVM we have several CMake modules that are included as part of our
distribution for developers who don't build our project from source. Those
modules are the fundamental pieces needed to build LLVM-based projects with
CMake. We also rely on modules as a way of organizing the build system's
functionality for maintainability and re-use within LLVM projects.
Argument Handling
-----------------
When defining a CMake command handling arguments is very useful. The examples
in this section will all use the CMake ``function`` block, but this all applies
to the ``macro`` block as well.
CMake commands can have named arguments, but all commands are implicitly
variable argument. If the command has named arguments they are required and must
be specified at every call site. Below is a trivial example of providing a
wrapper function for CMake's built in function ``add_dependencies``.
.. code-block:: cmake
function(add_deps target)
add_dependencies(${target} ${ARGV})
endfunction()
This example defines a new macro named ``add_deps`` which takes a required first
argument, and just calls another function passing through the first argument and
all trailing arguments. When variable arguments are present CMake defines them
in a list named ``ARGV``, and the count of the arguments is defined in ``ARGN``.
CMake provides a module ``CMakeParseArguments`` which provides an implementation
of advanced argument parsing. We use this all over LLVM, and it is recommended
for any function that has complex argument-based behaviors or optional
arguments. CMake's official documentation for the module is in the
``cmake-modules`` manpage, and is also available at the
`cmake-modules online documentation
<https://cmake.org/cmake/help/v3.4/module/CMakeParseArguments.html>`_.
.. note::
As of CMake 3.5 the cmake_parse_arguments command has become a native command
and the CMakeParseArguments module is empty and only left around for
compatibility.
Functions Vs Macros
-------------------
Functions and Macros look very similar in how they are used, but there is one
fundamental difference between the two. Functions have their own scope, and
macros don't. This means variables set in macros will bleed out into the calling
scope. That makes macros suitable for defining very small bits of functionality
only.
The other difference between CMake functions and macros is how arguments are
passed. Arguments to macros are not set as variables, instead dereferences to
the parameters are resolved across the macro before executing it. This can
result in some unexpected behavior if using unreferenced variables. For example:
.. code-block:: cmake
macro(print_list my_list)
foreach(var IN LISTS my_list)
message("${var}")
endforeach()
endmacro()
set(my_list a b c d)
set(my_list_of_numbers 1 2 3 4)
print_list(my_list_of_numbers)
# prints:
# a
# b
# c
# d
Generally speaking this issue is uncommon because it requires using
non-dereferenced variables with names that overlap in the parent scope, but it
is important to be aware of because it can lead to subtle bugs.
LLVM Project Wrappers
=====================
LLVM projects provide lots of wrappers around critical CMake built-in commands.
We use these wrappers to provide consistent behaviors across LLVM components
and to reduce code duplication.
We generally (but not always) follow the convention that commands prefaced with
``llvm_`` are intended to be used only as building blocks for other commands.
Wrapper commands that are intended for direct use are generally named following
with the project in the middle of the command name (i.e. ``add_llvm_executable``
is the wrapper for ``add_executable``). The LLVM ``add_*`` wrapper functions are
all defined in ``AddLLVM.cmake`` which is installed as part of the LLVM
distribution. It can be included and used by any LLVM sub-project that requires
LLVM.
.. note::
Not all LLVM projects require LLVM for all use cases. For example compiler-rt
can be built without LLVM, and the compiler-rt sanitizer libraries are used
with GCC.
Useful Built-in Commands
========================
CMake has a bunch of useful built-in commands. This document isn't going to
go into details about them because The CMake project has excellent
documentation. To highlight a few useful functions see:
* `add_custom_command <https://cmake.org/cmake/help/v3.4/command/add_custom_command.html>`_
* `add_custom_target <https://cmake.org/cmake/help/v3.4/command/add_custom_target.html>`_
* `file <https://cmake.org/cmake/help/v3.4/command/file.html>`_
* `list <https://cmake.org/cmake/help/v3.4/command/list.html>`_
* `math <https://cmake.org/cmake/help/v3.4/command/math.html>`_
* `string <https://cmake.org/cmake/help/v3.4/command/string.html>`_
The full documentation for CMake commands is in the ``cmake-commands`` manpage
and available on `CMake's website <https://cmake.org/cmake/help/v3.4/manual/cmake-commands.7.html>`_

View File

@ -45,7 +45,7 @@ components:
``include/llvm/CodeGen/``. At this level, concepts like "constant pool
entries" and "jump tables" are explicitly exposed.
3. Classes and algorithms used to represent code as the object file level, the
3. Classes and algorithms used to represent code at the object file level, the
`MC Layer`_. These classes represent assembly level constructs like labels,
sections, and instructions. At this level, concepts like "constant pool
entries" and "jump tables" don't exist.
@ -386,32 +386,27 @@ functions make it easy to build arbitrary machine instructions. Usage of the
.. code-block:: c++
// Create a 'DestReg = mov 42' (rendered in X86 assembly as 'mov DestReg, 42')
// instruction. The '1' specifies how many operands will be added.
MachineInstr *MI = BuildMI(X86::MOV32ri, 1, DestReg).addImm(42);
// Create the same instr, but insert it at the end of a basic block.
// instruction and insert it at the end of the given MachineBasicBlock.
const TargetInstrInfo &TII = ...
MachineBasicBlock &MBB = ...
BuildMI(MBB, X86::MOV32ri, 1, DestReg).addImm(42);
DebugLoc DL;
MachineInstr *MI = BuildMI(MBB, DL, TII.get(X86::MOV32ri), DestReg).addImm(42);
// Create the same instr, but insert it before a specified iterator point.
MachineBasicBlock::iterator MBBI = ...
BuildMI(MBB, MBBI, X86::MOV32ri, 1, DestReg).addImm(42);
BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), DestReg).addImm(42);
// Create a 'cmp Reg, 0' instruction, no destination reg.
MI = BuildMI(X86::CMP32ri, 2).addReg(Reg).addImm(0);
MI = BuildMI(MBB, DL, TII.get(X86::CMP32ri8)).addReg(Reg).addImm(42);
// Create an 'sahf' instruction which takes no operands and stores nothing.
MI = BuildMI(X86::SAHF, 0);
MI = BuildMI(MBB, DL, TII.get(X86::SAHF));
// Create a self looping branch instruction.
BuildMI(MBB, X86::JNE, 1).addMBB(&MBB);
BuildMI(MBB, DL, TII.get(X86::JNE)).addMBB(&MBB);
The key thing to remember with the ``BuildMI`` functions is that you have to
specify the number of operands that the machine instruction will take. This
allows for efficient memory allocation. You also need to specify if operands
default to be uses of values, not definitions. If you need to add a definition
operand (other than the optional destination register), you must explicitly mark
it as such:
If you need to add a definition operand (other than the optional destination
register), you must explicitly mark it as such:
.. code-block:: c++
@ -632,7 +627,7 @@ directives through MCStreamer.
On the implementation side of MCStreamer, there are two major implementations:
one for writing out a .s file (MCAsmStreamer), and one for writing out a .o
file (MCObjectStreamer). MCAsmStreamer is a straight-forward implementation
file (MCObjectStreamer). MCAsmStreamer is a straightforward implementation
that prints out a directive for each method (e.g. ``EmitValue -> .byte``), but
MCObjectStreamer implements a full assembler.
@ -1771,13 +1766,11 @@ table that summarizes what features are supported by each target.
Target Feature Matrix
---------------------
Note that this table does not include the C backend or Cpp backends, since they
do not use the target independent code generator infrastructure. It also
doesn't list features that are not supported fully by any target yet. It
considers a feature to be supported if at least one subtarget supports it. A
feature being supported means that it is useful and works for most cases, it
does not indicate that there are zero known bugs in the implementation. Here is
the key:
Note that this table does not list features that are not supported fully by any
target yet. It considers a feature to be supported if at least one subtarget
supports it. A feature being supported means that it is useful and works for
most cases, it does not indicate that there are zero known bugs in the
implementation. Here is the key:
:raw-html:`<table border="1" cellspacing="0">`
:raw-html:`<tr>`
@ -2197,9 +2190,9 @@ prefix byte on an instruction causes the instruction's memory access to go to
the specified segment. LLVM address space 0 is the default address space, which
includes the stack, and any unqualified memory accesses in a program. Address
spaces 1-255 are currently reserved for user-defined code. The GS-segment is
represented by address space 256, while the FS-segment is represented by address
space 257. Other x86 segments have yet to be allocated address space
numbers.
represented by address space 256, the FS-segment is represented by address space
257, and the SS-segment is represented by address space 258. Other x86 segments
have yet to be allocated address space numbers.
While these address spaces may seem similar to TLS via the ``thread_local``
keyword, and often use the same underlying hardware, there are some fundamental
@ -2645,3 +2638,59 @@ of a program is limited to 4K instructions: this ensures fast termination and
a limited number of kernel function calls. Prior to running an eBPF program,
a verifier performs static analysis to prevent loops in the code and
to ensure valid register usage and operand types.
The AMDGPU backend
------------------
The AMDGPU code generator lives in the lib/Target/AMDGPU directory, and is an
open source native AMD GCN ISA code generator.
Target triples supported
^^^^^^^^^^^^^^^^^^^^^^^^
The following are the known target triples that are supported by the AMDGPU
backend.
* **amdgcn--** --- AMD GCN GPUs (AMDGPU.7.0.0+)
* **amdgcn--amdhsa** --- AMD GCN GPUs (AMDGPU.7.0.0+) with HSA support
* **r600--** --- AMD GPUs HD2XXX-HD6XXX
Relocations
^^^^^^^^^^^
Supported relocatable fields are:
* **word32** --- This specifies a 32-bit field occupying 4 bytes with arbitrary
byte alignment. These values use the same byte order as other word values in
the AMD GPU architecture
* **word64** --- This specifies a 64-bit field occupying 8 bytes with arbitrary
byte alignment. These values use the same byte order as other word values in
the AMD GPU architecture
Following notations are used for specifying relocation calculations:
* **A** --- Represents the addend used to compute the value of the relocatable
field
* **G** --- Represents the offset into the global offset table at which the
relocation entrys symbol will reside during execution.
* **GOT** --- Represents the address of the global offset table.
* **P** --- Represents the place (section offset or address) of the storage unit
being relocated (computed using ``r_offset``)
* **S** --- Represents the value of the symbol whose index resides in the
relocation entry
AMDGPU Backend generates *Elf64_Rela* relocation records with the following
supported relocation types:
===================== ===== ========== ====================
Relocation type Value Field Calculation
===================== ===== ========== ====================
``R_AMDGPU_NONE`` 0 ``none`` ``none``
``R_AMDGPU_ABS32_LO`` 1 ``word32`` (S + A) & 0xFFFFFFFF
``R_AMDGPU_ABS32_HI`` 2 ``word32`` (S + A) >> 32
``R_AMDGPU_ABS64`` 3 ``word64`` S + A
``R_AMDGPU_REL32`` 4 ``word32`` S + A - P
``R_AMDGPU_REL64`` 5 ``word64`` S + A - P
``R_AMDGPU_ABS32`` 6 ``word32`` S + A
``R_AMDGPU_GOTPCREL`` 7 ``word32`` G + GOT + A - P
===================== ===== ========== ====================

112
docs/CodeOfConduct.rst Normal file
View File

@ -0,0 +1,112 @@
==============================
LLVM Community Code of Conduct
==============================
.. note::
This document is currently a **DRAFT** document while it is being discussed
by the community.
The LLVM community has always worked to be a welcoming and respectful
community, and we want to ensure that doesn't change as we grow and evolve. To
that end, we have a few ground rules that we ask people to adhere to:
* `be friendly and patient`_,
* `be welcoming`_,
* `be considerate`_,
* `be respectful`_,
* `be careful in the words that you choose and be kind to others`_, and
* `when we disagree, try to understand why`_.
This isn't an exhaustive list of things that you can't do. Rather, take it in
the spirit in which it's intended - a guide to make it easier to communicate
and participate in the community.
This code of conduct applies to all spaces managed by the LLVM project or The
LLVM Foundation. This includes IRC channels, mailing lists, bug trackers, LLVM
events such as the developer meetings and socials, and any other forums created
by the project that the community uses for communication. It applies to all of
your communication and conduct in these spaces, including emails, chats, things
you say, slides, videos, posters, signs, or even t-shirts you display in these
spaces. In addition, violations of this code outside these spaces may, in rare
cases, affect a person's ability to participate within them, when the conduct
amounts to an egregious violation of this code.
If you believe someone is violating the code of conduct, we ask that you report
it by emailing conduct@llvm.org. For more details please see our
:doc:`Reporting Guide <ReportingGuide>`.
.. _be friendly and patient:
* **Be friendly and patient.**
.. _be welcoming:
* **Be welcoming.** We strive to be a community that welcomes and supports
people of all backgrounds and identities. This includes, but is not limited
to members of any race, ethnicity, culture, national origin, colour,
immigration status, social and economic class, educational level, sex, sexual
orientation, gender identity and expression, age, size, family status,
political belief, religion or lack thereof, and mental and physical ability.
.. _be considerate:
* **Be considerate.** Your work will be used by other people, and you in turn
will depend on the work of others. Any decision you take will affect users
and colleagues, and you should take those consequences into account. Remember
that we're a world-wide community, so you might not be communicating in
someone else's primary language.
.. _be respectful:
* **Be respectful.** Not all of us will agree all the time, but disagreement is
no excuse for poor behavior and poor manners. We might all experience some
frustration now and then, but we cannot allow that frustration to turn into
a personal attack. It's important to remember that a community where people
feel uncomfortable or threatened is not a productive one. Members of the LLVM
community should be respectful when dealing with other members as well as
with people outside the LLVM community.
.. _be careful in the words that you choose and be kind to others:
* **Be careful in the words that you choose and be kind to others.** Do not
insult or put down other participants. Harassment and other exclusionary
behavior aren't acceptable. This includes, but is not limited to:
* Violent threats or language directed against another person.
* Discriminatory jokes and language.
* Posting sexually explicit or violent material.
* Posting (or threatening to post) other people's personally identifying
information ("doxing").
* Personal insults, especially those using racist or sexist terms.
* Unwelcome sexual attention.
* Advocating for, or encouraging, any of the above behavior.
In general, if someone asks you to stop, then stop. Persisting in such
behavior after being asked to stop is considered harassment.
.. _when we disagree, try to understand why:
* **When we disagree, try to understand why.** Disagreements, both social and
technical, happen all the time and LLVM is no exception. It is important that
we resolve disagreements and differing views constructively. Remember that
we're different. The strength of LLVM comes from its varied community, people
from a wide range of backgrounds. Different people have different
perspectives on issues. Being unable to understand why someone holds
a viewpoint doesn't mean that they're wrong. Don't forget that it is human to
err and blaming each other doesn't get us anywhere. Instead, focus on helping
to resolve issues and learning from mistakes.
Questions?
==========
If you have questions, please feel free to contact the LLVM Foundation Code of
Conduct Advisory Committee by emailing conduct@llvm.org.
(This text is based on the `Django Project`_ Code of Conduct, which is in turn
based on wording from the `Speak Up! project`_.)
.. _Django Project: https://www.djangoproject.com/conduct/
.. _Speak Up! project: http://speakup.io/coc.html

Some files were not shown because too many files have changed in this diff Show More