2021-10-12 20:51:03 +01:00
|
|
|
# Serene Programming Language
|
2021-09-27 13:05:15 +01:00
|
|
|
#
|
2022-01-27 11:44:44 +00:00
|
|
|
# Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
2021-09-27 13:05:15 +01:00
|
|
|
#
|
2021-10-12 20:51:03 +01:00
|
|
|
# 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, version 2.
|
2021-09-27 13:05:15 +01:00
|
|
|
#
|
2021-10-12 20:51:03 +01:00
|
|
|
# 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.
|
2021-09-27 13:05:15 +01:00
|
|
|
#
|
2021-10-12 20:51:03 +01:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-03-23 22:31:20 +00:00
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
#TODO: To support MacOS look into cmake's public headers
|
|
|
|
# https://cmake.org/cmake/help/latest/prop_tgt/PUBLIC_HEADER.html
|
2021-09-28 17:11:50 +01:00
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
# Hide all the symbols by default
|
2021-10-12 14:45:46 +01:00
|
|
|
if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND
|
2021-10-10 21:34:14 +01:00
|
|
|
NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
|
|
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
|
2021-10-12 14:45:46 +01:00
|
|
|
endif()
|
2021-09-28 17:11:50 +01:00
|
|
|
|
2021-10-12 14:45:46 +01:00
|
|
|
# Prevent any future RPATH issue on Posix
|
|
|
|
if(NOT APPLE)
|
|
|
|
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
|
|
|
endif()
|
2021-10-10 21:34:14 +01:00
|
|
|
|
|
|
|
add_library(serene
|
2021-04-05 19:02:30 +01:00
|
|
|
exprs/symbol.cpp
|
|
|
|
exprs/list.cpp
|
2021-04-11 00:02:56 +01:00
|
|
|
exprs/number.cpp
|
2021-04-17 19:36:25 +01:00
|
|
|
exprs/expression.cpp
|
|
|
|
exprs/def.cpp
|
2021-04-24 14:39:43 +01:00
|
|
|
exprs/fn.cpp
|
2021-05-09 12:21:26 +01:00
|
|
|
exprs/call.cpp
|
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
serene.cpp
|
2021-05-09 12:21:26 +01:00
|
|
|
context.cpp
|
2020-07-25 15:49:19 +01:00
|
|
|
namespace.cpp
|
2021-09-05 15:57:28 +01:00
|
|
|
source_mgr.cpp
|
2021-09-12 14:01:02 +01:00
|
|
|
diagnostics.cpp
|
2021-11-17 17:37:45 +00:00
|
|
|
semantics.cpp
|
2021-03-28 23:14:32 +01:00
|
|
|
|
2021-11-01 15:09:11 +00:00
|
|
|
# jit.cpp
|
|
|
|
jit/engine.cpp
|
|
|
|
jit/layers.cpp
|
2021-12-30 13:52:33 +00:00
|
|
|
jit/halley.cpp
|
2021-11-01 15:09:11 +00:00
|
|
|
|
2022-02-04 22:47:01 +00:00
|
|
|
errors.cpp
|
2021-12-31 12:02:25 +00:00
|
|
|
|
2021-03-28 23:14:32 +01:00
|
|
|
# Reader
|
|
|
|
reader/reader.cpp
|
|
|
|
|
|
|
|
# IR
|
2021-08-15 12:06:56 +01:00
|
|
|
slir/slir.cpp
|
2021-06-08 22:01:08 +01:00
|
|
|
slir/dialect.cpp
|
|
|
|
slir/value_op.cpp
|
2021-06-13 22:40:58 +01:00
|
|
|
slir/generatable.cpp
|
|
|
|
slir/utils.cpp
|
2021-06-23 20:34:57 +01:00
|
|
|
slir/ops.cpp
|
2021-06-11 22:06:44 +01:00
|
|
|
passes/slir_lowering.cpp
|
2021-06-17 13:19:19 +01:00
|
|
|
passes/to_llvm_dialect.cpp
|
2021-09-27 13:05:15 +01:00
|
|
|
)
|
2021-03-28 23:14:32 +01:00
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
# Create an ALIAS target. This way if we mess up the name
|
|
|
|
# there will be an cmake error inseat of a linker error which is harder
|
|
|
|
# to understand. So any binary that wants to use serene has to
|
|
|
|
# use `Serene::lib` alias instead
|
|
|
|
add_library(Serene::lib ALIAS serene)
|
|
|
|
|
|
|
|
set_target_properties(serene PROPERTIES
|
|
|
|
VERSION ${PROJECT_VERSION}
|
2021-10-10 22:28:50 +01:00
|
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
|
# Warn on unused libs
|
|
|
|
LINK_WHAT_YOU_USE TRUE
|
|
|
|
# LTO support
|
|
|
|
INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
|
|
|
2021-10-17 22:22:49 +01:00
|
|
|
if(SERENE_ENABLE_TIDY)
|
|
|
|
set_target_properties(serene PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
|
|
|
|
endif()
|
2021-10-10 21:34:14 +01:00
|
|
|
|
|
|
|
# Do we need to build serene as a shared lib? default is "yes"
|
|
|
|
if(SERENE_SHARED_LIB)
|
|
|
|
|
|
|
|
# We need to use libsan as a shared lib on debug mode. The
|
|
|
|
# target executable has to be built with `-fsanitize=address`
|
|
|
|
# as well and it has to run with:
|
|
|
|
# LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so)
|
|
|
|
target_compile_options(serene PRIVATE
|
|
|
|
$<$<CONFIG:DEBUG>:-shared-libsan>
|
|
|
|
)
|
|
|
|
target_link_options(
|
|
|
|
serene PRIVATE
|
|
|
|
$<$<CONFIG:DEBUG>:-shared-libsan>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2021-04-07 19:56:54 +01:00
|
|
|
if (CPP_20_SUPPORT)
|
2021-10-10 21:34:14 +01:00
|
|
|
target_compile_features(serene PUBLIC cxx_std_20)
|
2021-04-07 19:56:54 +01:00
|
|
|
else()
|
2021-10-10 21:34:14 +01:00
|
|
|
target_compile_features(serene PUBLIC cxx_std_17)
|
2021-04-07 19:56:54 +01:00
|
|
|
endif()
|
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
# Generate the tablegen ODS files before this target
|
2022-01-27 11:29:58 +00:00
|
|
|
add_dependencies(serene SereneTablegen SereneDialectGen SereneErrorGen)
|
2021-04-07 19:56:54 +01:00
|
|
|
|
2020-07-10 18:06:26 +01:00
|
|
|
# We need this directory, and users of our library will need it too
|
2021-10-10 21:34:14 +01:00
|
|
|
target_include_directories(serene PUBLIC "$<BUILD_INTERFACE:${INCLUDE_DIR}>")
|
|
|
|
target_include_directories(serene PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>")
|
|
|
|
|
|
|
|
# Generate the export.h
|
|
|
|
include(GenerateExportHeader)
|
|
|
|
generate_export_header(serene EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/serene/export.h)
|
|
|
|
target_compile_definitions(
|
|
|
|
serene PUBLIC "$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:SERENE_STATIC_DEFINE>")
|
2021-06-17 13:19:19 +01:00
|
|
|
|
|
|
|
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
|
|
|
|
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
|
2021-09-28 17:11:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
if(SERENE_SHOW_MLIR_DIALECTS)
|
|
|
|
message(STATUS "MLIR Dialects to choose from:")
|
|
|
|
foreach(lib ${dialect_libs})
|
|
|
|
message(STATUS "\t${lib}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if(SERENE_SHOW_MLIR_TRANSFORMERS)
|
|
|
|
message(STATUS "MLIR Dialects transformers to choose from:")
|
|
|
|
foreach(lib ${conversion_libs})
|
|
|
|
message(STATUS "\t${lib}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SERENE_SHOW_LLVM_LIBS)
|
|
|
|
execute_process(COMMAND llvm-config --libs all
|
|
|
|
OUTPUT_VARIABLE SERENE_LLVM_LIBS)
|
|
|
|
message(STATUS "LLVM libs available:\n ${SERENE_LLVM_LIBS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
set(serene_lib_dialects_in_use
|
|
|
|
MLIRStandard)
|
|
|
|
|
|
|
|
set(serene_lib_transformers_in_use
|
|
|
|
MLIRStandardToLLVM)
|
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
target_link_libraries(serene PRIVATE
|
2021-09-28 17:11:50 +01:00
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
|
|
|
MLIRTransforms
|
|
|
|
|
|
|
|
${serene_lib_dialects_in_use}
|
|
|
|
${serene_lib_transformers_in_use}
|
|
|
|
|
2021-10-10 21:34:14 +01:00
|
|
|
#TODO: Remove this lib, we're just using one func
|
|
|
|
MLIRExecutionEngine
|
|
|
|
|
2021-09-28 17:11:50 +01:00
|
|
|
# LLVM's JIT lib
|
|
|
|
LLVMExecutionEngine
|
|
|
|
LLVMOrcJIT
|
|
|
|
MLIRLLVMToLLVMIRTranslation
|
|
|
|
|
2022-01-05 16:18:32 +00:00
|
|
|
LLVMTarget
|
|
|
|
LLVMX86AsmParser
|
2021-09-28 17:11:50 +01:00
|
|
|
|
|
|
|
${llvm_libs})
|