I have followed the instructions here to build the modified version of clang used to build Android 11 (r383902b1, using manifest_6877366.xml).
Running python toolchain/llvm_android/build.py results in a successful build, but I am unable to build the PrintFunctionNames plugin example located in toolchain/llvm-project/clang/examples/.
I have tried modifying various flags in the build files, for example:
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -508,7 +508,7 @@ add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(runtime)
-option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF)
+option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." ON)
add_subdirectory(examples)
and
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -41,7 +41,7 @@ write_lit_config("lit_site_cfg") {
extra_values = [
"LLVM_WITH_Z3=", # Must be empty, not 0.
- "CLANG_BUILD_EXAMPLES=0",
+ "CLANG_BUILD_EXAMPLES=1",
"CLANG_DEFAULT_CXX_STDLIB=", # Empty string means "default value" here.
"CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
and even
project toolchain/llvm_android/
diff --git a/do_build.py b/do_build.py
index 7952a57..b8aeed5 100755
--- a/do_build.py
+++ b/do_build.py
@@ -198,6 +198,11 @@ def invoke_cmake(out_path, defines, env, cmake_path, target=None, install=True):
flags = ['-G', 'Ninja']
flags += ['-DCMAKE_MAKE_PROGRAM=' + str(paths.NINJA_BIN_PATH)]
+ flags += ['-DLLVM_INCLUDE_EXAMPLES=On']
+ flags += ['-DLLVM_BUILD_EXAMPLES=1']
+ flags += ['-DCLANG_BUILD_EXAMPLES=1']
+ flags += ['-DBUILD_EXAMPLES=1']
+ flags += ['-DCLANG_INCLUDE_EXAMPLES=On']
I have also tried executing cmake directly in order to try several answers to this related question, but they have not resulted in building the plugin.