Commit Graph

2054 Commits

Author SHA1 Message Date
serge-sans-paille
8d3ab9dfc4
Properly support LLVM_ENABLE_LLD on Windows
Currently, setting -DLLVM_ENABLE_LLD=ON on windows also requires setting
-DCMAKE_LINKER=lld-link.exe. This is both misleading and redundant.

Fix this by trying to find llvm-link.exe when -DLLVM_ENABLE_LLD=ON is
set and CMAKE_LINKER is not, and aborting otherwise.

Differential Revision: https://reviews.llvm.org/D140534
2022-12-22 20:07:25 +01:00
Nikita Popov
673ce56291 [cmake] Copy llvm-driver-template.cpp.in into build dir as well
We were copying it into the installed version of the directory,
but not into the one in the build directory. Because of that it
was not directly usable as a cmake module by subprojects that
also use the driver functionality.
2022-12-21 11:42:03 +01:00
Fangrui Song
f31a36e776 Revert D139752 "cmake: Enable 64bit off_t on 32bit glibc systems"
This reverts commit ae3e228af7.

Seems that it may form a wrong command line for 32-bit Halide builds

`-D_FILE_OFFSET_BITS="64 -D_DEBUG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"` according to
2022-12-20 09:45:28 -08:00
Fangrui Song
6a817d7bdb [CMake] add_definitions => add_compile_definitions after D139752
Suggested by alexreinking (Alex Reinking)
2022-12-20 09:34:14 -08:00
Sebastian Neubauer
3e2a6d7f03 [llvm][cmake] Fix add_subdirectory build in multi-config
Using CMAKE_CFG_INTDIR in paths that are used in configure_file,
resulted in a folder that is literally called '${CONFIGURATION}'
for the multi-config ninja build.

I think this is a regression from a while ago. Fix this by replacing
CMAKE_CFG_INTDIR with '.'. We can only create one of the
LLVMConfig.cmake files as the consuming CMake project can only import a
single file. This creates LLVMConfig.cmake and others in the place where
they were previously and where they are for a single-config build.

Differential Revision: https://reviews.llvm.org/D139623
2022-12-20 11:56:10 +01:00
Khem Raj
ae3e228af7 cmake: Enable 64bit off_t on 32bit glibc systems
Pass -D_FILE_OFFSET_BITS=64 to compiler flags on 32bit glibc based
systems. This will make sure that 64bit versions of LFS functions are
used e.g. seek will behave same as lseek64. Also revert [1] partially
because this added a cmake test to detect lseek64 but then forgot to
pass the needed macro to actual compile, this test was incomplete too
since libc implementations like musl has 64bit off_t by default on 32bit
systems and does not bundle[2] -D_LARGEFILE64_SOURCE under -D_GNU_SOURCE
like glibc, which means the compile now fails on musl because the cmake
check passes but we do not have _LARGEFILE64_SOURCE defined. Using the
*64 function was transitional anyways so use -D_FILE_OFFSET_BITS=64
instead

[1] 8db7e5e4ee
[2] https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D139752
2022-12-18 00:13:29 +00:00
Nicole Rabjohn
2ee308ceea [CMake] Setting the LLVM_TARGET_TRIPLE macro based on the LLVM_DEFAULT_TARGET_TRIPLE
After D137870, LLVM_TARGET_TRIPLE is no longer defined on the runtime
path into compiler-rt. This patch creates a common block of code to set
LLVM_TARGET_TRIPLE equal to the default for both the llvm- and runtime-
paths.

Differential Revision: https://reviews.llvm.org/D138864
2022-12-13 20:03:50 -05:00
Daniel Thornburgh
138d538957 [CMake] Move dladdr check below _GNU_SOURCE check.
The presence of dladdr on Linux depends on whether or not _GNU_SOURCE is
set.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D139575
2022-12-08 15:53:25 -08:00
Leonard Chan
96d63993dd Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"
This reverts commit bec8a372fc.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.
2022-12-05 22:20:51 +00:00
Petr Hosek
bec8a372fc [CMake] Use LLVM_TARGET_TRIPLE in runtimes
This variable is derived from LLVM_DEFAULT_TARGET_TRIPLE by default,
but using a separate variable allows additional normalization to be
performed if needed.

