Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm 10.0.0 #1450

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/llvm/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
10.0.0:
url: https://github.com/llvm/llvm-project/archive/llvmorg-10.0.0.zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-project-10.0.0.tar.xz which is 80Mb in size compared to the zip archive which is ~150Mb.

Also it may be worth updating to 10.0.1 which contains a number of bugfixes.

sha256: d2fadc9962ccceab2b9b0d806352db690c9040f24f4a4bdef37b72dcc82fc07a
113 changes: 113 additions & 0 deletions recipes/llvm/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from conans import ConanFile, tools, CMake
from conans.tools import Version
from conans.errors import ConanInvalidConfiguration
import os, shutil, glob

projects = [
'clang',
'clang-tools-extra',
'compiler-rt',
'debuginfo-tests',
'libc',
'libclc',
'libcxx',
'libcxxabi',
'libunwind',
'lld',
'lldb',
'mlir',
'openmp',
'parallel-libs',
'polly',
'pstl'
]

default_projects = [
'clang',
'compiler-rt'
]

class Llvm(ConanFile):
name = 'llvm'
description = 'The LLVM Project is a collection of modular and reusable compiler and toolchain technologies'
url = 'https://github.com/conan-io/conan-center-index'
homepage = 'https://github.com/llvm/llvm-project'
license = 'Apache 2.0'
topics = 'c++', 'compiler', 'tooling'

settings = 'os', 'arch', 'compiler', 'build_type'

no_copy_source = True
_source_subfolder = 'source_subfolder'

options = {**{ 'with_' + project : [True, False] for project in projects }, **{
'fPIC': [True, False]
}}
default_options = {**{ 'with_' + project : project in default_projects for project in projects }, **{
'fPIC': True
}}
generators = 'cmake_find_package'

@property
def repo_folder(self):
return os.path.join(self.source_folder, self._source_subfolder)

def project_folder(self, project):
return os.path.join(self.repo_folder, project)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = 'llvm-project-llvmorg-' + self.version
os.rename(extracted_dir, self._source_subfolder)

def configure(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, '14')

if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) < "19.1":
raise ConanInvalidConfiguration("Need MSVC >= 19.1")
Comment on lines +67 to +68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're too restrictive. Visual Studio 2017 is version 15.
(see the generator section of cmake --help)

Copy link
Contributor Author

@Manu343726 Manu343726 Apr 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, see the previous build error:

CMake Error at cmake/modules/CheckCompilerVersion.cmake:38 (message):
  Host Visual Studio version must be at least 19.1, your version is
  19.0.24215.1.
Call Stack (most recent call first):
  cmake/modules/CheckCompilerVersion.cmake:51 (check_compiler_version)
  cmake/config-ix.cmake:13 (include)
  CMakeLists.txt:623 (include)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19.0.24215.1 is the version of the C compiler, not the version of visual studio.

Look at personal your conan settings file: $HOME/.conan/settings.yml.
There exists no Visual Studio compiler whose version >= 19.1.
Or check https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2019.
Visual Studio 2019 => version 16.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/llvm/llvm-project/blob/master/llvm/cmake/modules/CheckCompilerVersion.cmake#L53-L64

So host Visual Studio version 16.4 and lower is known to miscompile part of LLVM.

  • That means only up-to-date versions of visual studio 2019 can build llvm.
  • This also means that the test in configure must compare against the major.minor version of MSVC (16.4) instead of only major (16).


def build(self):
enabled_projects = [project for project in projects if getattr(self.options, 'with_' + project)]
self.output.info('Enabled LLVM subprojects: {}'.format(', '.join(enabled_projects)))

cmake = CMake(self);
cmake.configure(
defs = {
'LLVM_ENABLE_PROJECTS': ';'.join(enabled_projects)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add LLVM_ENABLE_BINDINGS: False. These are probably not needed in a C++ library, and the OCaml bindings end up in /usr/lib/ocaml` by default (at least on my system) which is outside of the conan cache folder.

},
source_folder = os.path.join(self._source_subfolder, 'llvm')
)
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package needs to call cmake.configure() also. I think it's idiomatic to refactor CMake configuration into a separate function (see How to reuse cmake install for package() method) and additionally cache the cmake variable in an instance member variable


self.copy(
'LICENSE.TXT',
src=self.project_folder('clang'),
dst='licenses',
keep_path=False)

ignore = [
'share',
'libexec',
'**/Find*.cmake',
'**/*Config.cmake'
]

for ignore_entry in ignore:
ignore_glob = os.path.join(self.package_folder, ignore_entry)

for ignore_path in glob.glob(ignore_glob, recursive=True):
self.output.info('Remove ignored file/directory "{}" from package'.format(ignore_path))

if os.path.isfile(ignore_path):
os.remove(ignore_path)
else:
shutil.rmtree(ignore_path)

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.builddirs = ['lib/cmake']
10 changes: 10 additions & 0 deletions recipes/llvm/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

set(CMAKE_CXX_STANDARD 14)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/llvm/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
Loading