Remove the un-necessary libc option

This commit is contained in:
Sameer Rahmani 2023-04-16 17:33:41 +01:00
parent 68701215bb
commit 5febe50655
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
9 changed files with 66 additions and 140 deletions

18
builder
View File

@ -47,6 +47,7 @@ KERNEL_VERSION="5.0"
MUSL_VERSION="1.2.3"
TARGET=x86_64-pc-linux-musl
BUILD_TARGET=x86_64-build-linux-musl
export LLVM_VERSION \
CMAKE_VERSION \
@ -56,7 +57,8 @@ export LLVM_VERSION \
KERNEL_VERSION \
LLVM_MAJOR_VERSION \
MUSL_VERSION \
TARGET
TARGET \
BUILD_TARGET
ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
@ -66,7 +68,7 @@ source "$ME/scripts/utils.sh"
user="serene"
channel="stable"
function _conan() {
function _conan() { ## A conan wrapper
PYTHONPATH="$ME:$PYTHONPATH" conan "$@"
}
@ -84,6 +86,18 @@ function _build() {
}
function graph() { ## Generate the dependency graph
_push "packages/$1/"
_conan graph info \
--user "$user" --channel "$channel" -v \
--profile:host="../../profiles/stage$2" \
--profile:build="../../profiles/stage$2" \
conanfile.py \
"${@:3}"
_pop
}
function llvm-source() { ## Build the llvm source pkg
_push "packages/sources/llvm/"
_conan create --user "$user" --channel "$channel" \

View File

@ -80,9 +80,18 @@ def with_static_flags(cmake_vars):
return cmake_vars
def with_musl_toolchain(conanfile, tc):
if conanfile.options.libc == "musl":
target = os.environ["TARGET"]
def with_musl_toolchain(conanfile, tc, envname="TARGET"):
target = os.environ[envname]
tc.variables["CMAKE_C_COMPILER_TARGET"] = target
tc.variables["CMAKE_CXX_COMPILER_TARGET"] = target
tc.variables["CMAKE_C_COMPILER_TARGET"] = target
tc.variables["CMAKE_CXX_COMPILER_TARGET"] = target
def copy_template(conanfile, src, dest, varmap):
result = Path(src).read_text()
target_file = Path(dest)
for k, v in varmap.items():
result = result.replace(f"@{k}@", str(v))
target_file.write_text(result)

View File

@ -96,17 +96,25 @@ CMAKE_OPTIONS = {
class ClangBootstrap(ConanFile):
name = "clang-bootstrap"
settings = "os", "arch", "compiler", "build_type"
settings = "os", "arch", "build_type"
version = get_version("llvm")
gnu_triple = "x86_64-build-linux-gnu"
musl_triple = "x86_64-build-linux-musl"
musl_triple = os.environ["TARGET"]
def build_requirements(self):
self.requires(f"llvm-source/{self.version}@{self.user}/{self.channel}")
self.requires(f"zlib/{get_version('zlib')}@{self.user}/{self.channel}")
self.requires(f"zstd/{get_version('zstd')}@{self.user}/{self.channel}")
self.requires(
f"zlib-bootstrap/{get_version('zlib')}@{self.user}/{self.channel}",
visible=False,
transitive_libs=False,
)
self.requires(
f"zstd-bootstrap/{get_version('zstd')}@{self.user}/{self.channel}",
visible=False,
transitive_libs=False,
)
self.tool_requires(f"cmake/{get_version('cmake')}@{self.user}/{self.channel}")
self.tool_requires(f"ninja/{get_version('ninja')}@{self.user}/{self.channel}")
@ -136,7 +144,7 @@ class ClangBootstrap(ConanFile):
# opts["LLVM_RUNTIME_DISTRIBUTION_COMPONENTS"] = "cxx-headers"
zlibdir = self.dependencies["zlib"]
zlibdir = self.dependencies["zlib-bootstrap"]
zlib_include = zlibdir.cpp_info.includedir
zlib_lib = zlibdir.cpp_info.libdir
opts["CMAKE_REQUIRED_INCLUDES"] = zlib_include
@ -256,6 +264,8 @@ class ClangBootstrap(ConanFile):
"PATH",
str(bindir),
)
self.buildenv_info.define("CLANG_BOOTSTRAP_PATH", self.package_folder)
self.buildenv_info.define("LIBCC_GNU", str(clang_lib_dir / self.gnu_triple))
self.buildenv_info.define("LIBCC_MUSL", str(clang_lib_dir / self.musl_triple))
self.buildenv_info.define("CC", str(bindir / "clang"))

View File

@ -25,7 +25,7 @@ from conf.utils import with_static_flags, get_version
class Cmake(ConanFile):
name = "cmake"
version = get_version("cmake")
settings = "os", "arch", "build_type", "compiler"
settings = "os", "arch", "build_type"
def source(self):
get(

View File

@ -24,7 +24,7 @@ from conf.utils import with_static_flags, get_version
class Ninja(ConanFile):
name = "ninja"
settings = "os", "arch", "build_type", "compiler"
settings = "os", "arch", "build_type"
version = get_version("ninja")
def requirements(self):

View File

@ -15,90 +15,28 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get, copy
from conan.tools.cmake import CMakeToolchain, CMakeDeps
from conf.base.zlib import ZlibBase
from conf.utils import get_version, with_musl_toolchain
class Zlib(ConanFile):
class Zlib(ZlibBase):
name = "zlib"
version = get_version("zlib")
settings = "os", "arch", "build_type", "compiler"
exports = "*.cmake"
cmake_setup_file = "zlib_setup.cmake"
options = {
"libc": ["gnu", "musl"],
}
default_options = {"libc": "gnu"}
def build_requirements(self):
self.tool_requires(f"cmake/{get_version('cmake')}@{self.user}/{self.channel}")
self.tool_requires(f"ninja/{get_version('ninja')}@{self.user}/{self.channel}")
if self.options.libc == "musl":
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
self.requires(f"musl/{get_version('musl')}@{self.user}/{self.channel}")
def source(self):
get(
self,
f"https://github.com/madler/zlib/archive/v{self.version}.tar.gz",
super().build_requirements()
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
self.requires(f"musl/{get_version('musl')}@{self.user}/{self.channel}")
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = False
with_musl_toolchain(self, tc)
with_musl_toolchain(self, tc, "BUILD_TARGET")
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure(
{
"BUILD_SHARED_LIBS": False,
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
},
build_script_folder=f"zlib-{self.version}",
)
self.run("ninja zlibstatic")
def package(self):
copy(self, "*.a", self.build_folder, os.path.join(self.package_folder, "lib"))
copy(self, self.cmake_setup_file, self.recipe_folder, self.package_folder)
copy(
self,
"zconf.h",
self.build_folder,
os.path.join(self.package_folder, "include"),
)
copy(
self,
"zlib.h",
os.path.join(self.build_folder, f"zlib-{self.version}"),
os.path.join(self.package_folder, "include"),
)
copy(
self,
"zlib.pc",
self.build_folder,
os.path.join(self.package_folder, "share", "pkgconfig"),
)
def package_info(self):
self.cpp_info.set_property("cmake_build_modules", [self.cmake_setup_file])
self.cpp_info.set_property("cmake_find_mode", "module")
self.cpp_info.set_property("cmake_file_name", "ZLIB")
self.cpp_info.set_property("cmake_target_name", "ZLIB::ZLIB")
self.cpp_info.set_property("pkg_config_name", "zlib")
self.cpp_info.libs = ["z"]
self.cpp_info.set_property("cmake_find_package", "ZLIB")
self.cpp_info.set_property("cmake_find_package_multi", "ZLIB")

View File

@ -19,61 +19,26 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get, copy
from conf.base.zstd import ZstdBase
from conf.utils import get_version, with_musl_toolchain
class Zstd(ConanFile):
class Zstd(ZstdBase):
name = "zstd"
version = get_version("zstd")
settings = "os", "arch", "build_type", "compiler"
exports = "*.cmake"
options = {
"libc": ["gnu", "musl"],
}
default_options = {"libc": "gnu"}
def build_requirements(self):
self.tool_requires(f"cmake/{get_version('cmake')}@{self.user}/{self.channel}")
self.tool_requires(f"ninja/{get_version('ninja')}@{self.user}/{self.channel}")
def source(self):
get(
self,
f"https://github.com/facebook/zstd/archive/v{self.version}.tar.gz",
super().build_requirements()
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
self.requires(f"musl/{get_version('musl')}@{self.user}/{self.channel}")
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = False
with_musl_toolchain(self, tc)
with_musl_toolchain(self, tc, "BUILD_TARGET")
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure(
{
"CMAKE_C_COMPILER": self.settings.compiler,
"CMAKE_CXX_COMPILER": self.settings.compiler,
"BUILD_SHARED_LIBS": False,
"ZSTD_BUILD_STATIC": True,
"ZSTD_BUILD_SHARED": False,
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
},
build_script_folder=f"zstd-{self.version}/build/cmake/",
)
cmake.build()
cmake.install()
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "module")
self.cpp_info.set_property("cmake_file_name", "zstd::libzstd_static")
self.cpp_info.set_property("cmake_target_name", "zstd::libzstd_static")
self.cpp_info.set_property("pkg_config_name", "zstd")
self.cpp_info.libs = ["zstd"]
self.cpp_info.set_property("cmake_find_package", "zstd::libzstd_static")
self.cpp_info.set_property("cmake_find_package_multi", "zstd::libzstd_static")

View File

@ -9,9 +9,6 @@ compiler=gcc
compiler.version=12.2
compiler.libcxx=libstdc++
[options]
*/*:libc = gnu
[buildenv]
LD=lld

View File

@ -13,13 +13,6 @@ clang-bootstrap/*:compiler=gcc
clang-bootstrap/*:compiler.version=12.2
clang-bootstrap/*:compiler.libcxx=libstdc++
[options]
zlib/*:libc = musl
# [tool_requires]
# musl/*:clang-bootstrap/{{ LLVM_VERSION }}@serene/stable
# zlib/*:clang-bootstrap/{{ LLVM_VERSION }}@serene/stable
[buildenv]
CC=clang
CXX=clang++