diff options
Diffstat (limited to 'third_party/llvm_builtins')
-rw-r--r-- | third_party/llvm_builtins/BUILD.gn | 38 | ||||
-rw-r--r-- | third_party/llvm_builtins/docs.rst | 51 |
2 files changed, 72 insertions, 17 deletions
diff --git a/third_party/llvm_builtins/BUILD.gn b/third_party/llvm_builtins/BUILD.gn index d38f26ffe..4cdf9ef8b 100644 --- a/third_party/llvm_builtins/BUILD.gn +++ b/third_party/llvm_builtins/BUILD.gn @@ -16,6 +16,7 @@ import("//build_overrides/pigweed.gni") import("$dir_pw_build/error.gni") import("$dir_pw_build/target_types.gni") +import("$dir_pw_docgen/docs.gni") declare_args() { # This should be set to the path of the llvm compiler-rt/builtins directory. @@ -24,6 +25,9 @@ declare_args() { # Points to a pw_source_set that enumerates builtins specific to # the current toolchain. pw_third_party_llvm_builtins_TARGET_BUILTINS = "" + + # List of files to be excluded from the builtins repo. + pw_third_party_llvm_builtins_ignore_list = [] } config("no-warnings") { @@ -149,6 +153,9 @@ files = [ "umodti3.c", ] +# Because this is unconditionally added to all clang-based ARM toolchains, +# this library should be a no-op if `dir_pw_third_party_llvm_builtins` is +# not configured. pw_source_set("arm_builtins") { configs = [ ":no-warnings" ] remove_configs = [ "//pw_build:extra_strict_warnings" ] @@ -213,7 +220,9 @@ pw_source_set("arm_builtins") { ] if (dir_pw_third_party_llvm_builtins != "") { - foreach(file, arm_files) { + effective_arm_files = + filter_exclude(arm_files, pw_third_party_llvm_builtins_ignore_list) + foreach(file, effective_arm_files) { sources += [ "$dir_pw_third_party_llvm_builtins/$file" ] } } else { @@ -221,12 +230,9 @@ pw_source_set("arm_builtins") { } } -# This list includes the cpu's for which their is a `:${current_cpu}_builtins` -# target. -_default_supported_cpus = [ "arm" ] -_current_cpu_is_known = _default_supported_cpus + [ current_cpu ] - - [ current_cpu ] != _default_supported_cpus - +# Because this is unconditionally added to all clang-based ARM toolchains, +# this library should be a no-op if `dir_pw_third_party_llvm_builtins` is +# not configured. pw_static_library("llvm_builtins") { add_global_link_deps = false @@ -236,25 +242,23 @@ pw_static_library("llvm_builtins") { sources = [] if (dir_pw_third_party_llvm_builtins != "") { - foreach(file, files) { + effective_files = + filter_exclude(files, pw_third_party_llvm_builtins_ignore_list) + foreach(file, effective_files) { sources += [ "$dir_pw_third_party_llvm_builtins/$file" ] } } else { not_needed([ "files" ]) } + # Architecture specific pw_source_set created from LLVM builtins + # source files. e.g. arm_builtins. If this property is not set, no + # architecture specific builtin functions will be included from the repo. if (pw_third_party_llvm_builtins_TARGET_BUILTINS != "") { deps = [ pw_third_party_llvm_builtins_TARGET_BUILTINS ] - } else if (_current_cpu_is_known) { - deps = [ ":${current_cpu}_builtins" ] - } else { - deps = [ ":unknown_cpu" ] } } -if (pw_third_party_llvm_builtins_TARGET_BUILTINS == "" && - !_current_cpu_is_known) { - pw_error("unknown_cpu") { - message = "Tried to build $dir_pw_third_party_llvm_builtins:llvm_builtins, but pw_third_party_llvm_builtins_TARGET_BUILTINS was not set and `current_cpu=\"$current_cpu\"` does not have well-known builtins set up." - } +pw_doc_group("docs") { + sources = [ "docs.rst" ] } diff --git a/third_party/llvm_builtins/docs.rst b/third_party/llvm_builtins/docs.rst new file mode 100644 index 000000000..73054f42d --- /dev/null +++ b/third_party/llvm_builtins/docs.rst @@ -0,0 +1,51 @@ +.. _module-pw_toolchain: + +================ +LLVM compiler-rt +================ +The ``$dir_pw_third_party/llvm_builtins/`` directory provides the GN integration +necessary to link against LLVM compiler-rt project. The intention here is to use +the builtins provided by the LLVM compiler-rt project. + +------------------------------- +Using upstream LLVM compiler-rt +------------------------------- +If you want to use LLVM compiler-rt, you must do the following: + +Submodule +========= +Add LLVM compiler-rt to your workspace with the following command. + +.. code-block:: sh + + git submodule add git submodule add \ + https://llvm.googlesource.com/llvm-project/compiler-rt \ + third_party/llvm_builtins + +.. admonition:: Note + + This git repository is maintained by Google and is a slice of upstream + LLVM including only the compiler-rt subdirectory. + +GN +== +* Set the GN var ``dir_pw_third_party_llvm_builtins`` to the location of the + LLVM compiler-rt source. If you used the command above, this will be + ``//third_party/llvm_builtins`` + + This can be set in your args.gn or .gn file like: + ``dir_pw_third_party_llvm_builtins = "//third_party/llvm_builtins"`` + +* Set the ``pw_third_party_llvm_builtins_TARGET_BUILTINS`` to the pw_source_set + that selectively adds the files required for the given architecture from the + LLVM compiler-rt checkout directory. + + For example, you can add the following in your args.gn or .gn file to use the + builtins for ARM32 architecture. + + .. code-block:: + + pw_third_party_llvm_builtins_TARGET_BUILTINS = "$dir_pw_third_party/llvm_builtins:arm_builtins" + +* Set the optional ``pw_third_party_llvm_builtins_ignore_list`` to the list of + files included in pw_source_sets in ``$dir_pw_third_party/llvm_builtins/BUILD.gn`` file. |