Skip to content

implement mold/1.3.1 recipe #11536

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

Merged
merged 46 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ccfa8d9
implement mold recipe
AndreyMlashkin Jul 4, 2022
bb4efe2
fix linter errors
AndreyMlashkin Jul 4, 2022
b84ab67
linter fixes
AndreyMlashkin Jul 4, 2022
5e13937
linter fixes
AndreyMlashkin Jul 4, 2022
3c44d0e
make CI lint happy
AndreyMlashkin Jul 5, 2022
345affb
add test recipe
AndreyMlashkin Jul 6, 2022
3214018
add zlib requirement
AndreyMlashkin Jul 6, 2022
ecbf58d
use only gcc version higher than 8
AndreyMlashkin Jul 7, 2022
cb6895b
override LD variable
AndreyMlashkin Jul 7, 2022
f15efb0
use zlib from conan
AndreyMlashkin Jul 7, 2022
564e8ca
add forgotten patch
AndreyMlashkin Jul 7, 2022
3edc425
make linter happy
AndreyMlashkin Jul 7, 2022
d8bb692
increase gcc version requirement
AndreyMlashkin Jul 7, 2022
87d63d6
hardcode zlib patch
AndreyMlashkin Jul 7, 2022
9d31754
remove patches
AndreyMlashkin Jul 7, 2022
9fb1727
add openssl dependency
AndreyMlashkin Jul 7, 2022
81a8eec
remove options
AndreyMlashkin Jul 7, 2022
6e2f452
increase clang version requirements
AndreyMlashkin Jul 7, 2022
f8212c1
forbid apple-clang with version less 11
AndreyMlashkin Jul 8, 2022
f072b36
disable macos arm builds
AndreyMlashkin Jul 8, 2022
e6ca9a9
point LD to mold
AndreyMlashkin Jul 11, 2022
78fc930
Apply suggestions from code review
AndreyMlashkin Jul 14, 2022
238323e
implement review notes
AndreyMlashkin Jul 14, 2022
1d3ef7a
Update recipes/mold/all/test_package/conanfile.py
AndreyMlashkin Jul 14, 2022
5a78673
disable clang 12
AndreyMlashkin Jul 18, 2022
48574c5
add libc to package id
AndreyMlashkin Jul 20, 2022
dfbfa07
remove package ID
AndreyMlashkin Jul 20, 2022
dfef214
drop gcc 10 support
AndreyMlashkin Jul 25, 2022
984fbaa
Apply suggestions from code review
AndreyMlashkin Jul 25, 2022
60620e3
use xxhash from conan
AndreyMlashkin Jul 25, 2022
1f97773
substitute includes to the right place
AndreyMlashkin Jul 25, 2022
7ef3680
Update recipes/mold/all/conanfile.py
AndreyMlashkin Jul 26, 2022
5e0724d
Apply suggestions from code review
AndreyMlashkin Jul 26, 2022
5ae9068
Update recipes/mold/all/conanfile.py
AndreyMlashkin Jul 26, 2022
1c41a05
use compiler for package id
AndreyMlashkin Jul 26, 2022
46201cc
Update recipes/mold/all/conanfile.py
AndreyMlashkin Jul 26, 2022
3ca4b41
substitute conan mimaloc and tbb as system libs
AndreyMlashkin Jul 26, 2022
2db000b
prohibit debug builds
AndreyMlashkin Jul 26, 2022
5455ee4
Apply suggestions from code review
AndreyMlashkin Jul 27, 2022
4f53c66
vorbid libstdc for mold
AndreyMlashkin Jul 27, 2022
3b25133
add check for compiler to exclude apple-clang
AndreyMlashkin Jul 28, 2022
f21c134
use std=c++2a for apple clang
AndreyMlashkin Jul 28, 2022
205d8f7
increase minimal apple-clang requirement
AndreyMlashkin Jul 28, 2022
a58ab67
Update recipes/mold/all/conanfile.py
AndreyMlashkin Jul 29, 2022
bc81c34
remove zlib
AndreyMlashkin Jul 29, 2022
a3151cc
Update recipes/mold/all/conanfile.py
AndreyMlashkin Jul 29, 2022
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/mold/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.3.1":
url: "https://github.com/rui314/mold/archive/refs/tags/v1.3.1.tar.gz"
sha256: "d436e2d4c1619a97aca0e28f26c4e79c0242d10ce24e829c1b43cfbdd196fd77"
99 changes: 99 additions & 0 deletions recipes/mold/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.45.0"

