Standalone build broken after r269332

Hi!

I tried to build standalone LLDB after r269332 change in
LLDBStandalone.cmake and encountered next problems:

It implies that LLVM and Clang were built separately, but they could
be built together, so next changes should be made as in previous
version:

- include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ if (EXISTS "${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ endif()

Include path for generated LLVM headers were not added, so I made next tweak:

- include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
+ include_directories("${LLVM_OBJ_ROOT}/include"
"${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")

But biggest problem remains is how to specify Clang source and build
directories, since llvm-config doesn't tells about them.

Previously I set next variables, but situation may be different when
LLVM and Clang are built separately:

-DLLDB_PATH_TO_CLANG_BUILD=${LLVMBuildDir}/tools/clang
-DLLDB_PATH_TO_CLANG_SOURCE=${LLVMSourceDir}/tools/clang
-DLLDB_PATH_TO_LLVM_BUILD=${LLVMBuildDir}
-DLLDB_PATH_TO_LLVM_SOURCE=${LLVMSourceDir}

Eugene.

The requirement of source-code of Clang+LLVM and build dirs of Clang and
LLVM is no-go in a package-manager use-case. This is only needed for the
import of regex implementation pulled out of LLDB sources.

The proper fix for it is to stop using regex implementation from out of
the LLDB sources.

Temporarily, I'm building LLDB on NetBSD with a local patch [1] adding
these regex libraries without any further issues in the standalone
build. In order to work on proper regex usage in LLDB, I need to
increase the number of passed tests on my platform -- to catch any
regressions easier.

[1] https://github.com/NetBSD/pkgsrc-wip/tree/master/lldb-git/patches

Hi Eugene,

my thoughts on this are inline.

Hi!

I tried to build standalone LLDB after r269332 change in
LLDBStandalone.cmake and encountered next problems:

It implies that LLVM and Clang were built separately, but they could
be built together, so next changes should be made as in previous
version:

- include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ if (EXISTS "${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
+ endif()

This part makes sense. I don't like the "IF EXISTS" part that much,
but if there is no other reasonable way to test for "IF
LLVM_AND_CLANG_BUILT_TOGETHER", then that's fine. Here we have to
diverge from clang standalone build as it does not need to depend on
clang as well as llvm.

Include path for generated LLVM headers were not added, so I made next tweak:

- include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
+ include_directories("${LLVM_OBJ_ROOT}/include"
"${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")

Sounds reasonable as well (although it might be interesting to check
out how come clang does not need this fix as well).

But biggest problem remains is how to specify Clang source and build
directories, since llvm-config doesn't tells about them.

Previously I set next variables, but situation may be different when
LLVM and Clang are built separately:

-DLLDB_PATH_TO_CLANG_BUILD=${LLVMBuildDir}/tools/clang
-DLLDB_PATH_TO_CLANG_SOURCE=${LLVMSourceDir}/tools/clang
-DLLDB_PATH_TO_LLVM_BUILD=${LLVMBuildDir}
-DLLDB_PATH_TO_LLVM_SOURCE=${LLVMSourceDir}

At which stage does the build now fail for you (after applying the
fixes above)?

As Kamil said, LLDB really shouldn't depend on the clang source
folder. The only dependency I know of is the uglyness in lldb-mi, but
it looks like it should be easy to fix (basically, lldb-mi should use
the public regex interface instead of the private one, porting
appeared straight-forward), so I think someone should just bite the
bullet and do it. If you need any more changes after that, we can look
into that then.

pl

Hi, Pavel!

Hi Eugene,

my thoughts on this are inline.

At which stage does the build now fail for you (after applying the
fixes above)?

Build failed at very beginning:

source/lldb.cpp:19:10: fatal error: 'clang/Basic/Version.h' file not found

But there are much more places which depends on Clang headers (AST, Basic).

As Kamil said, LLDB really shouldn't depend on the clang source
folder. The only dependency I know of is the uglyness in lldb-mi, but
it looks like it should be easy to fix (basically, lldb-mi should use
the public regex interface instead of the private one, porting
appeared straight-forward), so I think someone should just bite the
bullet and do it. If you need any more changes after that, we can look
into that then.

I build LLVM/Clang/ect with LLVM_INSTALL_TOOLCHAIN_ONLY=ON, so source
and build directories are needed for headers and libraries. I try to
save disc space for final installation and we don't use LLVM/Clang
headers/libraries internally, so source and build directories were
good enough for us.

Eugene.

Ok, I see what the problem is now. If you run llvm-config from the
build folder, it will print out the correct path for the llvm headers,
but this will not be correct for the clang headers as it points
directly to the subfolder of the source llvm checkout. In Kamil's use
case this will be fine since he is presumably running an installed
llvm-config, in which case it ends up pointing us to the installed
headers under /usr/lib, and if you install clang to the same location
everything is fine.

So, it sounds to me like we should resurrect the CLANG_BUILD and
CLANG_SOURCE (a poor man's version of clang-config) variables that got
removed. There should be no need for the LLVM vars, as llvm-config
should cover that, right? Can you prepare a patch for that?

pl

In further changes please add me to review, I will test the standalone
build.

Yes, I'm running an installed version of llvm-config and I don't have
sources neither build files.