Differential Revision: https://reviews.llvm.org/D137451
2022-11-29 04:08:24 +00:00
Michał Górny
5279e6a7d6 [cmake] Fix Findzstd.cmake to handle OpenBSD shared libraries
Fix Findzstd CMake to handle shared libraries on OpenBSD correctly.
This userland does not use shared library symlinks without SOVERSION,
so the result of find_library() does not ever end with
zstd_SHARED_LIBRARY_SUFFIX.  To work around this, reverse the logic
to compare the result against zstd_STATIC_LIBRARY_SUFFIX and assume
shared library otherwise.

While at it, fix the conditions not to fall back to "result is static
library" path if it actually was recognized as a shared library but
zstd_shared target already existed.

Fixes #59056

Differential Revision: https://reviews.llvm.org/D138361
2022-11-23 06:50:53 +01:00
Andreas Hollandt
8da41fe696 [cmake] Fix _GNU_SOURCE being added unconditionally
Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D137917
2022-11-14 12:28:21 -08:00
Chris Bieneman
6111125d73 [NFC] Fixing spelling in code comment 2022-11-14 10:28:36 -06:00
Tom Stellard
a7ba84a39d cmake: Inline the add_llvm_symbol_exports.py script
This fixes stand-alone builds.

Reviewed By: andrewng

Differential Revision: https://reviews.llvm.org/D137611
2022-11-10 13:18:47 -08:00
Timm Bäder
e1b88c8a09 [clang] Only use major version in resource dir
This causes unnecessary churn for downstreams.

For the full discussion, see https://discourse.llvm.org/t/should-we-continue-embed-the-full-llvm-version-in-lib-clang/62094

Differential Revision: https://reviews.llvm.org/D125860
2022-11-10 15:02:03 +01:00
Tom Stellard
a11cd0d94e Move googletest to the third-party directory
Rre-commit of 59052468c3 with a typo
fix in compiler-rt/CMakeLists.txt
2022-11-09 15:28:08 -08:00
Tom Stellard
8a084f68c8 Revert "Move googletest to the third-party directory"
This reverts commit 59052468c3.

It looks like this patch breaks the build when compiler-rt is passed to
LLVM_ENABLE_PROJECTS instead of LLVM_ENABLE_RUNTIMES.
2022-11-09 11:34:59 -08:00
Tom Stellard
59052468c3 Move googletest to the third-party directory
This will help improve the project's layering, so that sub-projects
that don't actually need any llvm code can still use googletest
without having to reference code in the llvm directory.

This will also make it easier to consolidate and simplify the standalone
build configurations.

Reviewed By: stellaraccident, lattner, probinson, phosek

Differential Revision: https://reviews.llvm.org/D131919
2022-11-09 11:10:26 -08:00
Sam James
32a2af44e1 [CMake] Fix -Wstrict-prototypes
Fixes warnings (or errors, if someone injects -Werror in their build system,
which happens in fact with some folks vendoring LLVM too) with Clang 16:
```
+/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype
is deprecated in all versions of C [-Wstrict-prototypes]
-/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is
deprecated in all versions of C [-Werror,-Wstrict-prototypes]
 int main() {return 0;}
         ^
          void
```

Differential Revision: https://reviews.llvm.org/D137503
2022-11-08 01:37:04 +00:00
Argyrios Kyrtzidis
05a165bf04 [llvm/cmake/config-ix.cmake] If LD64_EXECUTABLE is already set, avoid the need to look up ld64
This provides option to set the `LD64_EXECUTABLE` variable to a path at CMake configure time directly.
2022-11-05 20:58:41 -07:00
Sam James
fa981b5413 Set LLVM_ATOMIC_LIB variable for convenient linking against libatomic
* Set LLVM_ATOMIC_LIB to keep track of when we need to link against libatomic.
* Add detection of mold linker which is required for this.
* Use --as-needed when linking against libatomic as a bonus. On some platforms,
  libatomic may be required only sometimes.

Bug: https://bugs.gentoo.org/832675
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Differential Revision: https://reviews.llvm.org/D136280
2022-11-03 21:07:43 +01:00
Jan Svoboda
16e1a49441 Revert "[cmake][msvc] Enable standards-conforming preprocessor"
This reverts commit 12d8e7c6ad.

The Windows MLIR buildbot started failing with:

C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winbase.h(9531): error C2220: the following warning is treated as an error
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winbase.h(9531): warning C5105: macro expansion producing 'defined' has undefined behavior
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winbase.h(9531): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
2022-11-02 10:58:26 -07:00
Jan Svoboda
12d8e7c6ad [cmake][msvc] Enable standards-conforming preprocessor
Since we now only support Visual Studio 2019 16.7 and newer, we're able to use the /Zc:preprocessor flag that turns on the standards-conforming preprocessor. Among other things, it correctly expands __VA_ARGS__. This enables removal of some boilerplate in D135128.

