From bffc94b08f713cc9916009575664b132aee76bcf Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 10 Dec 2020 13:50:31 -0800 Subject: compilers: Add support for using multiple threads with lto Both Clang and GCC support using multiple threads for preforming link time optimizaions, and they can now be configured using the `-Db_lto_threads` option. Fixes #7820 --- docs/markdown/Builtin-options.md | 43 +++++++++++++++++++---------------- docs/markdown/snippets/lto_threads.md | 7 ++++++ 2 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 docs/markdown/snippets/lto_threads.md (limited to 'docs/markdown') diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md index ef327e3..f57755c 100644 --- a/docs/markdown/Builtin-options.md +++ b/docs/markdown/Builtin-options.md @@ -119,30 +119,33 @@ no options. The following options are available. Note that they may not be available on all platforms or with all compilers: -| Option | Default value | Possible values | Description | -| ----------- | ------------- | --------------- | ----------- | -| b_asneeded | true | true, false | Use -Wl,--as-needed when linking | -| b_bitcode | false | true, false | Embed Apple bitcode, see below | -| b_colorout | always | auto, always, never | Use colored output | -| b_coverage | false | true, false | Enable coverage tracking | -| b_lundef | true | true, false | Don't allow undefined symbols when linking | -| b_lto | false | true, false | Use link time optimization | -| b_ndebug | false | true, false, if-release | Disable asserts | -| b_pch | true | true, false | Use precompiled headers | -| b_pgo | off | off, generate, use | Use profile guided optimization | -| b_sanitize | none | see below | Code sanitizer to use | -| b_staticpic | true | true, false | Build static libraries as position independent | -| b_pie | false | true, false | Build position-independent executables (since 0.49.0)| -| b_vscrt | from_buildtype| none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype | VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0) | +| Option | Default value | Possible values | Description | +|---------------|----------------|------------------------------------------------------------------|-------------------------------------------------------------------------------| +| b_asneeded | true | true, false | Use -Wl,--as-needed when linking | +| b_bitcode | false | true, false | Embed Apple bitcode, see below | +| b_colorout | always | auto, always, never | Use colored output | +| b_coverage | false | true, false | Enable coverage tracking | +| b_lundef | true | true, false | Don't allow undefined symbols when linking | +| b_lto | false | true, false | Use link time optimization | +| b_lto_threads | 0 | Any integer* | Use multiple threads for lto. *(Added in 0.57.0)* | +| b_ndebug | false | true, false, if-release | Disable asserts | +| b_pch | true | true, false | Use precompiled headers | +| b_pgo | off | off, generate, use | Use profile guided optimization | +| b_sanitize | none | see below | Code sanitizer to use | +| b_staticpic | true | true, false | Build static libraries as position independent | +| b_pie | false | true, false | Build position-independent executables (since 0.49.0) | +| b_vscrt | from_buildtype | none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype | VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0) | The value of `b_sanitize` can be one of: `none`, `address`, `thread`, `undefined`, `memory`, `address,undefined`. - The default value of `b_vscrt` -is `from_buildtype`. The following table is used internally to pick -the CRT compiler arguments for `from_buildtype` or -`static_from_buildtype` *(since 0.56)* based on the value of the -`buildtype` option: +* < 0 means disable, == 0 means automatic selection, > 0 sets a specific number to use + + +The default value of `b_vscrt` is `from_buildtype`. The following table is +used internally to pick the CRT compiler arguments for `from_buildtype` or +`static_from_buildtype` *(since 0.56)* based on the value of the `buildtype` +option: | buildtype | from_buildtype | static_from_buildtype | | -------- | -------------- | --------------------- | diff --git a/docs/markdown/snippets/lto_threads.md b/docs/markdown/snippets/lto_threads.md new file mode 100644 index 0000000..a6f7614 --- /dev/null +++ b/docs/markdown/snippets/lto_threads.md @@ -0,0 +1,7 @@ +## Knob to control LTO thread + +Both the gnu linker and lld support using threads for speading up LTO, meson +now provides a knob for this: `-Db_lto_threads`. Currently this is only +supported for clang and gcc. Any positive integer is supported, `0` means +`auto`. If the compiler or linker implemnets it's on `auto` we use that, +otherwise the number of threads on the machine is used. -- cgit v1.1 From 6f532b72c85e38880cf7953098bb91e8f3feb696 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 10 Dec 2020 14:16:45 -0800 Subject: Add support for LLVM's thinLTO This uses a separate option, b_lto_mode. It works in conjunction with b_lto_threads. Fixes #7493 --- docs/markdown/Builtin-options.md | 3 +++ docs/markdown/snippets/lto_mode.md | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 docs/markdown/snippets/lto_mode.md (limited to 'docs/markdown') diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md index f57755c..2d7c01c 100644 --- a/docs/markdown/Builtin-options.md +++ b/docs/markdown/Builtin-options.md @@ -128,6 +128,7 @@ available on all platforms or with all compilers: | b_lundef | true | true, false | Don't allow undefined symbols when linking | | b_lto | false | true, false | Use link time optimization | | b_lto_threads | 0 | Any integer* | Use multiple threads for lto. *(Added in 0.57.0)* | +| b_lto_mode | default | default, thin | Select between lto modes, thin and default. *(Added in 0.57.0)* | | b_ndebug | false | true, false, if-release | Disable asserts | | b_pch | true | true, false | Use precompiled headers | | b_pgo | off | off, generate, use | Use profile guided optimization | @@ -141,6 +142,8 @@ The value of `b_sanitize` can be one of: `none`, `address`, `thread`, * < 0 means disable, == 0 means automatic selection, > 0 sets a specific number to use +LLVM supports `thin` lto, for more discussion see [LLVM's documentation](https://clang.llvm.org/docs/ThinLTO.html) + The default value of `b_vscrt` is `from_buildtype`. The following table is used internally to pick the CRT compiler arguments for `from_buildtype` or diff --git a/docs/markdown/snippets/lto_mode.md b/docs/markdown/snippets/lto_mode.md new file mode 100644 index 0000000..c1df066 --- /dev/null +++ b/docs/markdown/snippets/lto_mode.md @@ -0,0 +1,5 @@ +## Support added for LLVM's thinLTO + +A new `b_lto_mode` option has been added, which may be set to `default` or +`thin`. Thin only works for clang, and only with gnu gold, lld variants, or +ld64. -- cgit v1.1