Closed SylvainCorlay closed 7 years ago
Please have a look at here. Cling should only look for llvm and clang if it is not installed. Check out the contents of cling-compiledata.h.
Here is what a naive build of the recipe yields (disregard env_placehold_placehold_placehold
), which is the placeholder for the install prefix...
-- Cling will look for C++ headers in '/usr/include/c++/5:/usr/include/x86_64-linux-gnu/c++/5:/usr/include/c++/5/backward' at runtime.
-- And if not found, will invoke: 'g++-5' for them.
-- Configuring done
CMake Error at /home/sylvain/miniconda3/conda-bld/cling_1486418090716/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/cmake/llvm/AddLLVM.cmake:513 (add_dependencies):
The dependency target "ClangDriverOptions" of target "clingInterpreter"
does not exist.
Call Stack (most recent call first):
CMakeLists.txt:315 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
CMake Error at /home/sylvain/miniconda3/conda-bld/cling_1486418090716/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/cmake/llvm/AddLLVM.cmake:513 (add_dependencies):
The dependency target "clang-headers" of target "clingInterpreter" does not
exist.
Call Stack (most recent call first):
CMakeLists.txt:315 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
CMake Error at /home/sylvain/miniconda3/conda-bld/cling_1486418090716/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/cmake/llvm/AddLLVM.cmake:513 (add_dependencies):
The dependency target "intrinsics_gen" of target "clingInterpreter" does
not exist.
Call Stack (most recent call first):
CMakeLists.txt:315 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
[...]
What is surprising is the location where headers are being looked for. Do you always expect CLING_CXX_PATH
and CLING_CXX_HEADERS
to be set manually?
No, if CLING_CXX_PATH
and CLING_CXX_HEADERS
are not set we will ask the available compiler (in this case g++-5) for its headers locations and we will pick them on the target system.
The errors seem to be coming because we maybe need to rely not only on AddLLVM.cmake but on clang's cmake 'stuff' too.
This is not specific to the conda recipe, but also when building locally against llvm[cling] and clang[cling]. So there is an actual issue with cling's cmake which does not support build with clang as an external library. The short way to reproduce this without breaking your work environment.
Download miniconda here: https://conda.io/miniconda.html. Install it somewhere in your home directory.
conda install cmake llvmdev clangdev cling-patches -c conda-forge
clone cling
/ cd cling
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/path/to/miniconda/root/ -D CMAKE_BUILD_TYPE=Release ..
make
Then you can delete the miniconda installation and there will be no artefact left.
Starting to look at clang's cmake stuff.
Clang does have a AddClang.cmake
module, but it is not installed with the distribution (however ClangConfig.cmake
is installed correctly). Besides, adding include('AddClang')
and providing the same boilerplate for its location results in the same error message as above.
The cmake file has a weird logic with call to llvm_add_library
which is defined in llvm's cmake.
Commenting out the line
llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
gives the next error
CMake Error at tools/driver/CMakeLists.txt:48 (target_link_libraries):
Target "clingUserInterface" of type UTILITY may not be linked into another
target. One may link only to STATIC or SHARED libraries, or to executables
with the ENABLE_EXPORTS property set.
@karies @vgvassilev let me know if you need other info.
I got the cling variants for clang and llvm in conda-forge and this is the last step to complete a conda package for cling on conda-forge.
Edit: I just posted on the forum with some more details on my attempts to fix the cmake file.
Hm... it seems bd5d32f9e broke it. Could you remove this dependency and try? We need to pick up a publicly available dependency on tablegen-ed targets.
Hm... it seems bd5d32f broke it. Could you remove this dependency and try? We need to pick up a publicly available dependency on tablegen-ed targets.
No luck... Same error. :unamused:
CMake Error at /home/sylvain/miniconda3/lib/cmake/llvm/AddLLVM.cmake:513 (add_dependencies):
The dependency target "clang-headers" of target "clingInterpreter" does not
exist.
Call Stack (most recent call first):
CMakeLists.txt:315 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
Ok, it seems that we should rely on what is ClangConfig.cmake/ClangTargets.cmake... Could you try changing this dependency to something from the public config? Eg. clangSema
.
Gotcha. This looks like the solution. I will get back to you.
Perhaps, we should be relying on something that is very "early" in the dependency chain, maybe clangTableGen...
Adding
find_package(Clang REQUIRED)
at line the top level results in llvm-config failed with status Permission denied
.
Lol, so, @JohanMabille just found out that the lines
find_program(LLVM_CONFIG "llvm-config")
if(LLVM_CONFIG)
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}"
without the find-package
, prints
-- Found LLVM_CONFIG as /home/sylvain/miniconda3/bin/llvm-config
while with the find_package
it prints
-- Found LLVM_CONFIG as /home/sylvain/miniconda3/lib/cmake/llvm/LLVMConfig.cmake
That seems like a bug on the llvm side.
-DLLVM_CONFIG=/path/to/llvm-config
works around it and results in the same error as before.
Can you paste the error?
Edit: btw, is the llvm-config executable?
Actually errors are due to dependencies that don't exist in any of the ClangXXXX.cmake: ClangDriverOptions, clang-headers and intrinsics-gen. Commenting out these dependencies fixes the issue. However the compilation then quickly fails.
Yeah, the cmake
completes but the actual build from the generated makefile fails with c++ errors.
Here are the errors without commenting out the dependencies:
CMake Error at C:/Users/jmabille/Miniconda3/Library/lib/cmake/llvm/AddLLVM.cmake:517 (add_dependencies):
The dependency target "ClangDriverOptions" of target "obj.clingInterpreter"
does not exist.
Call Stack (most recent call first):
CMakeLists.txt:316 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
CMake Error at C:/Users/jmabille/Miniconda3/Library/lib/cmake/llvm/AddLLVM.cmake:517 (add_dependencies):
The dependency target "clang-headers" of target "obj.clingInterpreter" does
not exist.
Call Stack (most recent call first):
CMakeLists.txt:316 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
CMake Error at C:/Users/jmabille/Miniconda3/Library/lib/cmake/llvm/AddLLVM.cmake:517 (add_dependencies):
The dependency target "intrinsics_gen" of target "obj.clingInterpreter"
does not exist.
Call Stack (most recent call first):
CMakeLists.txt:316 (llvm_add_library)
lib/Interpreter/CMakeLists.txt:41 (add_cling_library)
The following patch fixes the cmake step.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 980c7eb..04d8e79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.4.3)
# standalone project, using LLVM as an external library:
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
project(Cling)
+ find_package(Clang REQUIRED)
if(WIN32)
# We need cmake to support exporting of symbols not only from libraries but
@@ -460,8 +461,8 @@ get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
list(APPEND LLVM_COMMON_DEPENDS ${CLANG_TABLEGEN_TARGETS})
# And llvm-intrinsics.
-list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
-list(APPEND LLVM_COMMON_DEPENDS clang-headers)
+#list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
+#list(APPEND LLVM_COMMON_DEPENDS clang-headers)
add_subdirectory(lib)
add_subdirectory(tools)
diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt
index 978d283..fdbd22f 100644
--- a/lib/Interpreter/CMakeLists.txt
+++ b/lib/Interpreter/CMakeLists.txt
@@ -73,9 +73,6 @@ add_cling_library(clingInterpreter OBJECT
ValuePrinter.cpp
ValuePrinterSynthesizer.cpp
- DEPENDS
- ClangDriverOptions
-
LINK_LIBS
${LIBS}
)
diff --git a/lib/MetaProcessor/CMakeLists.txt b/lib/MetaProcessor/CMakeLists.txt
index 5460a2a..6806e57 100644
--- a/lib/MetaProcessor/CMakeLists.txt
+++ b/lib/MetaProcessor/CMakeLists.txt
@@ -19,9 +19,6 @@ add_cling_library(clingMetaProcessor OBJECT
MetaProcessor.cpp
MetaSema.cpp
- DEPENDS
- ClangDriverOptions
-
LINK_LIBS
clangLex
clangAST
Now the make compilation errors.
[sylvain@mbp ~/dev/root/cling/build ((cling-nightlies) *)]$ make
[ 1%] Updating cling-compiledata.h
Scanning dependencies of target obj.clingInterpreter
[ 2%] Building CXX object lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/AutoSynthesizer.cpp.o
[ 4%] Building CXX object lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/AutoloadCallback.cpp.o
[ 5%] Building CXX object lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/ASTTransformer.cpp.o
[ 6%] Building CXX object lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/BackendPasses.cpp.o
/home/sylvain/dev/root/cling/lib/Interpreter/BackendPasses.cpp: In member function ‘void cling::BackendPasses::CreatePasses(llvm::Module&)’:
/home/sylvain/dev/root/cling/lib/Interpreter/BackendPasses.cpp:125:44: error: ‘const class clang::CodeGenOptions’ has no member named ‘UnitAtATime’
PMBuilder.DisableUnitAtATime = !m_CGOpts.UnitAtATime;
^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-unused-local-typedef" [enabled by default]
cc1plus: warning: unrecognized command line option "-Wno-covered-switch-default" [enabled by default]
cc1plus: warning: unrecognized command line option "-Wno-nested-anon-types" [enabled by default]
lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/build.make:138: recipe for target 'lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/BackendPasses.cpp.o' failed
make[2]: *** [lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/BackendPasses.cpp.o] Error 1
CMakeFiles/Makefile2:150: recipe for target 'lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/all' failed
make[1]: *** [lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
It looks like UnitAtATime
is unused. Could you set this to 0?
OK @vgvassilev , We know what is going on.
Our [cling]-flavored clang and llvm packages are based on clang 3.9.1
(we rebased your patches upon it to be able to build a recipe from the same source as the default flavor). UnitAtATime
does not exist in this version of clang.
I think that the other build errors that we are seeing also come from this.
@vgvassilev do you have a process on the re-basing of the cling-patches
branches on later commit of the main repo?
In general, it would be great for packaging if you branched out from releases.
We have an internal guidelines, but I think nothing formalized. I agree it would be good but I don't think it will happen for 3.9.1.
3.9.1 is a later commit than where you branched out.
Branching out an actual release is important so that we can apply patches to a released source tarball.
OK, I have a patch that seems to work, which I will add to the conda recipe. If was mostly a matter of passing instances of ArrayRef
instead of pointers + size.
The reason why I end up debugging LLVM:
The following patch makes things build!
From 4d8d8b3bfb663c8bf8090e7e9fc21d89b87b7e66 Mon Sep 17 00:00:00 2001
From: Sylvain Corlay <sylvain.corlay@gmail.com>
Date: Mon, 13 Feb 2017 23:23:29 +0100
Subject: [PATCH] conda-patch
---
CMakeLists.txt | 8 +++++---
lib/Interpreter/BackendPasses.cpp | 1 -
lib/Interpreter/CMakeLists.txt | 3 ---
lib/Interpreter/DynamicLookup.cpp | 3 +--
lib/MetaProcessor/CMakeLists.txt | 3 ---
lib/UserInterface/UserInterface.cpp | 2 +-
lib/Utils/AST.cpp | 11 ++++-------
7 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 980c7eb..fbead85 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
else()
message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
endif()
+
+ find_package(Clang REQUIRED)
list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
@@ -101,7 +103,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set(LLVM_INCLUDE_TESTS ON)
endif()
- include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
+ include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
link_directories("${LLVM_LIBRARY_DIR}")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
@@ -460,8 +462,8 @@ get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
list(APPEND LLVM_COMMON_DEPENDS ${CLANG_TABLEGEN_TARGETS})
# And llvm-intrinsics.
-list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
-list(APPEND LLVM_COMMON_DEPENDS clang-headers)
+#list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
+#list(APPEND LLVM_COMMON_DEPENDS clang-headers)
add_subdirectory(lib)
add_subdirectory(tools)
diff --git a/lib/Interpreter/BackendPasses.cpp b/lib/Interpreter/BackendPasses.cpp
index dc37ffc..df070ed 100644
--- a/lib/Interpreter/BackendPasses.cpp
+++ b/lib/Interpreter/BackendPasses.cpp
@@ -122,7 +122,6 @@ void BackendPasses::CreatePasses(llvm::Module& M)
PMBuilder.LoopVectorize = m_CGOpts.VectorizeLoop;
PMBuilder.DisableTailCalls = m_CGOpts.DisableTailCalls;
- PMBuilder.DisableUnitAtATime = !m_CGOpts.UnitAtATime;
PMBuilder.DisableUnrollLoops = !m_CGOpts.UnrollLoops;
PMBuilder.MergeFunctions = m_CGOpts.MergeFunctions;
PMBuilder.RerollLoops = m_CGOpts.RerollLoops;
diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt
index 978d283..fdbd22f 100644
--- a/lib/Interpreter/CMakeLists.txt
+++ b/lib/Interpreter/CMakeLists.txt
@@ -73,9 +73,6 @@ add_cling_library(clingInterpreter OBJECT
ValuePrinter.cpp
ValuePrinterSynthesizer.cpp
- DEPENDS
- ClangDriverOptions
-
LINK_LIBS
${LIBS}
)
diff --git a/lib/Interpreter/DynamicLookup.cpp b/lib/Interpreter/DynamicLookup.cpp
index 82eb9d4..c188644 100644
--- a/lib/Interpreter/DynamicLookup.cpp
+++ b/lib/Interpreter/DynamicLookup.cpp
@@ -96,8 +96,7 @@ namespace {
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(OS,
- Node->getTemplateArgs(),
- Node->getNumTemplateArgs(),
+ llvm::ArrayRef<clang::TemplateArgumentLoc>(Node->getTemplateArgs(), Node->getNumTemplateArgs()),
m_Policy);
if (Node->hasExplicitTemplateArgs())
assert((Node->getTemplateArgs() || Node->getNumTemplateArgs()) && \
diff --git a/lib/MetaProcessor/CMakeLists.txt b/lib/MetaProcessor/CMakeLists.txt
index 5460a2a..6806e57 100644
--- a/lib/MetaProcessor/CMakeLists.txt
+++ b/lib/MetaProcessor/CMakeLists.txt
@@ -19,9 +19,6 @@ add_cling_library(clingMetaProcessor OBJECT
MetaProcessor.cpp
MetaSema.cpp
- DEPENDS
- ClangDriverOptions
-
LINK_LIBS
clangLex
clangAST
diff --git a/lib/UserInterface/UserInterface.cpp b/lib/UserInterface/UserInterface.cpp
index 1549306..1d60512 100644
--- a/lib/UserInterface/UserInterface.cpp
+++ b/lib/UserInterface/UserInterface.cpp
@@ -20,7 +20,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Frontend/CompilerInstance.h"
diff --git a/lib/Utils/AST.cpp b/lib/Utils/AST.cpp
index e3d1a8a..f271828 100644
--- a/lib/Utils/AST.cpp
+++ b/lib/Utils/AST.cpp
@@ -290,7 +290,7 @@ namespace utils {
if (mightHaveChanged) {
QualType QT
= Ctx.getTemplateSpecializationType(TST->getTemplateName(),
- desArgs.data(), desArgs.size(),
+ llvm::ArrayRef<clang::TemplateArgument>(desArgs.data(), desArgs.size()),
TST->getCanonicalTypeInternal());
return QT.getTypePtr();
}
@@ -324,8 +324,7 @@ namespace utils {
TemplateName TN(TSTdecl->getSpecializedTemplate());
QualType QT
= Ctx.getTemplateSpecializationType(TN,
- desArgs.data(),
- desArgs.size(),
+ llvm::ArrayRef<clang::TemplateArgument>(desArgs.data(), desArgs.size()),
TSTRecord->getCanonicalTypeInternal());
return QT.getTypePtr();
}
@@ -1316,8 +1315,7 @@ namespace utils {
if (mightHaveChanged) {
Qualifiers qualifiers = QT.getLocalQualifiers();
QT = Ctx.getTemplateSpecializationType(TST->getTemplateName(),
- desArgs.data(),
- desArgs.size(),
+ llvm::ArrayRef<clang::TemplateArgument>(desArgs.data(), desArgs.size()),
TST->getCanonicalTypeInternal());
QT = Ctx.getQualifiedType(QT, qualifiers);
}
@@ -1389,8 +1387,7 @@ namespace utils {
if (mightHaveChanged) {
Qualifiers qualifiers = QT.getLocalQualifiers();
TemplateName TN(TSTdecl->getSpecializedTemplate());
- QT = Ctx.getTemplateSpecializationType(TN, desArgs.data(),
- desArgs.size(),
+ QT = Ctx.getTemplateSpecializationType(TN, llvm::ArrayRef<clang::TemplateArgument>(desArgs.data(), desArgs.size()),
TSTRecord->getCanonicalTypeInternal());
QT = Ctx.getQualifiedType(QT, qualifiers);
}
--
2.7.4
:tada: hurray. I got a running conda package!
expect a few days before it gets through on conda.
Moving find_package(Clang REQUIRED)
after the invocation of LLVM_CONFIG
allows to build without the workaround -DLLVM_CONFIG=/path/to/llvm-config
. Note that this find_package
statement is required, else the build ends up with unresolved external symbols.
ok, thanks @JohanMabille this seems to work and simplify the patch - I amended the comment above.
@vgvassilev do I need to make a cling variant for the libcxx
package and build it with the [cling] variant of llvm and clang or is the stock version good?
I am having some issues with the c runtime when using the conda package generated. Is there a flag to enable so that cling uses a given C runtime (I guess libcxx instead of gcc's)?
Would -DLLVM_ENABLE_LIBCXX=1
work?
Checking.
Just to clarify, should LLVM and clang be built with that option too or just cling?
LLVM and cling should be built with the same set of options. So yeah, we should build LLVM with this option. However, I recall that if there is libcxx on the system LLVM enables this by default.
Cling should be able to detect which is the version which it was compiled with and use it.
Hi, really good timing for me, thx for your work. just downloaded cling and tried to install the kernel but failed with pip instruction, i don't know what I am missing. so just want to ask when it will be available for conda? and is there any plan for ROOT to be added to conda?
@cppchedy This coming very soon. Stay tuned for an announcement early this week for the OS X and Linux builds first which work well.
@SylvainCorlay cool! so I guess _ will stop now and just wait for the conda package. thx a lot. any idea on possible ROOT package at anaconda?
any idea on possible ROOT package at anaconda?
I am only working on cling.
ok!! thx for you answer!!
@SylvainCorlay Any update on the Mac build?
I eventually completed the packaging of the
[cling]
variants ofllvm
andclang
in conda forge, using the "build-features" functionality of conda. Besides, I moved the windows recipe to msvc14.Now I am trying to get around the
CMakeList.txt
of cling itself. It seems that building cling while using clang as an external library is not quite supported.Cling is correctly finding llvm with the project config cmake file, but does not seem to recognize some clang targets.