-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396]. * Embedded compiler: development [#CLICKHOUSE-3396].
- Loading branch information
1 parent
e846d62
commit 9b18c6c
Showing
26 changed files
with
1,825 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
option (USE_EMBEDDED_COMPILER "Set to TRUE to enable support for 'compile' option for query execution" FALSE) | ||
|
||
if (USE_EMBEDDED_COMPILER) | ||
# Based on source code of YT. | ||
# Authors: Ivan Puzyrevskiy, Alexey Lukyanchikov, Ruslan Savchenko. | ||
|
||
# Find LLVM includes and libraries. | ||
# | ||
# LLVM_VERSION - LLVM version. | ||
# LLVM_INCLUDE_DIRS - Directory containing LLVM headers. | ||
# LLVM_LIBRARY_DIRS - Directory containing LLVM libraries. | ||
# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers. | ||
# LLVM_FOUND - True if LLVM was found. | ||
|
||
# llvm_map_components_to_libraries - Maps LLVM used components to required libraries. | ||
# Usage: llvm_map_components_to_libraries(REQUIRED_LLVM_LIBRARIES core jit interpreter native ...) | ||
|
||
find_program(LLVM_CONFIG_EXECUTABLE | ||
NAMES llvm-config | ||
PATHS $ENV{LLVM_ROOT}/bin) | ||
|
||
mark_as_advanced(LLVM_CONFIG_EXECUTABLE) | ||
|
||
if(NOT LLVM_CONFIG_EXECUTABLE) | ||
message(FATAL_ERROR "Cannot find LLVM (looking for `llvm-config`). Please, provide LLVM_ROOT environment variable.") | ||
else() | ||
set(LLVM_FOUND TRUE) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --version | ||
OUTPUT_VARIABLE LLVM_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if(LLVM_VERSION VERSION_LESS "5") | ||
message(FATAL_ERROR "LLVM 5+ is required.") | ||
endif() | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir | ||
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir | ||
OUTPUT_VARIABLE LLVM_LIBRARY_DIRS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --cxxflags | ||
OUTPUT_VARIABLE LLVM_CXXFLAGS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --targets-built | ||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT}") | ||
|
||
# Get the link libs we need. | ||
function(llvm_map_components_to_libraries RESULT) | ||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs ${ARGN} | ||
OUTPUT_VARIABLE _tmp | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
string(REPLACE " " ";" _libs_module "${_tmp}") | ||
|
||
message(STATUS "LLVM Libraries for '${ARGN}': ${_libs_module}") | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs ${ARGN} | ||
OUTPUT_VARIABLE _libs_system | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
string(REPLACE "\n" " " _libs_system "${_libs_system}") | ||
string(REPLACE " " " " _libs_system "${_libs_system}") | ||
string(REPLACE " " ";" _libs_system "${_libs_system}") | ||
|
||
set(${RESULT} ${_libs_module} ${_libs_system} PARENT_SCOPE) | ||
endfunction(llvm_map_components_to_libraries) | ||
|
||
message(STATUS "LLVM Include Directory: ${LLVM_INCLUDE_DIRS}") | ||
message(STATUS "LLVM Library Directory: ${LLVM_LIBRARY_DIRS}") | ||
message(STATUS "LLVM C++ Compiler: ${LLVM_CXXFLAGS}") | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
add_library(clickhouse-compiler | ||
driver.cpp | ||
cc1_main.cpp | ||
cc1as_main.cpp | ||
lld.cpp) | ||
|
||
target_compile_options(clickhouse-compiler PRIVATE -fno-rtti) | ||
|
||
llvm_map_components_to_libraries(REQUIRED_LLVM_LIBRARIES all) | ||
|
||
# We link statically with zlib, and LLVM (sometimes) tries to bring its own dependency. | ||
list(REMOVE_ITEM REQUIRED_LLVM_LIBRARIES "-lz") | ||
|
||
# This is extracted almost directly from CMakeFiles/.../link.txt in LLVM build directory. | ||
|
||
target_link_libraries(clickhouse-compiler | ||
|
||
clangBasic clangCodeGen clangDriver clangFrontend clangFrontendTool | ||
clangRewriteFrontend clangARCMigrate clangStaticAnalyzerFrontend | ||
clangParse clangSerialization clangSema clangEdit clangStaticAnalyzerCheckers | ||
clangASTMatchers clangStaticAnalyzerCore clangAnalysis clangAST clangRewrite clangLex clangBasic | ||
|
||
lldCOFF | ||
lldDriver | ||
lldELF | ||
lldMinGW | ||
lldMachO | ||
lldReaderWriter | ||
lldYAML | ||
lldCommon | ||
lldCore | ||
|
||
${REQUIRED_LLVM_LIBRARIES} | ||
|
||
Polly | ||
PollyISL | ||
PollyPPCG | ||
|
||
libtinfo.a | ||
common) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
============================================================================== | ||
LLVM Release License | ||
============================================================================== | ||
University of Illinois/NCSA | ||
Open Source License | ||
|
||
Copyright (c) 2007-2016 University of Illinois at Urbana-Champaign. | ||
All rights reserved. | ||
|
||
Developed by: | ||
|
||
LLVM Team | ||
|
||
University of Illinois at Urbana-Champaign | ||
|
||
http://llvm.org | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal with | ||
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: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimers. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimers in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
* Neither the names of the LLVM Team, University of Illinois at | ||
Urbana-Champaign, nor the names of its contributors may be used to | ||
endorse or promote products derived from this Software without specific | ||
prior written permission. | ||
|
||
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 | ||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE | ||
SOFTWARE. | ||
|
||
============================================================================== | ||
The LLVM software contains code written by third parties. Such software will | ||
have its own individual LICENSE.TXT file in the directory in which it appears. | ||
This file will describe the copyrights, license, and restrictions which apply | ||
to that code. | ||
|
||
The disclaimer of warranty in the University of Illinois Open Source License | ||
applies to all code in the LLVM Distribution, and nothing in any of the | ||
other licenses gives permission to use the names of the LLVM Team or the | ||
University of Illinois to endorse or promote products derived from this | ||
Software. | ||
|
||
The following pieces of software have additional or alternate copyrights, | ||
licenses, and/or restrictions: | ||
|
||
Program Directory | ||
------- --------- | ||
<none yet> | ||
|
Oops, something went wrong.