Reviewed By: Bigcheese, thieta

Differential Revision: https://reviews.llvm.org/D135128
2022-11-02 09:35:55 -07:00
Kadir Cetinkaya
b999ac1af6
[llvm] Fix minimum Apple Clang requirement
This was stated as 9.3, but as pointed out in
https://discourse.llvm.org/t/rfc-bump-minimal-requirements-apple-clang-9-3-10-0-0-before-4th-tue-in-january/66156/7?u=kadircet
9.3 doesn't exist, hence this was effectively 10.0.

This patch merely reflects the reality more closely.

Differential Revision: https://reviews.llvm.org/D136609
2022-10-28 15:12:24 +02:00
Michał Górny
89f77be94f [llvm] [cmake] Silence GNUInstallDirs warning in LLVMInstallSymlink
Set a dummy CMAKE_INSTALL_LIBDIR in order to silence the following CMake
warning when executing LLVMInstallSymlink.cmake script:

    CMake Warning (dev) at /usr/share/cmake/Modules/GNUInstallDirs.cmake:243 (message):
      Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
      target architecture is known.  Please enable at least one language before
      including GNUInstallDirs.
    Call Stack (most recent call first):
      /usr/lib/llvm/16/lib64/cmake/llvm/LLVMInstallSymlink.cmake:5 (include)
      tools/lld/cmake_install.cmake:66 (include)
      cmake_install.cmake:52 (include)

Differential Revision: https://reviews.llvm.org/D136573
2022-10-28 08:49:26 +02:00
Andrew Ng
1e29766314 [CMake] Add Python script to generate version script symbol exports
Using a Python script instead of the various shell commands means that
it is now possible to cross compile LLVM for Linux on Windows.

Differential Revision: https://reviews.llvm.org/D136092
2022-10-18 13:47:43 +01:00
Andrew Ng
e7fc7540da [CMake] Fix Findzstd module for shared DLL on Windows
Differential Revision: https://reviews.llvm.org/D136065
2022-10-18 12:35:11 +01:00
Steven Wu
4ba360d499 [CMake] Fix FindGRPC cmake module to allow different layering
Take the library target out of `generate_protos` function so the caller
can decide where to layer the library using the source generated from
the function.

Fixes: https://github.com/llvm/llvm-project/issues/58075

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D135712
2022-10-12 15:35:26 -07:00
Tobias Hieta
fc651a0669
[CMake] Add option LLVM_FORCE_CREATE_SYMLINKS
On Windows we don't create symlinks for the binaries (clang++, clang-cl)
since the support requires special setup (group policy settings and
you need to know exactly our distribution story). But if you know
about these things and have a controlled environment there is a lot
of storage to be saved, so let's add a manual opt-in for using symlinks
on Windows with LLVM_FORCE_CREATE_SYMLINKS=ON.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D135578
2022-10-12 11:06:32 +02:00
Michał Górny
56f94ede2a [llvm] [cmake] Support finding both static and shared zstd via FindZstd
Improve the logic in FindZstd to support finding both shared and static
variants of the zstd library simultaneously.  Otherwise, if the shared
library is installed, zstd::libzstd_static is not declared at all
and CMake fails if LLVM_USE_STATIC_ZSTD is used.

Differential Revision: https://reviews.llvm.org/D135457
2022-10-12 07:14:28 +02:00
Anush Elangovan
4d25ba0165 Make windows resource generation more robust
This is another attempt at https://reviews.llvm.org/D110489.

When build IREE we run into cases where we don't have / need
LLVM_VERSION_* etc set. Compilation fails if it isn't an integer.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D135650
2022-10-11 06:31:02 -07:00
Nikita Popov
bc839b4b4e [Bindings] Remove go bindings
Remove the unmaintained Go bindings per
https://discourse.llvm.org/t/rfc-remove-the-go-bindings/65725.

The tinygo project provides maintained Go bindings at
https://github.com/tinygo-org/go-llvm.

Differential Revision: https://reviews.llvm.org/D135436
2022-10-10 10:14:17 +02:00
Petr Hosek
2d4fd0b6d5 [CMake] Provide Findzstd module
This module is used to find the system zstd library. The imported
targets intentionally use the same name as the generate zstd config
CMake file so these can be used interchangeably.

Differential Revision: https://reviews.llvm.org/D134990
2022-10-06 16:10:48 +00:00
Nikita Popov
2d433aebc1 Revert "[CMake] Provide Findzstd module"
This reverts commit 849059861c.