class MoldConan(ConanFile):
name = "mold"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/rui314/mold/"
license = "AGPL-3.0"
description = ("mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker")
topics = ("mold", "ld", "linkage", "compilation")

settings = "os", "arch", "compiler", "build_type"

generators = "make"

def validate(self):
if self.settings.build_type == "Debug":
raise ConanInvalidConfiguration('Mold is a build tool, specify mold:build_type=Release in your build profile, see https://github.com/conan-io/conan-center-index/pull/11536#issuecomment-1195607330')
if self.settings.compiler in ["gcc", "clang", "intel-cc"] and self.settings.compiler.libcxx != "libstdc++11":
raise ConanInvalidConfiguration('Mold can only be built with libstdc++11; specify mold:compiler.libcxx=libstdc++11 in your build profile')
if self.settings.os == "Windows":
raise ConanInvalidConfiguration(f'{self.name} can not be built on {self.settings.os}.')
if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "11":
raise ConanInvalidConfiguration("GCC version 11 or higher required")
if (self.settings.compiler == "clang" or self.settings.compiler == "apple-clang") and tools.Version(self.settings.compiler.version) < "12":
raise ConanInvalidConfiguration("Clang version 12 or higher required")
if self.settings.compiler == "apple-clang" and "armv8" == self.settings.arch :
raise ConanInvalidConfiguration(f'{self.name} is still not supported by Mac M1.')

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def _get_include_path(self, dependency):
include_path = self.deps_cpp_info[dependency].rootpath
include_path = os.path.join(include_path, "include")
return include_path

def _patch_sources(self):
if self.settings.compiler == "apple-clang":
tools.replace_in_file("source_subfolder/Makefile", "-std=c++20", "-std=c++2a")

tools.replace_in_file("source_subfolder/Makefile", "-Ithird-party/xxhash ", "-I{} -I{} -I{} -I{} -I{}".format(
self._get_include_path("zlib"),
self._get_include_path("openssl"),
self._get_include_path("xxhash"),
self._get_include_path("mimalloc"),
self._get_include_path("onetbb")
))

tools.replace_in_file("source_subfolder/Makefile", "MOLD_LDFLAGS += -ltbb", "MOLD_LDFLAGS += -L{} -ltbb".format(
self.deps_cpp_info["onetbb"].lib_paths[0]))

tools.replace_in_file("source_subfolder/Makefile", "MOLD_LDFLAGS += -lmimalloc", "MOLD_LDFLAGS += -L{} -lmimalloc".format(
self.deps_cpp_info["mimalloc"].lib_paths[0]))

def requirements(self):
self.requires("zlib/1.2.12")
self.requires("openssl/1.1.1q")
self.requires("xxhash/0.8.1")
self.requires("onetbb/2021.3.0")
self.requires("mimalloc/2.0.6")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def build(self):
self._patch_sources()
with tools.chdir(self._source_subfolder):
autotools = AutoToolsBuildEnvironment(self)
autotools.make(target="mold", args=['SYSTEM_TBB=1', 'SYSTEM_MIMALLOC=1'])

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
self.copy("mold", src=self._source_subfolder, dst="bin", keep_path=False)

def package_id(self):
del self.info.settings.compiler

def package_info(self):
bindir = os.path.join(self.package_folder, "bin")
mold_location = os.path.join(bindir, "bindir")

self.output.info('Appending PATH environment variable: {}'.format(bindir))
self.env_info.PATH.append(bindir)
self.env_info.LD = mold_location
self.buildenv_info.prepend_path("MOLD_ROOT", bindir)
self.cpp_info.includedirs = []

if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["m", "pthread", "dl"])
10 changes: 10 additions & 0 deletions recipes/mold/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
from conans import ConanFile, tools
from conan.tools.build import cross_building

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

def test(self):
if not cross_building(self):
self.run("mold -v", run_environment=True)
3 changes: 3 additions & 0 deletions recipes/mold/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.3.1":
folder: all