Commit Graph

50 Commits

Author SHA1 Message Date
Chris Bieneman
901166c939 Enabling LLVM & Clang to be cross-compiled using CMake from a single configuration command line
The basic idea is similar to the existing cross compilation support. A directory must be configured to build host versions of tablegen tools and llvm-config. This directory can be user provided (and configured), or it can be created during the build. During a build the native build directory will be configured and built to supply the tablegen tools used during the build. A user could also explicitly provide the tablegen executables to run on the CMake command line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217105 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 23:21:18 +00:00
Alp Toker
427c5cb4f9 CMake: avoid a reconfigure loop from r213091
Removing the native CMakeCache.txt causes the target to get re-run needlessly
on some systems. We'll want another solution for that part of the fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213099 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 22:11:54 +00:00
Alp Toker
9bc72a33f1 CMake: fix cross-compilation with external source directories
This adds support for building native artifacts when cross-compiling using the
popular side-by-side source directory layout (no symlinks, no nested
repositories).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213091 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 21:04:12 +00:00
NAKAMURA Takumi
46e8559826 TableGen.cmake: Functionalize and reformat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201972 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-23 12:54:15 +00:00
NAKAMURA Takumi
1e3bb3fc41 [CMake] Move intrinsics_gen to lib/Target out of add_public_tablegen_target.
add_public_tablegen_target is used somewhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-20 13:42:30 +00:00
NAKAMURA Takumi
dd5ff1bf41 Teach tablegen() macro to check needed variables
This macro depends on several variables to be set in the calling
context.  Check them and report an error if they are not set.
Without this, custom commands may be silently specified that
will fail at build time.

Patch by Brad King.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201229 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-12 11:50:11 +00:00
NAKAMURA Takumi
fdc6308fa1 [CMake] LLVMSupport should be responsible to provide system_libs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201077 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-10 10:52:19 +00:00
NAKAMURA Takumi
911a491cb3 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201054 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-09 16:38:31 +00:00
NAKAMURA Takumi
5778c9eb63 Export lib and exe build target names from build tree
Record every logical target that we install with install(TARGETS) in a
global LLVM_EXPORTS property.  Then use the export(TARGETS) command to
provide a "LLVMExports.cmake" file that exports logical targets for
import into applications directly from our build tree.

The "LLVMExports.cmake" file is not meant for direct inclusion by
application code but should be included by "LLVMConfig.cmake" in a
future change.

Contributed by Brad King.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201050 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-09 16:36:16 +00:00
NAKAMURA Takumi
39fcc71463 Export lib and exe build target names from install tree
Use the install(TARGETS) command EXPORT option for every library and
executable that we install with LLVM.  Then use the install(EXPORT)
command to provide a "LLVMExports.cmake" file that exports logical
targets for import into applications from our install tree.

The "LLVMExports.cmake" file is not meant for direct inclusion by
application code but should be included by "LLVMConfig.cmake" in a
future change.

Contributed by Brad King.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201049 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-09 16:36:03 +00:00
NAKAMURA Takumi
ee3a79a1e4 Revert r200150, "[CMake] tablegen(): Use -I <dir> according to the list by include_directories()."
It missed include/llvm/Target. Could I avoid GLOB_RECURSE anyways? :(
FYI, I intended to prune ${LLVM_MAIN_INCLUDE_DIR} in TableGen.cmake in r200150.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200730 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04 01:17:12 +00:00
NAKAMURA Takumi
dc209b8a83 [CMake] tablegen(): Use -I <dir> according to the list by include_directories().
For now, local_tds and global_tds are integrated to dependent_tds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200150 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 12:41:38 +00:00
NAKAMURA Takumi
9def8b2640 [CMake] Functionalize tblgen().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200149 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 12:41:33 +00:00
NAKAMURA Takumi
02a054cd61 [CMake] Add a comment to tablegen's copy_if_different. Ninja reports every action by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199058 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-12 17:42:43 +00:00
Douglas Gregor
54ed186e1b Remove CMake-Xcode hack that symlinked llvm-config into a common place.
When building Clang separately from LLVM with CMake, one should set
the path of llvm-config via the cache variable LLVM_CONFIG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198316 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 16:30:55 +00:00
Jordan Rose
25acded1b0 [CMake] Don't put every project's tblgen executable in the LLVM bin directory.
This changes Clang standalone builds so that clang-tblgen lives in
clang/build/bin instead of llvm/build/bin, and so that with the Xcode
generator it's in clang/build/bin/Debug instead of llvm/build/bin/Debug/Debug/.
Yes, really.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197590 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 17:50:33 +00:00
NAKAMURA Takumi
fe8eb63fcb [CMake] ${LLVM_MAIN_SRC_DIR}/include can be represented as ${LLVM_MAIN_INCLUDE_DIR}.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197396 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-16 16:14:19 +00:00
NAKAMURA Takumi
ef70d2a393 [CMake] Let add_public_tablegen_target() provide intrinsics_gen, too.
I think, in principle, intrinsics_gen may be added explicitly.
That said, it can be added incidentally, since each target already has dependencies to llvm-tblgen.
Almost all source files depend on both CommonTaleGen and intrinsics_gen.

Explicit add_dependencies() have been pruned under lib/Target.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195929 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-28 17:04:31 +00:00
NAKAMURA Takumi
ad363187c4 [CMake] Let add_public_tablegen_target responsible to provide dependency to CommonTableGen.
add_public_tablegen_target adds *CommonTableGen to LLVM_COMMON_DEPENDS.
LLVM_COMMON_DEPENDS affects add_llvm_library (and other add_target stuff) within its scope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195927 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-28 17:04:04 +00:00
David Majnemer
6a971bb8f5 Revert "Revert "Windows: Add support for unicode command lines""
This reverts commit r192070 which reverted r192069, I forgot to
regenerate the configure scripts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192079 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-07 01:00:07 +00:00
David Majnemer
b262556c45 Revert "Windows: Add support for unicode command lines"
This is causing MinGW bots to fail.
This reverts commit r192069.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192070 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-06 20:44:34 +00:00
David Majnemer
5a1a1856a4 Windows: Add support for unicode command lines
Summary:
The MSVCRT deliberately sends main() code-page specific characters.
This isn't too useful to LLVM as we end up converting the arguments to
UTF-16 and subsequently attempt to use the result as, for example, a
file name.  Instead, we need to have the ability to access the Unicode
command line and transform it to UTF-8.

This has the distinct advantage over using the MSVC-specific wmain()
function as our entry point because:
 - It doesn't work on cygwin.
 - It only work on MinGW with caveats and only then on certain versions.
 - We get to keep our entry point as main(). :)

