[llvm-dev] Building with LLVM_PARALLEL_XXX_JOBS

Sedat Dilek via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 17 02:05:58 PDT 2016


On Mon, Mar 14, 2016 at 5:30 PM, Chris Bieneman <cbieneman at apple.com> wrote:
[ brutal-snip ]
...
> [ TODO#S: Before doing a 2nd build (and in a 3rd run using more
> optimized binaries) ]
>
> How do I anable LTO via CMAKE?
>
>
> LLVM_ENALBLE_LTO=On
>

[ v4 of my build-script attached ]

Hi Chris,

thanks for the response!

That seems to work (see below).

$ cd $BUILD_DIR
$ grep -i lto CMakeCache.txt | grep ^[A-Z]
[ OUTPUT ]
LLVMLTO_LIB_DEPENDS:STATIC=
LLVM_ENALBLE_LTO:UNINITIALIZED=ON
LLVM_TOOL_LLVM_LTO_BUILD:BOOL=ON
LLVM_TOOL_LTO_BUILD:BOOL=ON
LTO_LIB_DEPENDS:STATIC=general;LLVMX86CodeGen;general;LLVMX86AsmPrinter;general;LLVMX86AsmParser;general;LLVMX86Desc;general;LLVMX86Info;general;LLVMX86Disassembler;general;LLVMCore;general;LLVMLTO;general;LLVMMC;general;LLVMMCDisassembler;general;LLVMSupport;general;LLVMTarget;
COMPILER_RT_HAS_FNO_LTO_FLAG:INTERNAL=1
LLVM_TOOL_LLVM_LTO_BUILD-ADVANCED:INTERNAL=1
LLVM_TOOL_LTO_BUILD-ADVANCED:INTERNAL=1
[ /OUTPUT ]

But is no more documented in
<http://llvm.org/releases/3.8.0/docs/CMake.html> or
<http://llvm.org/docs/CMake.html>.
I have seen LLVM_ENALBLE_LTO=On in some older docs.
Bring it back?
AFAICS, "cmake -LA | grep -i $pattern" die not show me this, but I
might be wrong.
( Some weeks ago, I dealt with LTO/PGO. )

> How do I enable PGO via CMAKE?
>
>
> I’m actually in the middle of writing some documentation on this right now
> because I recently made this process a lot easier. Let me give you the high
> level overview.
>
> The way PGO works is that you build an instrumented compiler, then you run
> the instrumented compiler against sample source files. While the
> instrumented compiler runs it will output a bunch of files containing
> performance counters (.profraw files). After generating all the profraw
> files you use llvm-profdata to merge the files into a single profdata file
> that you can feed into the LLVM_PROFDATA_FILE option.
>
> Alas, there is an easier way to generate the profdata file!
>
> If you look in the clang repo at <clang>/cmake/caches/README.txt you’ll see
> an explanation of how to use the PGO CMake cache file. The basic idea is you
> run:
>
> $ cmake -G <generator> -C <path_to_clang>/cmake/caches/PGO.cmake <source
> dir>
> $ <build tool> stage2-instrumented-generate-profdata
>
> If you let that run for a few hours or so, it will place a profdata file in
> your build directory. This takes a really long time because it builds clang
> twice, and you *must* have compiler-rt in your build tree.
>
> This process uses any source files under the perf-training directory as
> training data as long as the source files are marked up with LIT-style RUN
> lines.
>
> After it finishes you can use “find . -name clang.profdata” to find it, but
> it should be at a path something like:
>
> <build
> dir>/tools/clang/stage2-instrumented-bins/utils/perf-training/clang.profdata
>
> You can feed that file into the LLVM_PROFDATA_FILE option when you build
> your optimized compiler.
>

Uuuugh, that sounds a bit complicated or at least for me :-).
I am not that familiar with CMake and the llvm-toolchain build-system.

I need something simple like...

PGO_CMAKE_OPTS="..."
CONFIGURE_CMAKE_OPTS="$CONFIGURE_CMAKE_OPTS $PGO_CMAKE_OPTS"

...in my build-script.

Thanks.

- Sedat -


> -Chris
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_llvm-toolchain_clang-cmake-ninja-gold_v4.sh
Type: application/x-sh
Size: 5026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160317/dbf87127/attachment.sh>


More information about the llvm-dev mailing list