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

Add mold 142 as build system changed from makefiles to cmake #12881

Merged
merged 31 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ea1a264
add version 1.4.2
AndreyMlashkin Sep 9, 2022
2022a3c
add with_mimalloc option
AndreyMlashkin Sep 9, 2022
0bd7e4a
add validate method
AndreyMlashkin Sep 9, 2022
b9e46d7
add cmake as build requrements
AndreyMlashkin Sep 9, 2022
3841edd
use minmalloc from conan
AndreyMlashkin Sep 14, 2022
8aeaf52
use minmalloc from conan
AndreyMlashkin Sep 14, 2022
b4925e7
use tbb from conan
AndreyMlashkin Sep 14, 2022
c564934
don't use cmake as requirement for old mold
AndreyMlashkin Sep 14, 2022
473570d
hotfix
AndreyMlashkin Sep 14, 2022
805e477
add cmake_find_package generator
AndreyMlashkin Sep 14, 2022
e36a0ed
add CMakeDeps
AndreyMlashkin Sep 15, 2022
836a8f6
don't use old conans import
AndreyMlashkin Sep 15, 2022
c47338d
Update recipes/mold/1.4.x/conanfile.py
AndreyMlashkin Sep 19, 2022
6e7d6c8
package licenses
AndreyMlashkin Sep 19, 2022
05e095b
make artifacts match settings
AndreyMlashkin Sep 19, 2022
a4df1d6
correct package method for mold 1.3.1
AndreyMlashkin Sep 19, 2022
87684e3
package mold binary differently for gcc and clang
AndreyMlashkin Sep 19, 2022
3df5b3c
exclude windows builds
AndreyMlashkin Sep 19, 2022
8317db8
delete unneeded CMakeLists
AndreyMlashkin Sep 19, 2022
56c555f
Apply suggestions from code review
AndreyMlashkin Sep 20, 2022
ab58739
import VirtualBuildEnv
AndreyMlashkin Sep 21, 2022
b64d3b3
add a newline
AndreyMlashkin Sep 21, 2022
1e407af
Apply suggestions from code review
AndreyMlashkin Sep 22, 2022
0254b6e
delete package id also for 1.3.1 version
AndreyMlashkin Sep 29, 2022
fcc5aae
use build_requirements instead of requirements in test
AndreyMlashkin Sep 29, 2022
5271367
Apply suggestions from code review
AndreyMlashkin Oct 2, 2022
0b18808
Update recipes/mold/1.4.x/test_package/conanfile.py
AndreyMlashkin Oct 3, 2022
65e95ba
make mold test recipe work again
AndreyMlashkin Oct 3, 2022
e569462
add version 1.5.1
AndreyMlashkin Oct 3, 2022
ca1a600
rename folder
AndreyMlashkin Oct 4, 2022
5b3cb57
add test_v1_package
AndreyMlashkin Oct 5, 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
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from conan import ConanFile
from conan.tools.scm import Version
from conan.tools import files
from conan.tools.files import copy
from conan.errors import ConanInvalidConfiguration
from conans import AutoToolsBuildEnvironment
import os
Expand Down Expand Up @@ -82,8 +83,9 @@ def build(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)
copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "mold", src="bin", dst=os.path.join(self.package_folder, "bin"), keep_path=False)
copy(self, "mold", src=self._source_subfolder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)

def package_id(self):
del self.info.settings.compiler
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove this from package_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I've got an error in the CI:

[HOOK - conan-center.py] post_package(): ERROR: [MATCHING CONFIGURATION (KB-H014)] Packaged artifacts does not match the settings used: os=Linux, compiler=gcc (https://github.com/conan-io/conan-center-index/blob/master/docs/error_knowledge_base.md#KB-H014) 

Check build 16

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep this. Otherwise using these packages as tool_requirements becomes annoying
https://github.com/conan-io/conan-center-index/blob/master/docs/packaging_policy.md#settings

Copy link
Member

Choose a reason for hiding this comment

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

Revert. We need to find a fix for it. Compiler should not be part of the package ID. It's documented here: https://github.com/conan-io/conan-center-index/blob/master/docs/packaging_policy.md#settings

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.build import cross_building

class TestPackageConan(ConanFile):
Expand Down
4 changes: 4 additions & 0 deletions recipes/mold/1.4.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.4.2":
url: "https://github.com/rui314/mold/archive/refs/tags/v1.4.2.tar.gz"
sha256: "47e6c48d20f49e5b47dfb8197dd9ffcb11a8833d614f7a03bd29741c658a69cd"
99 changes: 99 additions & 0 deletions recipes/mold/1.4.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import copy, get, rmdir
from conan.errors import ConanInvalidConfiguration
from conan.tools.scm import Version
from conan.tools.env import VirtualBuildEnv

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"
options = {
"with_mimalloc": [True, False],
}
default_options = {
"with_mimalloc": False,
}

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 Version(self.settings.compiler.version) < "10":
raise ConanInvalidConfiguration("GCC version 10 or higher required")
if self.settings.compiler in ('clang', 'apple-clang') and 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.')

def layout(self):
cmake_layout(self, src_folder="src")

AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
def package_id(self):
del self.info.settings.compiler

def build_requirements(self):
self.tool_requires("cmake/3.24.1")

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")
if self.options.with_mimalloc:
self.requires("mimalloc/2.0.6")

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

def generate(self):
tc = CMakeToolchain(self)
tc.variables["MOLD_USE_MIMALLOC"] = self.options.with_mimalloc
Copy link
Contributor

Choose a reason for hiding this comment

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

tc.variables["MOLD_USE_SYSTEM_MIMALLOC"] = True
tc.variables["MOLD_USE_SYSTEM_TBB"] = True
tc.generate()

cd = CMakeDeps(self)
cd.generate()
tc = VirtualBuildEnv(self)
tc.generate()

AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
def build(self):
AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
cmake = CMake(self)
Copy link
Contributor

@ericriff ericriff Sep 29, 2022

Choose a reason for hiding this comment

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

We should replace this double instantiation of the cmake object (the one here and the one on package() ) with a single instance, cached with lru_cache. See

for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should replace this double instantiation of the cmake object (the one here and the one on package() ) with a single instance, cached with lru_cache. See

for reference.

I don't think so. All recipes updated recently declate CMake object in build and package.
You shouldn't confuse it with the old CMake generator, which would call configure twice in such case.

cmake.configure()
cmake.build()

def package(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd include a package_id method and delete the compiler info. After all this is a tool, we don't care about the compiler used to build it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above: I am getting this error, while removing it

[HOOK - conan-center.py] post_package(): ERROR: [MATCHING CONFIGURATION (KB-H014)] Packaged artifacts does not match the settings used: os=Linux, compiler=gcc (https://github.com/conan-io/conan-center-index/blob/master/docs/error_knowledge_base.md#KB-H014) 

cmake = CMake(self)
cmake.install()
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))

rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have no clue what the right way to expose this 😱

self.cpp_info.includedirs = []
AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.libdirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.resdirs = []

if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["m", "pthread", "dl"])
17 changes: 17 additions & 0 deletions recipes/mold/1.4.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
from conan import ConanFile
from conan.tools.build import can_run


class MoldTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "VirtualRunEnv"
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing build?

test_type = "explicit"

def build_requirements(self):
self.tool_requires(self.tested_reference_str)

def test(self):
if can_run(self):
self.run("mold -v", env="conanrun")

4 changes: 3 additions & 1 deletion recipes/mold/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"1.3.1":
folder: all
folder: 1.3.1
"1.4.2":
Copy link
Contributor

Choose a reason for hiding this comment

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

This got outdated since you included version 1.5. Would it make sense to rename the folder to all? So we have an all folder for current recipes and a legacy 1.3.1 folder. It looks like mold changes minor versions often since 1.4 is relatively new.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense

folder: 1.4.x