This breaks running llvm tests:

llvm-lit: /home/npopov/repos/llvm-project/llvm/utils/lit/lit/TestingConfig.py:138: fatal: unable to parse config file '/home/npopov/repos/llvm-project/build/test/lit.site.cfg.py', traceback: Traceback (most recent call last):
  File "/home/npopov/repos/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 127, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/home/npopov/repos/llvm-project/build/test/lit.site.cfg.py", line 48, in <module>
    config.have_zstd = FALSE
NameError: name 'FALSE' is not defined
2022-10-06 12:03:20 +02:00
Petr Hosek
849059861c [CMake] Provide Findzstd module
This module is used to find the system zstd library. The imported
targets intentionally use the same name as the generate zstd config
CMake file so these can be used interchangeably.

Differential Revision: https://reviews.llvm.org/D134990
2022-10-06 08:22:51 +00:00
Alex Brachet
3b0df701b0 [llvm-driver] Support single distributions
`LLVM_DISTRIBUTION_COMPONENTS` now influences the llvm binary in the
normal cmake output directory when it is set. This allows for
distribution targets to only include tools they want in the llvm
binary. It must be done this way because only one target can be
associated with a specific output name.

Differential Revision: https://reviews.llvm.org/D131310
2022-10-01 20:20:28 +00:00
Alex Brachet
aa1c58b9c6 [llvm-driver][NFC] Simplify handling of tool symlinks
Differential Revision: https://reviews.llvm.org/D134979
2022-10-01 20:18:49 +00:00
Nikita Popov
9525e8ad3a Revert "[cmake] Export GetHostTriple.cmake"
This turned out to be insufficient by itself, because we would
also need to export config.guess.

This reverts commit 4ac4d6bc9f.
2022-09-29 09:58:39 +02:00
Nikita Popov
4ac4d6bc9f [cmake] Export GetHostTriple.cmake
GetHostTriple is used by the runtimes build, so this cmake file
must be exported. Otherwise it is not possible to build runtimes
against a previously built LLVM.

Differential Revision: https://reviews.llvm.org/D134730
2022-09-28 16:28:37 +02:00
Mikhail Korolev
74f0b058f0 Fix Z3 version detection regexp
regexp for try_run path expects '0 or more' digits which is incorrect because it should be 'one or more', regexp for header parsing expects 'exactly one' digit which is incorrect with current Z3 version (4.11.2)

Reviewed By: mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D134261
2022-09-23 16:24:51 -03:00
Ashay Rane
dfbaf90043
[llvm] prefix linker flag on non-MSVC compilers with -Wl,
Prior to this patch, a Windows build of llvm-lto using clang failed with
the error: `LTO.def: unknown file type`.  The reason for this failure is
that .DEF files are used by the linker not by the clang compiler.  The
MSVC compiler+linker handles this transparently, but if we're using
clang (or gcc), then we need to tell the compiler to forward this flag
to the linker. This patch adds the necessary `-Wl` flag to fix the
problem.

Reviewed By: rnk, mstorsjo

Differential Revision: https://reviews.llvm.org/D134165
2022-09-21 11:18:42 -05:00
Kevin Gleason
b052eead95 Fix -fuse-ld to be linker flag in feature detection check
Discovered an issue working in StableHLO when attempting to build with `-Wall -Werror`:
https://github.com/openxla/stablehlo/pull/137

Currently, if `LLVM_USE_LLD` and `-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"`
are both specified for build, the build will error with:

```
-- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Failed
CMake Error at /usr/local/google/home/gleasonk/Coding/llvm-build/lib/cmake/llvm/HandleLLVMOptions.cmake:309 (message):
  Host compiler does not support '-fuse-ld=lld'
...

$ cat <build_dir>/CMakeFiles/CMakeError.log
...
clang: error: argument unused during compilation: '-fuse-ld=lld' [-Werror,-Wunused-command-line-argument]
```

It looks like other repos have hit this same issue:
- https://github.com/golang/go/issues/41527 (mentioned in comment)
- https://github.com/iree-org/iree/pull/7450

This can be reproduced in llvm-project with the following build command:

```
# Compile command taken from https://mlir.llvm.org/getting_started/
# and modified for use case
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_C_COMPILER=clang \
   -DLLVM_ENABLE_LLD=ON \
   -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"
```

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D134206
2022-09-21 04:01:57 +00:00
John Ericson
3a1c81e327 [CMake] Avoid LLVM_BINARY_DIR when other more specific variable are better-suited, part 2
A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by `add_subdirectory`; since the directory name in the source tree is fixed without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. We therefore do not replace it but leave it as-is.