N.B.  This patch includes fixes to other parts of lib/Support/Windows
s.t. we would be able to take advantage of getting the Unicode paths.
E.G.  clang spawning clang -cc1 would want to give it Unicode arguments.

Reviewers: aaron.ballman, Bigcheese, rnk, ruiu

Reviewed By: rnk

CC: llvm-commits, ygao

Differential Revision: http://llvm-reviews.chandlerc.com/D1834

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192069 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-06 20:25:49 +00:00
Hans Wennborg
4f5cfba4d5 cmake: Install llvm-tblgen again
It was removed in r189130, but it turns out this makes life hard for
folks packaging LLVM and Clang and building the latter based on the
LLVM package.

Note that this only adds back the LLVM tblgen, and it's obviously
not included when LLVM_INSTALL_TOOLCHAIN_ONLY is set.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190419 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 18:35:14 +00:00
Douglas Gregor
b51439594a CMake Xcode builds: symlink tblgen targets out to bin/.
Xcode always puts executable targets in the directory
bin/<Config>. When building separate LLVM and Clang projects for
Xcode, this prevents the CMake-configured project for Clang from
finding llvm-tblgen. Add a symlink so that tblgen executables are
always available in bin/ (regardless of the configuration LLVM is
built with).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189220 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-26 14:43:19 +00:00
Hans Wennborg
b7f81d372a CMake: don't install tablegen
Since it's an llvm-internal tool, we shouldn't install it.

