google / ml-compiler-opt

Infrastructure for Machine Learning Guided Optimization (MLGO) in LLVM.
Apache License 2.0
612 stars 92 forks source link

【Question】What parameters need to be passed in to compile the data set? -Oz -Xclang -fembed-bitcode=all? #321

Closed 18liumin closed 8 months ago

18liumin commented 9 months ago

cmake -GNinja -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/googletest_install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=${LLVM_INSTALLDIR}/bin/clang++ -DCMAKE_C_COMPILER=${LLVM_INSTALLDIR}/bin/clang -DCMAKE_C_FLAGS="-Oz -Xclang -fembed-bitcode=all" -DCMAKE_CXX_FLAGS="-Oz -Xclang -fembed-bitcode=all" ..

boomanaiden154 commented 9 months ago

For inlining-for-size, you want to set up the build system to enable -Oz or at least -Os. This can be done in a variety of ways, for example CMake's CMAKE_BUILD_TYPE=MinSizeRel. Just adding -Oz or -Os to the compiler flags may not work depending upon how the build system is setup. And then you just need -Xclang -fembed-bitcode=all to embed the bitcode into the object file so that the ml-compiler-opt tooling is able to process it.

boomanaiden154 commented 9 months ago

Was there a comment/question here that got deleted? Got an email, but there's nothing here...