This picks up where D133828 left off, getting the occurrences with*out* `CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in the (retroactively) previous diff.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D132316
2022-09-14 15:48:58 -04:00
Cole Kissane
c0b4f248df tweak zstd behavior in cmake and llvm config for better testing
add LLVM_PREFER_STATIC_ZSTD (default TRUE) cmake config flag
(compression test seems to fail for shared zstd on windows, note that zstd multithread is by default disabled in the static build so it may be a hidden variable)
propagate variable zstd_DIR in LLVMConfig.cmake.in
fix llvm-config CMakeLists.txt behavior for absolute libs windows
get zstd lib name

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D132870
2022-09-01 07:49:43 -07:00
Martin Storsjö
61fb3fb458 [cmake] Disable the -Wmisleading-indentation warning with GCC
We do keep using the flag with Clang, which should keep catching
such issues in buildbots.

With GCC, the warning can cause lots of loud notes about the
warning logic getting disabled in large source files.

Differential Revision: https://reviews.llvm.org/D132914
2022-08-31 22:26:09 +03:00
Markus Böck
52d7c0b760 [cmake] Don't include symlinks to tools in Build-all when LLVM_BUILD_TOOLS is off
When building LLVM with LLVM_BUILD_TOOLS as OFF, numerous tools such as llvm-ar or llvm-objcopy end up still being built. The reason for this is that the symlink targets are unconditionally included in a Build-all build, causing the tool they're symlinking to be built after all.

This patch changes that behaviour to be more intuitive by only including the symlink in a Build-all build if the target they're linking to is also included.

Differential Revision: https://reviews.llvm.org/D132883
2022-08-30 14:46:22 +02:00
John Ericson
34fe6ddce1 Revert "[CMake] Avoid LLVM_BINARY_DIR when other more specific variable are better-suited"
This reverts commit ad8c34bc30.
2022-08-25 11:13:46 -04:00
Mircea Trofin
5ce4c9aa04 [mlgo] Use TFLite for 'development' mode.
TLite is a lightweight, statically linkable[1], model evaluator, supporting a
subset of what the full tensorflow library does, sufficient for the
types of scenarios we envision having. It is also faster.

We still use saved models as "source of truth" - 'release' mode's AOT
starts from a saved model; and the ML training side operates in terms of
saved models.

Using TFLite solves the following problems compared to using the full TF
C API:

- a compiler-friendly implementation for runtime-loadable (as opposed
  to AOT-embedded) models: it's statically linked; it can be built via
  cmake;
- solves an issue we had when building the compiler with both AOT and
  full TF C API support, whereby, due to a packaging issue on the TF
  side, we needed to have the pip package and the TF C API library at
  the same version. We have no such constraints now.

The main liability is it supporting a subset of what the full TF
framework does. We do not expect that to cause an issue, but should that
be the case, we can always revert back to using the full framework
(after also figuring out a way to address the problems that motivated
the move to TFLite).

Details:

This change switches the development mode to TFLite. Models are still
expected to be placed in a directory - i.e. the parameters to clang
don't change; what changes is the directory content: we still need
an `output_spec.json` file; but instead of the saved_model protobuf and
the `variables` directory, we now just have one file, `model.tflite`.

The change includes a utility showing how to take a saved model and
convert it to TFLite, which it uses for testing.

The full TF implementation can still be built (not side-by-side). We
intend to remove it shortly, after patching downstream dependencies. The
build behavior, however, prioritizes TFLite - i.e. trying to enable both
full TF C API and TFLite will just pick TFLite.

[1] thanks to @petrhosek's changes to TFLite's cmake support and its deps!
2022-08-24 16:07:24 -07:00
John Ericson
ad8c34bc30 [CMake] Avoid LLVM_BINARY_DIR when other more specific variable are better-suited
A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/(\$\{CMAKE_CFG_INTDIR}/)?lib(${LLVM_LIBDIR_SUFFIX})?\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/(\$\{CMAKE_CFG_INTDIR}/)?bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `compiler-rt/cmake/Modules/CompilerRTUtils.cmake
- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D132316
2022-08-24 10:14:05 -04:00
Louis Dionne
5905e69934 [runtimes] Handle interface targets in runtimes distribution components
As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

Differential Revision: https://reviews.llvm.org/D132387
2022-08-23 08:55:58 -04:00