(This depends on Clang r189127 and lld r189128.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189130 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 18:28:10 +00:00
Simon Atanasyan
df263de386 Pass -G argument to cmake with the same generator's name as used for the
initial cmake invocation.

Patch reviewed by Reid Kleckner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187591 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-01 18:04:07 +00:00
NAKAMURA Takumi
1b9d890455 TableGen.cmake: Fix to work without LLVM_COMMON_DEPENDS.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158650 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 15:41:56 +00:00
NAKAMURA Takumi
b510157d35 CMake: Add the folder "Tablegenning" on llvm-tblgen targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149219 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30 03:01:03 +00:00
Chandler Carruth
a71b7b0911 Fix a typo noticed by Peter Collingbourne. No one depends on this
working today, but it shouldn't corrupt state for some poor soul to
debug later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143545 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-02 16:55:57 +00:00
Chandler Carruth
1bfc9f8ff2 The TableGen parts of the CMake build are seriously broken. This fixes
one aspect of them by having them use the (annoying, if not broken)
proper library dependency model for adding the LLVMTableGen library as
a dependency. This could manifest as a link order issue in the presence
of separate LLVM / Clang source builds with CMake and a linker that
really cares about such things.

Also, add the Support dependency to llvm-tblgen itself so that it
doesn't rely on TableGen's transitive Support dependency. A parallel
change for clang-tblgen will be forthcoming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143531 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-02 05:03:06 +00:00
Peter Collingbourne
de8f33c199 Build system infrastructure for multiple tblgens.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141266 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 01:51:51 +00:00
Chandler Carruth
b35552d440 Clean up a pile of hacks in our CMake build relating to TableGen.
The first problem to fix is to stop creating synthetic *Table_gen
targets next to all of the LLVM libraries. These had no real effect as
CMake specifies that add_custom_command(OUTPUT ...) directives (what the
'tablegen(...)' stuff expands to) are implicitly added as dependencies
to all the rules in that CMakeLists.txt.

These synthetic rules started to cause problems as we started more and
more heavily using tablegen files from *subdirectories* of the one where
they were generated. Within those directories, the set of tablegen
outputs was still available and so these synthetic rules added them as
dependencies of those subdirectories. However, they were no longer
properly associated with the custom command to generate them. Most of
the time this "just worked" because something would get to the parent
directory first, and run tablegen there. Once run, the files existed and
the build proceeded happily. However, as more and more subdirectories
have started using this, the probability of this failing to happen has
increased. Recently with the MC refactorings, it became quite common for
me when touching a large enough number of targets.

To add insult to injury, several of the backends *tried* to fix this by
adding explicit dependencies back to the parent directory's tablegen
rules, but those dependencies didn't work as expected -- they weren't
forming a linear chain, they were adding another thread in the race.

This patch removes these synthetic rules completely, and adds a much
simpler function to declare explicitly that a collection of tablegen'ed
files are referenced by other libraries. From that, we can add explicit
dependencies from the smaller libraries (such as every architectures
Desc library) on this and correctly form a linear sequence. All of the
backends are updated to use it, sometimes replacing the existing attempt
at adding a dependency, sometimes adding a previously missing dependency
edge.

Please let me know if this causes any problems, but it fixes a rather
persistent and problematic source of build flakiness on our end.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 00:09:08 +00:00
Oscar Fuentes
ddfb69cd47 CMake: generalize the system that creates custom targets for
tablegenning to all libraries and executables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135908 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 14:11:55 +00:00
Oscar Fuentes
ba6ac91995 Add the tablegenned files to the `clean' target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124854 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 03:47:50 +00:00
Oscar Fuentes
d538e24922 Changes for building Clang and others using LLVM as an external
library.

Installs tblgen (required by Clang).

Translates handling of user settings and platform-dependant options to
its own file, where it can included by another project.

Installs the .cmake files required by projects like Clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124816 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 20:57:36 +00:00
Oscar Fuentes
5b30f0a7eb TableGen.cmake: sometimes the .td file is not in the current directory
(clang/include/clang/Basic/StmtNodes.td, for instance, is tablegenned
from clang/include/clang/AST/CMakeLists.txt) so it is not contained on
the list of all .td files on the current source directory which is
used as the DEPENDS of the custom command. We must add the .td file to
the DEPENDS list of the custom command. Otherwise some .inc files are
not regenerated when the corresponding .td file changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122768 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 20:01:32 +00:00
Oscar Fuentes
8c0cd08459 Avoid stalled file dependency when tablegenning.
Patch by Frits van Bommel!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117113 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 17:37:42 +00:00
Oscar Fuentes
8a116e0b3e Teach CMake to only touch tablegen-generated files if anything
actually changed.

Patch by Frits van Bommel!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 16:20:10 +00:00
Douglas Gregor
ba6fc63eb2 Allow absolute paths in LLVM_TARGET_DEFINITIONS for CMake's TableGen rule
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106219 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 15:17:07 +00:00
Douglas Gregor
66aa9b1c2f CMake: Don't use copy_if_different for TableGen output, because it does not work with IDE targets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79732 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-22 07:00:18 +00:00
Oscar Fuentes
d97ea308ed CMake: tablegen: Add .td files under the inlude/llvm directory
hierarchy to the list of dependencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 21:35:00 +00:00
Douglas Gregor
4b73893d82 Add missing dependencies to the CMake build system.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74161 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 05:03:06 +00:00
Oscar Fuentes
99b94892f5 CMake: Fixed parallel build problem related to native tblgen when
cross-compiling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73180 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-11 04:16:10 +00:00
Douglas Gregor
af3f5441b5 CMake: Make sure to build TableGen'd files in the binary directory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67052 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 21:35:18 +00:00
Oscar Fuentes
beb7a05086 CMake: Do not rebuild the world when tblgen changes but the .inc files
it produces are not affected by the change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59763 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 00:18:45 +00:00
Oscar Fuentes
cccecb8ea2 CMake: Use LLVM_MAIN_SRC_DIR instead of CMAKE_SOURCE_DIR, for
consistency.

Patch by Kevin Andre!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59326 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 22:21:02 +00:00
Oscar Fuentes
1bbdd4645b CMake: Fixed dependencies of .cpp source files on .td and tablegenned
files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59325 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 22:06:14 +00:00
Oscar Fuentes
3ab40ca3d5 CMake: Support for cross-compiling. For now, requires a previously
built native tblgen which is passed to cmake in the variable
LLVM_TABLEGEN.

See

http://www.cmake.org/Wiki/CmakeMingw

for a quick example on how to cross-compile with CMake.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58939 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 18:53:19 +00:00
Oscar Fuentes
980e842153 CMake: Removed some cruft.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 02:33:15 +00:00
Oscar Fuentes
e1ad087fcb CMake: Builds all targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56641 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 04:40:32 +00:00