diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index e9a6faa37c36b..796844a896243 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -149,7 +149,7 @@ endforeach() # As we migrate runtimes to using the bootstrapping build, the set of default runtimes # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above. set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind") -set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc;libsycl") +set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc;libsycl;orc-rt") set(LLVM_ENABLE_RUNTIMES "" CACHE STRING "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.") if(LLVM_ENABLE_RUNTIMES STREQUAL "all") diff --git a/llvm/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt index f254cf10806d7..f5f7c98826c2d 100644 --- a/llvm/projects/CMakeLists.txt +++ b/llvm/projects/CMakeLists.txt @@ -9,6 +9,7 @@ foreach(entry ${entries}) (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxx) AND (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxxabi) AND (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND + (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/orc-rt) AND (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/test-suite) AND (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/openmp) AND (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/cross-project-tests) AND @@ -34,6 +35,7 @@ if(${LLVM_BUILD_RUNTIME}) add_llvm_external_project(libc) add_llvm_external_project(libcxxabi) add_llvm_external_project(libcxx) + add_llvm_external_project(orc-rt) endif() if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT) add_llvm_external_project(compiler-rt) diff --git a/orc-rt/CMakeLists.txt b/orc-rt/CMakeLists.txt new file mode 100644 index 0000000000000..9b70bae346ceb --- /dev/null +++ b/orc-rt/CMakeLists.txt @@ -0,0 +1,96 @@ +# CMake build for ORC-RT. + +#=============================================================================== +# Setup Project +#=============================================================================== + +cmake_minimum_required(VERSION 3.20.0) + +option(LLVM_RT_INCLUDE_TESTS "Build orcrt tests." ${LLVM_INCLUDE_TESTS}) + + +set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) +include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake + NO_POLICY_SCOPE) + +if (ORC_RT_INCLUDE_TESTS) + set(LLVM_INCLUDE_UTILS YES) +endif() + +project(OrcRT LANGUAGES C CXX ASM) + +include(GNUInstallDirs) + +#=============================================================================== +# Setup CMake Options +#=============================================================================== + +option(ORC_RT_INCLUDE_DOCS "Build the ORC-RT documentation." ON) +option(ORC_RT_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) +option(ORC_RT_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(ORC_RT_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) + +set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") +set(CMAKE_CXX_STANDARD_REQUIRED YES) +set(CMAKE_CXX_EXTENSIONS NO) +set(CMAKE_FOLDER "orc-rt") + +#=============================================================================== +# Setup Source Code +#=============================================================================== + +if (ORC_RT_INCLUDE_DOCS) + add_subdirectory(docs) +endif() + +add_subdirectory(include) +add_subdirectory(lib) +add_subdirectory(tools) + +if(LLVM_INCLUDE_TESTS) + if(NOT TARGET FileCheck) + find_program(FILECHECK_EXE + NAMES FileCheck + HINTS ${LLVM_RT_TOOLS_BINARY_DIR} + DOC "FileCheck executable") + endif() + if(FILECHECK_EXE) + add_executable(FileCheck IMPORTED GLOBAL) + set_property(TARGET FileCheck PROPERTY IMPORTED_LOCATION "${FILECHECK_EXE}") + message(DEBUG "Using FileCheck: ${FILECHECK_EXE}") + endif() + if(NOT TARGET count) + find_program(COUNT_EXE + NAMES count + HINTS ${LLVM_RT_TOOLS_BINARY_DIR} + DOC "count executable") + endif() + if(COUNT_EXE) + add_executable(count IMPORTED GLOBAL) + set_property(TARGET count PROPERTY IMPORTED_LOCATION "${COUNT_EXE}") + message(DEBUG "Using count: ${COUNT_EXE}") + endif() + if(NOT TARGET not) + find_program(NOT_EXE + NAMES not + HINTS ${LLVM_RT_TOOLS_BINARY_DIR} + DOC "not executable") + endif() + if(NOT_EXE) + add_executable(not IMPORTED GLOBAL) + set_property(TARGET not PROPERTY IMPORTED_LOCATION "${NOT_EXE}") + message(DEBUG "Using not: ${NOT_EXE}") + endif() + + set(ORCRT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(ORCRT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + + add_subdirectory(test) + set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest) + if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) + if (NOT TARGET gtest) + add_subdirectory(${UNITTEST_DIR} third-party/unittest) + endif() + add_subdirectory(unittests) + endif() +endif() \ No newline at end of file diff --git a/orc-rt/LICENSE.TXT b/orc-rt/LICENSE.TXT new file mode 100644 index 0000000000000..53bb2e7fbc764 --- /dev/null +++ b/orc-rt/LICENSE.TXT @@ -0,0 +1,234 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. diff --git a/orc-rt/docs/Building-orc-rt.md b/orc-rt/docs/Building-orc-rt.md new file mode 100644 index 0000000000000..69dbe7f3f3141 --- /dev/null +++ b/orc-rt/docs/Building-orc-rt.md @@ -0,0 +1,74 @@ +# Building orc-rt + +## Getting Started + +The basic steps needed to build orc-rt are: + +* Checkout llvm-project: + + * ``cd where-you-want-llvm-to-live`` + * ``git clone https://github.com/llvm/llvm-project.git`` + +* Configure and build orc-rt: + + CMake is the only supported configuration system. + + Clang is the preferred compiler when building and using orc-rt. + + * ``cd where you want to build llvm`` + * ``mkdir build`` + * ``cd build`` + * ``cmake -G -DLLVM_ENABLE_RUNTIMES=orc-rt [options] /runtimes`` + + For more information about configuring orc-rt see :ref:`CMake Options`. + + * ``make orc-rt`` --- will build orc-rt. + * ``make check-orc-rt`` --- will run the test suite. + + Shared and static libraries for orc-rt should now be present in + llvm/build/lib. + +* **Optional**: Install orc-rt + + Remember to use the CMake option ``CMAKE_INSTALL_PREFIX`` to select a safe + place to install orc-rt. + + * ``make install-orc-rt`` --- Will install the libraries and the headers + +## CMake Options + +Here are some of the CMake variables that are used often, along with a +brief explanation and LLVM-specific notes. For full documentation, check the +CMake docs or execute ``cmake --help-variable VARIABLE_NAME``. + +**CMAKE_BUILD_TYPE**:STRING + Sets the build type for ``make`` based generators. Possible values are + Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio + the user sets the build type with the IDE settings. + +**CMAKE_INSTALL_PREFIX**:PATH + Path where LLVM will be installed if "make install" is invoked or the + "INSTALL" target is built. + +**CMAKE_CXX_COMPILER**:STRING + The C++ compiler to use when building and testing orc-rt. + +## orc-rt specific options + +* option:: ORC_RT_ENABLE_ASSERTIONS:BOOL + + **Default**: ``ON`` + + Toggle assertions independent of the build mode. + +* option:: ORC_RT_ENABLE_PEDANTIC:BOOL + + **Default**: ``ON`` + + Compile with -Wpedantic. + +* option:: ORC_RT_ENABLE_WERROR:BOOL + + **Default**: ``ON`` + + Compile with -Werror diff --git a/orc-rt/docs/CMakeLists.txt b/orc-rt/docs/CMakeLists.txt new file mode 100644 index 0000000000000..8709000c6254e --- /dev/null +++ b/orc-rt/docs/CMakeLists.txt @@ -0,0 +1,8 @@ +if (LLVM_ENABLE_SPHINX) + include(AddSphinxTarget) + if (SPHINX_FOUND) + if (${SPHINX_OUTPUT_HTML}) + add_sphinx_target(html orc-rt) + endif() + endif() +endif() diff --git a/orc-rt/docs/README.txt b/orc-rt/docs/README.txt new file mode 100644 index 0000000000000..da202c5fa8391 --- /dev/null +++ b/orc-rt/docs/README.txt @@ -0,0 +1,13 @@ +ORC-RT Documentation +==================== + +The ORC-RT documentation is written using the Sphinx documentation generator. It is +currently tested with Sphinx 5.3.0. + +To build the documents into html configure ORC-RT with the following cmake options: + + * -DLLVM_ENABLE_SPHINX=ON + * -DORC_RT_INCLUDE_DOCS=ON + +After configuring ORC-RT with these options the make rule `docs-orc-rt-html` +should be available. diff --git a/orc-rt/docs/conf.py b/orc-rt/docs/conf.py new file mode 100644 index 0000000000000..b9f197d85b847 --- /dev/null +++ b/orc-rt/docs/conf.py @@ -0,0 +1,253 @@ +# -*- coding: utf-8 -*- +# ORC-RT documentation build configuration file. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +from datetime import date + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + "sphinx.ext.todo", + "sphinx.ext.mathjax", + "sphinx.ext.intersphinx", + "sphinx.ext.autodoc", +] + +# When building man pages, we do not use the markdown pages, +# So, we can continue without the myst_parser dependencies. +# Doing so reduces dependencies of some packaged llvm distributions. +try: + import myst_parser + + extensions.append("myst_parser") +except ImportError: + if not tags.has("builder-man"): + raise + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] +myst_heading_anchors = 6 + +import sphinx + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "ORC-RT" +copyright = "2025-%d, The ORC-RT Team" % date.today().year + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. These are currently set to zero because we don't use them. +# Should somebody consider in the future to change them, they need to be updated +# everytime a new release comes out. +# +# The short version. +# version = '0' +# The full version, including alpha/beta/rc tags. +# release = '0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build", "analyzer", "FIR/*"] + +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "friendly" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "haiku" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +html_title = "ORC Runtime" + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = "%b %d, %Y" + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = "orc-rt-doc" + +# If true, the reST sources are included in the HTML build as +# _sources/name. The default is True. +html_copy_source = False + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ("Overview", "ORC-RT.tex", "orc-rt Documentation", "The orc-rt Team", "manual"), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ("Overview"), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' diff --git a/orc-rt/docs/index.md b/orc-rt/docs/index.md new file mode 100644 index 0000000000000..56f9bb3829c17 --- /dev/null +++ b/orc-rt/docs/index.md @@ -0,0 +1,54 @@ +# LLVM ORC Runtime + +## Overview + +The ORC runtime provides executor-side support code for the LLVM ORC APIs. + +```{eval-rst} +.. toctree:: + :titlesonly: + + Building-orc-rt +``` + +### Current Status + +The ORC Runtime is a new, experimental project. It is being actively developed, +and neither the ABI nor API are stable. LLVM ORC API clients should be careful +to use an ORC Runtime from the same build as their LLVM ORC libraries. + +### Platform and Compiler Support + +* TODO + +The following minimum compiler versions are strongly recommended. + +* Clang 16 and above + +Anything older *may* work. + +### Notes and Known Issues + +* TODO + +## Getting Involved + +First please review our +[Developer's Policy](https://llvm.org/docs/DeveloperPolicy.html) and +[Getting started with LLVM](https://llvm.org/docs/GettingStarted.html). + +**Bug Reports** + +If you think you've found a bug in the ORC Runtime, please report it using +the [LLVM bug tracker](https://github.com/llvm/llvm-project/labels/orc-rt/). +Please use the tag "orc-rt" for new threads. + +**Patches** + +If you want to contribute a patch to th ORC runtime, please start by reading +the LLVM +[documentation about contributing](https://www.llvm.org/docs/Contributing.html). + +**Discussion and Questions** + +* TODO diff --git a/orc-rt/include/CMakeLists.txt b/orc-rt/include/CMakeLists.txt new file mode 100644 index 0000000000000..cd2032f3a5cdf --- /dev/null +++ b/orc-rt/include/CMakeLists.txt @@ -0,0 +1,17 @@ +set(ORC_RT_HEADERS + orc-rt-c/orc-rt.h +) + +# TODO: Switch to filesets when we move to cmake-3.23. +add_library(orc-rt-headers INTERFACE) +target_include_directories(orc-rt-headers INTERFACE + $ + $ +) +set_property(TARGET orc-rt-headers + PROPERTY PUBLIC_HEADER ${ORC_RT_HEADERS} +) +install(TARGETS orc-rt-headers + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ + COMPONENT OrcRT_Development +) diff --git a/orc-rt/include/orc-rt-c/orc-rt.h b/orc-rt/include/orc-rt-c/orc-rt.h new file mode 100644 index 0000000000000..31ef74f6c1e9b --- /dev/null +++ b/orc-rt/include/orc-rt-c/orc-rt.h @@ -0,0 +1,32 @@ +//===- orc-rt-c/orc-rt.h - Placeholder header for orc-rt ----------*- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Placeholder header for initial orc-rt checkin. +// +//===----------------------------------------------------------------------===// + +#ifndef ORC_RT_C_ORC_RT_H +#define ORC_RT_C_ORC_RT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/// \addtogroup orc_rt_c_api orc-rt C APIs +/// @{ + +void orc_rt(void); + +/// @} +/// + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ORC_RT_C_ORC_RT_H diff --git a/orc-rt/lib/CMakeLists.txt b/orc-rt/lib/CMakeLists.txt new file mode 100644 index 0000000000000..993f2b8b52eb7 --- /dev/null +++ b/orc-rt/lib/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(executor) diff --git a/orc-rt/lib/executor/CMakeLists.txt b/orc-rt/lib/executor/CMakeLists.txt new file mode 100644 index 0000000000000..82d29455eb6df --- /dev/null +++ b/orc-rt/lib/executor/CMakeLists.txt @@ -0,0 +1,13 @@ +set(files + orc-rt-executor.cpp + ) + +add_library(orc-rt-executor STATIC ${files}) +target_link_libraries(orc-rt-executor + PUBLIC orc-rt-headers + ) +install(TARGETS orc-rt-executor + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT OrcRT_Development + PUBLIC_HEADER DESTINATION include COMPONENT OrcRT_Development +) diff --git a/orc-rt/lib/executor/orc-rt-executor.cpp b/orc-rt/lib/executor/orc-rt-executor.cpp new file mode 100644 index 0000000000000..d70488d11d3fa --- /dev/null +++ b/orc-rt/lib/executor/orc-rt-executor.cpp @@ -0,0 +1,15 @@ +//===- orc-rt-executor.cpp - Placeholder implementation for orc-rt --------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Placeholder implementation file for initial orc-rt checkin. +// +//===----------------------------------------------------------------------===// + +#include + +extern "C" void orc_rt(void) { printf("hello, world!\n"); } diff --git a/orc-rt/test/CMakeLists.txt b/orc-rt/test/CMakeLists.txt new file mode 100644 index 0000000000000..0de6b6b085a43 --- /dev/null +++ b/orc-rt/test/CMakeLists.txt @@ -0,0 +1,38 @@ +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py + ) + +list(APPEND ORC_RT_TEST_DEPS + FileCheck + count + not + orc-executor + ) + +add_custom_target(orc-rt-test-depends DEPENDS ${ORC_RT_TEST_DEPS}) +set_target_properties(orc-rt-test-depends PROPERTIES FOLDER "orc-rt/Tests") + +add_lit_testsuite(check-orc-rt "Running the ORCRT regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${ORC_RT_TEST_DEPS} + ) + +add_lit_testsuites(ORC-RT ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${ORC_RT_TEST_DEPS} +) + +# Add orc-rt unit tests +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.cfg.py) + +add_lit_testsuite(check-orcrt-unit "Running orc-rt unittest suites" + ${CMAKE_CURRENT_BINARY_DIR}/unit + EXCLUDE_FROM_CHECK_ALL + DEPENDS OrcRTUnitTests) + diff --git a/orc-rt/test/init.test b/orc-rt/test/init.test new file mode 100644 index 0000000000000..eaa666ef75d79 --- /dev/null +++ b/orc-rt/test/init.test @@ -0,0 +1 @@ +RUN: orc-executor %s %s diff --git a/orc-rt/test/lit.cfg.py b/orc-rt/test/lit.cfg.py new file mode 100644 index 0000000000000..93eacf972867c --- /dev/null +++ b/orc-rt/test/lit.cfg.py @@ -0,0 +1,63 @@ +# -*- Python -*- + +import os +import platform +import re +import subprocess +import tempfile + +import lit.formats +import lit.util + +from lit.llvm import llvm_config +from lit.llvm.subst import ToolSubst +from lit.llvm.subst import FindTool + + +# name: The name of this test suite. +config.name = "ORCRT" + +# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites. +# See https://github.com/llvm/llvm-project/issues/106636 for more details. +# +# We prefer the lit internal shell which provides a better user experience on failures +# unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0 env var. +use_lit_shell = True +lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL") +if lit_shell_env: + use_lit_shell = lit.util.pythonize_bool(lit_shell_env) + +config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = [ + ".ll", + ".test", + ".c", +] +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root path where tests should be run. +config.test_exec_root = os.path.join(config.orcrt_obj_root, "test") +llvm_config.with_environment( + "PATH", + os.path.join(config.orcrt_obj_root, "tools", "orc-executor"), + append_path=True) +config.substitutions.append(("%PATH%", config.environment["PATH"])) +# config.substitutions.append(("%shlibext", config.llvm_shlib_ext)) +config.substitutions.append(("%llvm_src_root", config.llvm_src_root)) +# config.substitutions.append(("%host_cxx", config.host_cxx)) +# config.substitutions.append(("%host_cc", config.host_cc)) +if config.llvm_rt_tools_dir: + config.llvm_tools_dir = config.llvm_rt_tools_dir +llvm_config.use_default_substitutions() + + +# excludes: A list of directories to exclude from the testsuite. The 'Inputs' +# subdirectories contain auxiliary inputs for various tests in their parent +# directories. +config.excludes = [ + "lit.cfg.py", + "lit.site.cfg.py.in", +] diff --git a/orc-rt/test/lit.site.cfg.py.in b/orc-rt/test/lit.site.cfg.py.in new file mode 100644 index 0000000000000..708510e0d0044 --- /dev/null +++ b/orc-rt/test/lit.site.cfg.py.in @@ -0,0 +1,23 @@ +@LIT_SITE_CFG_IN_HEADER@ + +import sys + +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.orcrt_obj_root = "@ORCRT_BINARY_DIR@" +config.llvm_rt_tools_dir = "@LLVM_RT_TOOLS_BINARY_DIR@" +config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") +config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") +config.llvm_shlib_dir = lit_config.substitute("@SHLIBDIR@") +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.host_triple = "@LLVM_HOST_TRIPLE@" +config.target_triple = "@LLVM_TARGET_TRIPLE@" +config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" +config.host_arch = "@HOST_ARCH@" +config.python_executable = "@Python3_EXECUTABLE@" +config.targets_to_build = "@ORCRT_TARGETS_TO_BUILD@" + +import lit.llvm +lit.llvm.initialize(lit_config, config) +# Let the main config do the real work. +lit_config.load_config(config, "@ORCRT_SOURCE_DIR@/test/lit.cfg.py") diff --git a/orc-rt/test/unit/lit.cfg.py b/orc-rt/test/unit/lit.cfg.py new file mode 100644 index 0000000000000..0a0a26672c2e3 --- /dev/null +++ b/orc-rt/test/unit/lit.cfg.py @@ -0,0 +1,22 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +import os +import subprocess + +import lit.formats + +# name: The name of this test suite. +config.name = "ORCRT-Unit" + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = [] + +# test_source_root: The root path where tests are located. +# test_exec_root: The root path where tests should be run. +config.test_exec_root = os.path.join(config.orcrt_obj_root, "unittests") +config.test_source_root = config.test_exec_root + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests") \ No newline at end of file diff --git a/orc-rt/test/unit/lit.site.cfg.py.in b/orc-rt/test/unit/lit.site.cfg.py.in new file mode 100644 index 0000000000000..1ffe100166910 --- /dev/null +++ b/orc-rt/test/unit/lit.site.cfg.py.in @@ -0,0 +1,17 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") +config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") +config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@") +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.orcrt_obj_root = "@ORCRT_BINARY_DIR@" +config.target_triple = "@LLVM_TARGET_TRIPLE@" + +import lit.llvm +lit.llvm.initialize(lit_config, config) + +# Let the main config do the real work. +lit_config.load_config(config, "@ORCRT_SOURCE_DIR@/test/unit/lit.cfg.py") \ No newline at end of file diff --git a/orc-rt/tools/CMakeLists.txt b/orc-rt/tools/CMakeLists.txt new file mode 100644 index 0000000000000..fc78ea4131606 --- /dev/null +++ b/orc-rt/tools/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(orc-executor) diff --git a/orc-rt/tools/orc-executor/CMakeLists.txt b/orc-rt/tools/orc-executor/CMakeLists.txt new file mode 100644 index 0000000000000..b4a2292f58173 --- /dev/null +++ b/orc-rt/tools/orc-executor/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(orc-executor orc-executor.cpp) +target_link_libraries(orc-executor PRIVATE orc-rt-executor) diff --git a/orc-rt/tools/orc-executor/orc-executor.cpp b/orc-rt/tools/orc-executor/orc-executor.cpp new file mode 100644 index 0000000000000..92bdd5bf5d53f --- /dev/null +++ b/orc-rt/tools/orc-executor/orc-executor.cpp @@ -0,0 +1,18 @@ +//===- orc-executor.cpp - Placeholder implementation for orc-rt ----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Placeholder implementation file for initial orc-rt checkin. +// +//===----------------------------------------------------------------------===// + +#include "orc-rt-c/orc-rt.h" + +int main(int argc, char *argv[]) { + orc_rt(); + return 0; +} diff --git a/orc-rt/unittests/CMakeLists.txt b/orc-rt/unittests/CMakeLists.txt new file mode 100644 index 0000000000000..4476d43ca4ae5 --- /dev/null +++ b/orc-rt/unittests/CMakeLists.txt @@ -0,0 +1,11 @@ +add_custom_target(OrcRTUnitTests) +set_target_properties(OrcRTUnitTests PROPERTIES FOLDER "orcrt/Tests") + +function(add_orc_rt_unittest test_dirname) + add_unittest(OrcRTUnitTests ${test_dirname} ${ARGN}) +endfunction() + +add_orc_rt_unittest(CoreTests + init.cpp + DISABLE_LLVM_LINK_LLVM_DYLIB + ) diff --git a/orc-rt/unittests/init.cpp b/orc-rt/unittests/init.cpp new file mode 100644 index 0000000000000..24f12127f49f5 --- /dev/null +++ b/orc-rt/unittests/init.cpp @@ -0,0 +1,6 @@ +#include "gtest/gtest.h" + + +TEST(TEST, emptyFuncs) { + ASSERT_EQ(True, False); +} diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index bfb4341b172cc..62d8527a6c087 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0 # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend # on libc++, so we put it after. -set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;libclc;openmp;offload") +set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;libclc;openmp;offload;orc-rt") set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-rt;libsycl") set(LLVM_ENABLE_RUNTIMES "" CACHE STRING "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.") @@ -44,7 +44,7 @@ if(LLVM_ENABLE_RUNTIMES STREQUAL "all" ) endif() include(SortSubset) sort_subset("${LLVM_SUPPORTED_RUNTIMES}" "${LLVM_ENABLE_RUNTIMES}" LLVM_ENABLE_RUNTIMES) - +set(LLVM_RT_TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR} CACHE STRING "runtime path to required test tools") foreach(proj ${LLVM_ENABLE_RUNTIMES}) set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}") if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt) @@ -254,7 +254,6 @@ foreach(entry ${runtimes}) # will be included under here. set(HAVE_${canon_name} ON) endforeach() - if(LLVM_INCLUDE_TESTS) # If built with the runtimes build (rooted at runtimes/CMakeLists.txt), we # won't have llvm-lit. If built with the bootstrapping build (rooted at