Compare commits

...

15 Commits

34 changed files with 1522 additions and 108 deletions

8
.gitignore vendored
View File

@ -11,4 +11,10 @@ tf/terraform.tfstate*
build
.vagrant
.prod
#.#
#.#
.tmp/
packages/stage1-sysroot/sysroot/
packages/stage2-sysroot/sysroot/
packages/stage3-sysroot/sysroot/
*.zstd

119
builder
View File

@ -45,6 +45,7 @@ ZLIB_VERSION="1.2.13"
ZSTD_VERSION="1.5.4"
KERNEL_VERSION="6.0"
MUSL_VERSION="1.2.3"
IWYU_VERSION="14e9b208914a84fcdf49bf9f5d08897a4b3dc4b8"
TARGET=x86_64-pc-linux-musl
@ -56,7 +57,8 @@ export LLVM_VERSION \
KERNEL_VERSION \
LLVM_MAJOR_VERSION \
MUSL_VERSION \
TARGET
TARGET \
IWYU_VERSION
ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
@ -72,9 +74,9 @@ function _conan() { ## A conan wrapper
function _create() {
_conan create --user "$user" --channel "$channel" \
--profile:host="../../profiles/stage$1" \
--profile:build="../../profiles/stage$1" \
. "${@:2}"
--profile:host="$ME/profiles/stage$1" \
--profile:build="$ME/profiles/stage$1" \
"${@:2}" .
}
function _build() {
@ -84,6 +86,16 @@ function _build() {
}
function _deploy() {
mkdir -p "$ME/.tmp/$2/"
_conan install --deploy "$ME/conf/${4:-tarball_deployer.py}" \
--requires "$1/$2@$user/$channel" \
--profile:host="$ME/profiles/stage$3" \
--profile:build="$ME/profiles/stage$3" \
-of "$ME/.tmp/$3/" \
}
function graph() { ## Generate the dependency graph
_push "packages/$1/"
_conan graph info \
@ -105,32 +117,99 @@ function llvm-source() { ## Build the llvm source pkg
_pop
}
function cmake() { ## Build the cmake package
_push "packages/cmake/"
_create "$@"
_pop
# A glibc clang with a sysroot containing musl, libc++
function build-stage1() { ## Build the stage1 compiler and sysroot
llvm-source 0
_build cmake 0
_build ninja 0
_build zlib-bootstrap 0
_build zstd-bootstrap 0
_build clang-bootstrap 0
_build kernel-headers 1
_build musl 1
_build zlib 1
_build zstd 1
_build libcxx 1
_build stage1-bundle 1
# All this is because conan does not support removing dependencies yet
# So we ended up hacking our way through to create some
# packages that do now have any dependency
rm -rf "$ME/.tmp"
rm -rf "$ME/packages/stage1-sysroot/sysroot/"
_deploy "stage1-bundle" "$LLVM_VERSION" 1
mkdir -p "$ME/packages/stage1-sysroot/sysroot/"
cp -rv "$ME/.tmp/1/stage1-bundle/$LLVM_VERSION/" "$ME/packages/stage1-sysroot/sysroot/"
_build stage1-sysroot 1
rm -rf "$ME/packages/stage1-sysroot/sysroot/" "$ME/.tmp"
}
function gcc() { ## Build the gcc package
_push "packages/gcc/"
_create "$@"
_pop
# A musl clang with the sysroot
function build-stage2() { ## Build the stage2 compiler and sysroot
#llvm-source 1
_build cmake 1
_build ninja 1
_build clang 1
_build musl 2
_build zlib 2
_build zstd 2
_build stage2-bundle 2
# All this is because conan does not support removing dependencies yet
# So we ended up hacking our way through to create some
# packages that do now have any dependency
rm -rf "$ME/.tmp"
rm -rf "$ME/packages/stage2-sysroot/sysroot/"
_deploy "stage2-bundle" "$LLVM_VERSION" 2
mkdir -p "$ME/packages/stage2-sysroot/sysroot/"
cp -rv "$ME/.tmp/2/stage2-bundle/$LLVM_VERSION/" "$ME/packages/stage2-sysroot/sysroot/"
_build stage2-sysroot 2
rm -rf "$ME/packages/stage2-sysroot/sysroot/" "$ME/.tmp"
}
function ninja() { ## Build the gcc package
_build ninja "$@"
# final toolchain
function build-stage3() { ## Build the stage3 compiler and sysroot
_build toolchain 2
_build boehmgc 2
_build stage3-bundle 2
# All this is because conan does not support removing dependencies yet
# So we ended up hacking our way through to create some
# packages that do now have any dependency
rm -rf "$ME/.tmp"
rm -rf "$ME/packages/stage3-sysroot/sysroot/"
_deploy "stage3-bundle" "$LLVM_VERSION" 2
mkdir -p "$ME/packages/stage3-sysroot/sysroot/"
cp -rv "$ME/.tmp/2/stage3-bundle/$LLVM_VERSION/" "$ME/packages/stage3-sysroot/sysroot/"
_build stage3-sysroot 2
rm -rf "$ME/packages/stage3-sysroot/sysroot/" "$ME/.tmp"
}
function zlib() { ## Build the zlib package
_build zlib "$@"
function compress_tarball() {
local ZSTD_CLI
ZSTD_CLI="zstd --ultra -22 -T$(nproc)"
tar -I "$ZSTD_CLI" -cf "serene_toolchain.$LLVM_MAJOR_VERSION.tar.zstd" \
-C "$ME/.tmp/2/stage3-sysroot/" .
}
function zstd() { ## Build the zstd package
_build zstd "$@"
function build-tarball() { ## Create the toolchain tarball
_deploy "stage3-sysroot" "$LLVM_VERSION" 2 "toolchain_deployer.py"
echo "Creating the tarball..."
compress_tarball
}
function clang-bootstrap() { ## Build the gcc package
_build clang-bootstrap "$@"
function build-toolchain() { ## Build the entire thing
build-stage1
build-stage2
build-stage3
build-tarball
}
function help() { ## Print out this help message

View File

@ -25,13 +25,10 @@ from conf.utils import get_version, with_musl_toolchain
class ZlibBase(ConanFile):
version = get_version("zlib")
settings = "os", "arch", "build_type", "compiler"
exports = "*.cmake"
cmake_setup_file = "zlib_setup.cmake"
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,
@ -41,7 +38,7 @@ class ZlibBase(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = False
# with_musl_toolchain(self, tc)
with_musl_toolchain(self, tc)
tc.generate()
deps = CMakeDeps(self)
deps.generate()

View File

@ -27,10 +27,6 @@ class ZstdBase(ConanFile):
settings = "os", "arch", "build_type", "compiler"
exports = "*.cmake"
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,

36
conf/tarball_deployer.py Normal file
View File

@ -0,0 +1,36 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
from conan.tools.files import copy
from conf.utils import copy_tree
def deploy(graph, output_folder, **kwargs):
# Note the kwargs argument is mandatory to be robust against future changes.
for name, dep in graph.root.conanfile.dependencies.items():
if dep.folders is None:
raise RuntimeError(
f"Sources missing for {name} dependency.\n"
"This deployer needs the sources of every dependency present to work, either building from source, "
"or by using the 'tools.build:download_source' conf."
)
output = Path(output_folder) / str(dep.ref).split("@")[0]
print(f"Copying {dep.package_folder} to {output}")
copy_tree(dep.package_folder, output)

View File

@ -0,0 +1,39 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
from conan.tools.files import copy
from conf.utils import copy_tree
# Only deploy the `toolchain` package
def deploy(graph, output_folder, **kwargs):
for name, dep in graph.root.conanfile.dependencies.items():
if dep.folders is None:
raise RuntimeError(
f"Sources missing for {name} dependency.\n"
"This deployer needs the sources of every dependency present to work, either building from source, "
"or by using the 'tools.build:download_source' conf."
)
name = str(dep.ref).split("@")[0].split("/")[0]
if name == "stage3-sysroot":
output = Path(output_folder) / name
print(f"Copying {dep.package_folder} to {output}")
copy_tree(dep.package_folder, output)
else:
print(f"Ignoring the '{name}' package")

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import contextlib
import shutil
from pathlib import Path
@ -71,7 +73,7 @@ def copy_tree(src, dst, preserve_symlinks=True, ignore=None):
shutil.copy2(item, dst / item.name, follow_symlinks=not preserve_symlinks)
def with_static_flags(cmake_vars):
def with_static_flags(cmake_vars={}):
cmake_vars["CMAKE_C_FLAGS"] = f"-static {cmake_vars.get('CMAKE_C_FLAGS', '')}"
cmake_vars["CMAKE_CXX_FLAGS"] = f"-static {cmake_vars.get('CMAKE_CXX_FLAGS', '')}"
cmake_vars[
@ -80,11 +82,36 @@ def with_static_flags(cmake_vars):
return cmake_vars
def with_musl_toolchain(conanfile, tc, envname="TARGET"):
def with_musl_toolchain(conanfile, tc, sysroot=None, envname="TARGET"):
target = os.environ[envname]
tc.variables["CMAKE_C_COMPILER_TARGET"] = target
tc.variables["CMAKE_CXX_COMPILER_TARGET"] = target
opts = {
"CMAKE_SYSTEM_NAME": "Linux",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_ASM_COMPILER": "clang",
"CMAKE_C_COMPILER_TARGET": target,
# "CMAKE_C_FLAGS": f"--target={target}",
"CMAKE_CXX_COMPILER_TARGET": target,
# "CMAKE_CXX_FLAGS": f"--target={target}",
"CMAKE_ASM_COMPILER_TARGET": target,
# "CMAKE_ASM_FLAGS": f"--target={target}",
}
if sysroot:
opts.update(
{
"CMAKE_SYSROOT": sysroot,
"CMAKE_DEFAULT_SYSROOT": sysroot,
"CMAKE_FIND_ROOT_PATH": sysroot,
"CMAKE_FIND_ROOT_PATH_MODE_PROGRAM": "BOTH",
"CMAKE_FIND_ROOT_PATH_MODE_LIBRARY": "ONLY",
"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE": "ONLY",
"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE": "ONLY",
}
)
for k, v in opts.items():
tc.variables[k] = v
def copy_template(conanfile, src, dest, varmap):
@ -92,6 +119,7 @@ def copy_template(conanfile, src, dest, varmap):
target_file = Path(dest)
for k, v in varmap.items():
print(f">> replacing @{k}@ with {str(v)}")
result = result.replace(f"@{k}@", str(v))
target_file.write_text(result)
@ -106,10 +134,23 @@ def copy_dependency_tree(conanfile, dependencies_to_copy=[], dest=None):
conanfile.output.info(f"Copy the tree of '{dependency}' to '{root}'")
dep = Path(conanfile.dependencies[dependency].package_folder)
for dir_path in ["include", "lib", "bin"]:
for dir_path in ["include", "lib", "bin", "share"]:
try:
copy_tree(dep / dir_path, root / dir_path)
except FileNotFoundError:
conanfile.output.info(
f"Dir '{dep / dir_path}' does not exist, skipping"
)
@contextlib.contextmanager
def chpath(path: Path) -> None:
"""
Changes working directory and returns to previous on exit.
"""
prev_cwd = Path.cwd()
os.chdir(path)
try:
yield
finally:
os.chdir(prev_cwd)

View File

@ -0,0 +1,93 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
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, copy_dependency_tree
class BoehmGC(ConanFile):
name = "boehmgc"
settings = "os", "arch", "build_type", "compiler"
version = "8.2.2"
options = {
"stage": [1, 2],
}
default_options = {"stage": 2}
def source(self):
get(
self,
f"https://github.com/ivmai/bdwgc/archive/v{self.version}.tar.gz",
)
def build_requirements(self):
self.requires(f"toolchain/{get_version('llvm')}@{self.user}/{self.channel}")
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, "TARGET")
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def create_sysroot(self):
sysroot = Path(self.build_folder) / "sysroot"
sysroot.mkdir()
copy_dependency_tree(self, ["toolchain", "musl"], sysroot)
def build(self):
self.create_sysroot()
sysroot = f"{self.build_folder}/sysroot"
cmake = CMake(self)
cmake.configure(
{
"CMAKE_INSTALL_PREFIX": self.package_folder,
"build_cord": "ON",
"enable_atomic_uncollectable": "ON",
"enable_cplusplus": "OFF",
"enable_disclaim": "ON",
"enable_docs": "ON",
"enable_dynamic_loading": "ON",
"enable_gc_assertions": "ON",
"enable_handle_fork": "ON",
"enable_java_finalization": "OFF",
"enable_munmap": "ON",
"enable_parallel_mark": "ON",
"enable_thread_local_alloc": "ON",
"enable_threads": "ON",
"enable_threads_discovery": "ON",
"enable_throw_bad_alloc_library": "ON",
"install_headers": "ON",
"BUILD_SHARED_LIBS": "OFF",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"CMAKE_SYSROOT": sysroot,
},
build_script_folder=f"bdwgc-{self.version}/",
)
cmake.build()
cmake.install()

View File

@ -39,7 +39,10 @@ TOOLCHAIN_TARGETS = [
"lld",
"llvm-addr2line",
"llvm-ar",
"llvm-tblgen",
"llvm-config",
"llvm-as",
"clang-tblgen",
"llvm-cov",
"llvm-cvtres",
"llvm-cxxmap",
@ -63,6 +66,7 @@ TOOLCHAIN_TARGETS = [
"llvm-windres",
"LTO",
"builtins",
"llvm-libraries",
# lldb,
"compiler-rt",
"runtimes",
@ -100,7 +104,7 @@ CMAKE_OPTIONS = {
"LIBCXXABI_ENABLE_SHARED": "OFF",
"LIBCXX_ABI_VERSION": "2",
"LLVM_CCACHE_BUILD": "ON",
"LLVM_ENABLE_LTO": "THIN",
# "LLVM_ENABLE_LTO": "OFF",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"CLANG_DEFAULT_CXX_STDLIB": "libc++",
"CLANG_DEFAULT_LINKER": "lld",
@ -109,7 +113,7 @@ CMAKE_OPTIONS = {
"CLANG_VENDOR_UTI": "serene.stage0",
"LLVM_ENABLE_LIBCXX": "ON",
"LLVM_ENABLE_ZSTD": "OFF",
"LLVM_OPTIMIZED_TABLEGEN": "ON",
"LLVM_OPTIMIZED_TABLEGEN": "OFF",
"LLVM_THINLTO_CACHE_PATH": "/tmp/llvm-build-lto",
"LLVM_ENABLE_PROJECTS": ";".join(PROJECTS),
"LLVM_CCACHE_BUILD": "ON",
@ -121,16 +125,13 @@ CMAKE_OPTIONS = {
class LLVM(ConanFile):
name = "llvm"
settings = "os", "arch", "compiler", "build_type"
name = "clang"
settings = "os", "arch", "build_type"
version = get_version("llvm")
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"musl/{get_version('musl')}@{self.user}/{self.channel}")
# self.requires(f"zstd/{get_version('zstd')}@{self.user}/{self.channel}")
self.requires(
f"stage1-sysroot/{get_version('llvm')}@{self.user}/{self.channel}"
)
@ -149,7 +150,7 @@ class LLVM(ConanFile):
tc_dir = Path(self.dependencies["stage1-sysroot"].package_folder)
opts["CMAKE_C_COMPILER"] = str(tc_dir / "bin" / "clang")
opts["CMAKE_CXX_COMPILER"] = str(tc_dir / "bin" / "clang++")
opts["LLVM_CONFIG_PATH"] = str(tc_dir / "bin" / "llvm-config")
# opts["LLVM_CONFIG_PATH"] = str(tc_dir / "bin" / "llvm-config")
target = os.environ["TARGET"]
@ -210,7 +211,7 @@ class LLVM(ConanFile):
"CMAKE_VERBOSE_MAKEFILE": "ON",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"LLVM_USE_LINKER": "lld",
"LLVM_USE_LTO": "ON",
"LLVM_USE_LTO": "OFF",
"LLVM_CCACHE_BUILD": opts["LLVM_CCACHE_BUILD"],
# TODO: Check for more sanitizers that work with musl
"COMPILER_RT_SANITIZERS_TO_BUILD": "asan;msan;tsan",
@ -311,7 +312,7 @@ class LLVM(ConanFile):
cm.build(target="builtins")
cm.build(target="compiler-rt")
cm.build(target="install-distribution-stripped")
cm.build(target="install-distribution")
def package_info(self):
bindir = Path(os.path.join(self.package_folder, "bin"))
@ -331,3 +332,9 @@ class LLVM(ConanFile):
self.buildenv_info.define("AR", str(bindir / "llvm-ar"))
self.buildenv_info.define("NM", str(bindir / "llvm-nm"))
self.buildenv_info.define("RANLIB", str(bindir / "llvm-ranlib"))
self.buildenv_info.append("sysroot", self.package_folder)
f = os.path.join(self.package_folder, "toolchain.cmake")
self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", f)
self.conf_info.define("tools.build:sysroot", self.package_folder)
self.buildenv_info.define_path("SYSROOT", self.package_folder)

View File

@ -0,0 +1,33 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -19,7 +19,7 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get
from conf.utils import with_static_flags, get_version
from conf.utils import with_static_flags, get_version, with_musl_toolchain
class Cmake(ConanFile):
@ -27,6 +27,11 @@ class Cmake(ConanFile):
version = get_version("cmake")
settings = "os", "arch", "build_type"
options = {
"libc": ["glibc", "musl"],
}
default_options = {"libc": "glibc"}
def source(self):
get(
self,
@ -35,19 +40,25 @@ class Cmake(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
if self.options.libc == "musl":
with_musl_toolchain(self, tc)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
flags = with_static_flags(
{
"CMAKE_USE_OPENSSL": "OFF",
"BUILD_TESTING": "OFF",
}
)
cmake.configure(
with_static_flags(
{
"CMAKE_USE_OPENSSL": "OFF",
"BUILD_TESTING": "OFF",
}
),
flags,
build_script_folder=f"CMake-{self.version}",
)
cmake.build()

View File

@ -0,0 +1,37 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from conan import ConanFile
from conan.tools.scm import Git
from conan.tools.files import get
from conf.utils import *
class IWYU(ConanFile):
name = "iwyu"
version = get_version("iwyu")
settings = "os", "arch"
def build(self):
g = Git(self)
g.clone(
url="https://github.com/include-what-you-use/include-what-you-use",
target=self.package_folder,
)
with chpath(self.package_folder):
g.checkout(self.version)

View File

@ -60,7 +60,7 @@ CMAKE_OPTIONS = {
"LLVM_ENABLE_LTO": "THIN",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"LLVM_ENABLE_LIBCXX": "ON",
"LLVM_THINLTO_CACHE_PATH": "/tmp/llvm-build-lto",
"LLVM_THINLTO_CACHE_PATH": "/tmp/llvm-build-lto-libcxx",
"LLVM_ENABLE_PROJECTS": ";".join(PROJECTS),
"LIBCXX_HAS_MUSL_LIBC": "ON",
"LLVM_DEFAULT_TARGET_TRIPLE": os.environ["TARGET"],

View File

@ -27,17 +27,27 @@ from conf.utils import copy_tree, get_version
class Musl(ConanFile):
name = "musl"
settings = "os", "arch", "build_type"
settings = "os", "arch", "build_type", "compiler"
version = get_version("musl")
options = {
"stage": [1, 2],
}
default_options = {"stage": 1}
def build_requirements(self):
self.requires(
f"kernel-headers/{get_version('kernel')}@{self.user}/{self.channel}"
)
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
if self.options.stage == 1:
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
else:
self.tool_requires(
f"clang/{get_version('llvm')}@{self.user}/{self.channel}"
)
@property
def target(self):
@ -52,7 +62,10 @@ class Musl(ConanFile):
def generate(self):
tc = AutotoolsToolchain(self, prefix=f"{self.package_folder}/")
env = tc.environment()
buildenv = self.dependencies.build["clang-bootstrap"].buildenv_info.vars(self)
clang = "clang-bootstrap" if self.options.stage == 1 else "clang"
clang_root = Path(self.dependencies.build[clang].package_folder)
tc.update_configure_args(
{
@ -63,11 +76,22 @@ class Musl(ConanFile):
}
)
libcc_dir = Path(buildenv["LIBCC_GNU"])
if "musl" in self.target:
libcc_dir = Path(buildenv["LIBCC_MUSL"])
libcc = (
clang_root
/ "lib"
/ "clang"
/ get_version("llvm_major")
/ "lib"
/ self.target
/ "libclang_rt.builtins.a"
)
env.define("LIBCC", str(libcc_dir / "libclang_rt.builtins.a"))
env.define(
"LIBCC",
str(libcc),
)
env.define("CC", "clang")
env.prepend_path("PATH", str(clang_root / "bin"))
# We will strip the debug data later
tc.extra_cflags = ["-g", f"--target={self.target}"]
tc.generate(env)

View File

@ -19,7 +19,7 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get
from conf.utils import with_static_flags, get_version
from conf.utils import with_static_flags, get_version, with_musl_toolchain
class Ninja(ConanFile):
@ -27,9 +27,19 @@ class Ninja(ConanFile):
settings = "os", "arch", "build_type"
version = get_version("ninja")
options = {
"libc": ["glibc", "musl"],
}
default_options = {"libc": "glibc"}
def requirements(self):
self.tool_requires(f"cmake/{get_version('cmake')}@{self.user}/{self.channel}")
# if self.options.libc == "musl":
# self.requires(
# f"stage2-sysroot/{get_version('llvm')}@{self.user}/{self.channel}"
# )
def source(self):
get(
self,
@ -41,6 +51,9 @@ class Ninja(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
if self.options.libc == "musl":
with_musl_toolchain(self, tc)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
@ -51,8 +64,10 @@ class Ninja(ConanFile):
def build(self):
cmake = CMake(self)
flags = with_static_flags()
cmake.configure(
with_static_flags({}),
flags,
build_script_folder=f"ninja-{self.version}",
)
cmake.build()

View File

@ -17,12 +17,12 @@
from conan import ConanFile
from conan.tools.files import get
from conf.versions import *
from conf.utils import *
class LLVM(ConanFile):
name = "llvm-source"
version = LLVM_VERSION
version = get_version("llvm")
settings = "os", "arch"
def build(self):

View File

@ -0,0 +1,55 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage1(ConanFile):
name = "stage1-bundle"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(
f"clang-bootstrap/{get_version('llvm')}@{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"musl/{get_version('musl')}@{self.user}/{self.channel}")
self.requires(f"libcxx/{get_version('llvm')}@{self.user}/{self.channel}")
def build(self):
copy_dependency_tree(
self,
["clang-bootstrap", "musl", "zlib", "zstd", "libcxx"],
self.package_folder,
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)

View File

@ -0,0 +1,33 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -24,34 +24,28 @@ from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage1(ConanFile):
class Stage1Sysroot(ConanFile):
name = "stage1-sysroot"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
self.requires(
f"zlib/{get_version('zlib')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"zstd/{get_version('zstd')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"musl/{get_version('musl')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"libcxx/{get_version('llvm')}@{self.user}/{self.channel}", visible=False
)
exports = (
"*.cmake",
"sysroot/*",
)
def build(self):
copy_dependency_tree(
self,
["clang-bootstrap", "musl", "zlib", "zstd", "libcxx"],
self.package_folder,
# sysroot dir is created via the builder script
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/bin",
f"{self.package_folder}/bin",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/lib",
f"{self.package_folder}/lib",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/include",
f"{self.package_folder}/include",
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
@ -59,7 +53,7 @@ class Stage1(ConanFile):
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"]},
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)
def package_info(self):

View File

@ -0,0 +1,52 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage2(ConanFile):
name = "stage2-bundle"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(f"clang/{get_version('llvm')}@{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"musl/{get_version('musl')}@{self.user}/{self.channel}")
def build(self):
copy_dependency_tree(
self,
["clang", "musl", "zlib", "zstd"],
self.package_folder,
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)

View File

@ -0,0 +1,33 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,83 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage2Sysroot(ConanFile):
name = "stage2-sysroot"
version = get_version("llvm")
settings = "os", "arch"
exports = (
"*.cmake",
"sysroot/*",
)
def build(self):
# sysroot dir is created via the builder script
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/bin",
f"{self.package_folder}/bin",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/lib",
f"{self.package_folder}/lib",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/include",
f"{self.package_folder}/include",
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)
def package_info(self):
bindir = Path(self.package_folder) / "bin"
self.runenv_info.prepend_path(
"PATH",
str(bindir),
)
self.buildenv_info.append("sysroot", self.package_folder)
f = os.path.join(self.package_folder, "toolchain.cmake")
self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", f)
self.conf_info.define("tools.build:sysroot", self.package_folder)
self.buildenv_info.define_path("SYSROOT", self.package_folder)
self.buildenv_info.define("CC", str(bindir / "clang"))
self.buildenv_info.define("CXX", str(bindir / "clang++"))
self.buildenv_info.define("AR", str(bindir / "clang"))
self.buildenv_info.define("NM", str(bindir / "llvm-nm"))
self.buildenv_info.define("RANLIB", str(bindir / "llvm-ranlib"))
self.cpp_info.includedirs = [
f"{self.package_folder}/include/c++/v1",
f"{self.package_folder}/include/",
f"{self.package_folder}/lib/clang/{get_version('llvm_major')}/include",
]

View File

@ -0,0 +1,34 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,57 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage3(ConanFile):
name = "stage3-bundle"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
options = {
"stage": [1, 2],
}
default_options = {"stage": 2}
def build_requirements(self):
self.requires(f"toolchain/{get_version('llvm')}@{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"musl/{get_version('musl')}@{self.user}/{self.channel}")
def build(self):
copy_dependency_tree(
self,
["toolchain", "musl", "zlib", "zstd"],
self.package_folder,
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)

View File

@ -0,0 +1,34 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,88 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage3Sysroot(ConanFile):
name = "stage3-sysroot"
version = get_version("llvm")
settings = "os", "arch"
exports = (
"*.cmake",
"sysroot/*",
)
def build(self):
# sysroot dir is created via the builder script
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/bin",
f"{self.package_folder}/bin",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/lib",
f"{self.package_folder}/lib",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/include",
f"{self.package_folder}/include",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/share",
f"{self.package_folder}/share",
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)
def package_info(self):
bindir = Path(self.package_folder) / "bin"
self.runenv_info.prepend_path(
"PATH",
str(bindir),
)
self.buildenv_info.append("sysroot", self.package_folder)
f = os.path.join(self.package_folder, "toolchain.cmake")
self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", f)
self.conf_info.define("tools.build:sysroot", self.package_folder)
self.buildenv_info.define_path("SYSROOT", self.package_folder)
self.buildenv_info.define("CC", str(bindir / "clang"))
self.buildenv_info.define("CXX", str(bindir / "clang++"))
self.buildenv_info.define("AR", str(bindir / "clang"))
self.buildenv_info.define("NM", str(bindir / "llvm-nm"))
self.buildenv_info.define("RANLIB", str(bindir / "llvm-ranlib"))
self.cpp_info.includedirs = [
f"{self.package_folder}/include/c++/v1",
f"{self.package_folder}/include/",
f"{self.package_folder}/lib/clang/{get_version('llvm_major')}/include",
]

View File

@ -0,0 +1,34 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,362 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get
from conf.utils import with_static_flags, current_dir, get_version
TOOLCHAIN_TARGETS = [
"runtimes",
"clang-apply-replacements",
"clang-format",
"clang-query",
"clang-resource-headers",
"clang-tidy",
"clang-doc",
"clang",
"clangd",
"clang-extdef-mapping",
"cmake-exports",
"dsymutil",
"lld",
"llvm-addr2line",
"llvm-ar",
"llvm-tblgen",
"llvm-config",
"llvm-as",
"clang-tblgen",
"llvm-cov",
"llvm-cvtres",
"llvm-cxxmap",
"llvm-dlltool",
"llvm-dwp",
"llvm-dwarfdump",
"llvm-install-name-tool",
"llvm-lib",
"llvm-lipo",
"llvm-nm",
"llvm-objcopy",
"llvm-objdump",
"llvm-pdbutil",
"llvm-profdata",
"llvm-ranlib",
"llvm-rc",
"llvm-readelf",
"llvm-strings",
"llvm-strip",
"llvm-symbolizer",
"llvm-windres",
"LTO",
"builtins",
"llvm-libraries",
"mlir-libraries",
"mlir-tblgen",
"mlir-opt",
"mlir-lsp-server",
"mlir-reduce",
"llvm-jitlink",
"compiler-rt",
"runtimes",
]
# No lldb? Yes, lldb links against liblldb.so and since we use
# -static with our executables that wouldn't be easy to handle
# and I'm lazy. We can just compile the lldb or any other debugger
# on the host
PROJECTS = ["clang-tools-extra", "clang", "lld", "llvm", "mlir"]
RUNTIME_TARGETS = [
"compiler-rt",
"libcxx",
"libcxxabi",
"libunwind",
]
CMAKE_OPTIONS = {
"LLVM_USE_LINKER": "lld",
"LLVM_ENABLE_NEW_PASS_MANAGER": "ON",
"LLVM_BUILD_TESTS": "OFF",
"LLVM_ENABLE_ASSERTIONS": "ON",
"LLVM_ENABLE_LIBXML2": "OFF",
"LLVM_ENABLE_TERMINFO": "OFF",
"LLVM_ENABLE_ZLIB": "FORCE_ON",
"LLVM_INCLUDE_BENCHMARKS": "OFF",
"LLVM_INCLUDE_EXAMPLES": "OFF",
"LLVM_INCLUDE_TESTS": "OFF",
"LLVM_INCLUDE_GO_TESTS": "OFF",
"LLVM_ENABLE_BINDINGS": "OFF",
"LLVM_TARGETS_TO_BUILD": "X86",
"LLVM_STATIC_LINK_CXX_STDLIB": "ON",
"PACKAGE_VENDOR": "Serene",
"LLVM_ENABLE_PER_TARGET_RUNTIME_DIR": "ON",
"ENABLE_X86_RELAX_RELOCATIONS": "ON",
"BUILD_SHARED_LIBS": "OFF",
"CLANG_ENABLE_BOOTSTRAP": "ON",
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY": "ON",
"LIBCXXABI_ENABLE_SHARED": "OFF",
"LIBCXX_ABI_VERSION": "2",
"LLVM_CCACHE_BUILD": "ON",
# TODO: At this point lld crashes during linking clang itself
# cause of an issues in the `MachineDominator Tree Construction`
# pass that leads to an out of memory issue. Turn LTO on later
# "LLVM_ENABLE_LTO": "THIN",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"CLANG_DEFAULT_CXX_STDLIB": "libc++",
"CLANG_DEFAULT_LINKER": "lld",
"CLANG_DEFAULT_OBJCOPY": "llvm-objcopy",
"CLANG_DEFAULT_RTLIB": "compiler-rt",
"CLANG_VENDOR_UTI": "serene.toolchain",
"LLVM_ENABLE_LIBCXX": "ON",
"LLVM_ENABLE_ZSTD": "OFF",
"LLVM_OPTIMIZED_TABLEGEN": "OFF",
"LLVM_THINLTO_CACHE_PATH": "/tmp/llvm-build-lto",
"LLVM_ENABLE_PROJECTS": ";".join(PROJECTS),
"LLVM_CCACHE_BUILD": "ON",
"LIBCXX_HAS_MUSL_LIBC": "ON",
# "LLVM_PARALLEL_COMPILE_JOBS": "32",
# "LLVM_PARALLEL_LINK_JOBS": "1",
"LLVM_DEFAULT_TARGET_TRIPLE": os.environ["TARGET"],
# Common
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
}
class toolchain(ConanFile):
name = "toolchain"
settings = "os", "arch", "build_type"
version = get_version("llvm")
def build_requirements(self):
self.requires(f"llvm-source/{self.version}@{self.user}/{self.channel}")
self.requires(
f"stage2-sysroot/{get_version('llvm')}@{self.user}/{self.channel}"
)
@property
def buildenv(self):
return self.buildenv_info.vars(self, scope="build")
def add_compiler_options(self, opts):
# We can't use the clang-bootstrap toolchain file here because it will be passed
# to the runtimes and bulitins subcmake stuff later and it will "poison" the cmake
# cache with the wrong compiler and options. So we do this manually the hard way.
tc_dir = Path(self.dependencies["stage2-sysroot"].package_folder)
opts["CMAKE_C_COMPILER"] = str(tc_dir / "bin" / "clang")
opts["CMAKE_CXX_COMPILER"] = str(tc_dir / "bin" / "clang++")
# opts["LLVM_CONFIG_PATH"] = str(tc_dir / "bin" / "llvm-config")
target = os.environ["TARGET"]
opts["CMAKE_C_COMPILER_TARGET"] = target
opts["CMAKE_CXX_COMPILER_TARGET"] = target
opts["CMAKE_SYSROOT"] = str(tc_dir)
opts[
"CMAKE_EXE_LINKER_FLAGS"
] = f"-Wl,-rpath,{str(tc_dir)}/lib/{target} -static -Wl,-static"
opts[
"CMAKE_SHARED_LINKER_FLAGS"
] = f"-Wl,-rpath,$ORIGIN/../lib/{target} -Wl,-rpath,$ORIGIN/../lib/"
# opts["CMAKE_C_FLAGS"] = "-static" -Wl,-rpath,{str(tc_dir)}/lib/{target}
# opts["CMAKE_CXX_FLAGS"] = "-static"
def add_runtimes_and_builtins(self, opts):
builtin_targets = []
target = os.environ["TARGET"]
sysroot_path = Path(self.dependencies["stage2-sysroot"].package_folder)
target_builtin_opts = {
"CMAKE_SYSTEM_NAME": "Linux",
"CMAKE_BUILD_TYPE": self.settings.build_type,
"CMAKE_SYSTEM_PROCESSOR": "X86_64",
"CMAKE_C_FLAGS": self.buildenv.get("CFLAGS", ""),
"CMAKE_CXX_FLAGS": self.buildenv.get("CXXFLAGS", ""),
"CMAKE_ASM_FLAGS": self.buildenv.get("ASFLAGS", ""),
"CMAKE_C_COMPILER_TARGET": target,
"CMAKE_CXX_COMPILER_TARGET": target,
"CMAKE_ASM_COMPILER_TARGET": target,
"CMAKE_TRY_COMPILE_TARGET_TYPE": "STATIC_LIBRARY",
"CMAKE_EXE_LINKER_FLAGS": f"--target={target} {self.buildenv.get('LDFLAGS', '')}",
"CMAKE_SHARED_LINKER_FLAGS": f"--target={target} {self.buildenv.get('LDFLAGS', '')}",
"CMAKE_SYSROOT": str(sysroot_path),
"CMAKE_INSTALL_RPATH": "\$ORIGIN/../lib",
"CMAKE_BUILD_WITH_INSTALL_RPATH": "ON",
"LLVM_USE_LINKER": "lld",
"COMPILER_RT_BAREMETAL_BUILD": "ON",
"COMPILER_RT_DEFAULT_TARGET_ONLY": "ON",
"LLVM_CCACHE_BUILD": opts["LLVM_CCACHE_BUILD"],
}
for k, v in target_builtin_opts.items():
opts[f"BUILTINS_{target}_{k}"] = v
target_runtime_opts = {
"CMAKE_SYSTEM_NAME": "Linux",
"CMAKE_BUILD_TYPE": self.settings.build_type,
"CMAKE_C_FLAGS": self.buildenv.get("CFLAGS", ""),
"CMAKE_CXX_FLAGS": self.buildenv.get("CXXFLAGS", ""),
"CMAKE_ASM_FLAGS": self.buildenv.get("ASFLAGS", ""),
"CMAKE_C_COMPILER_TARGET": target,
"CMAKE_CXX_COMPILER_TARGET": target,
"CMAKE_ASM_COMPILER_TARGET": target,
"CMAKE_TRY_COMPILE_TARGET_TYPE": "STATIC_LIBRARY",
"CMAKE_EXE_LINKER_FLAGS": f"--target={target} {self.buildenv.get('LDFLAGS', '')}",
"CMAKE_SHARED_LINKER_FLAGS": f"--target={target} {self.buildenv.get('LDFLAGS', '')}",
"CMAKE_INSTALL_RPATH": "\$ORIGIN/../lib",
"CMAKE_BUILD_WITH_INSTALL_RPATH": "ON",
"CMAKE_SYSROOT": str(sysroot_path),
"CMAKE_VERBOSE_MAKEFILE": "ON",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"LLVM_USE_LINKER": "lld",
"LLVM_USE_LTO": "ON",
"LLVM_CCACHE_BUILD": opts["LLVM_CCACHE_BUILD"],
# TODO: Check for more sanitizers that work with musl
"COMPILER_RT_SANITIZERS_TO_BUILD": "asan;msan;tsan",
"COMPILER_RT_USE_BUILTINS_LIBRARY": "ON",
"COMPILER_RT_USE_LIBCXX": "ON",
"COMPILER_RT_BUILD_SANITIZERS": "ON",
# For some reason this flag is not correctly set if we don't
# manually set it and some strange gnu only LDFLAGS are injected.
"COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT": "OFF",
# X-Ray doesn't seem to compiler with musl
"COMPILER_RT_BUILD_XRAY": "OFF",
# Only build these if we enable sanitizers since they depend
# on the sanitizer common runtime
"COMPILER_RT_BUILD_MEMPROF": "ON",
"COMPILER_RT_BUILD_LIBFUZZER": "ON",
"COMPILER_RT_BUILD_ORC": "ON",
# Make sure we use libc++ from the tree instead from the system.
"SANITIZER_CXX_ABI": "libc++",
"SANITIZER_CXX_ABI_INTREE": "ON",
"LIBCXX_CXX_ABI": "libcxxabi",
"LIBCXX_USE_COMPILER_RT": "ON",
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY": "ON",
"LIBCXX_ABI_UNSTABLE": "ON",
"LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY": "ON",
"LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY": "ON",
"LIBCXX_ABI_VERSION": "2",
"LIBCXX_HAS_MUSL_LIBC": "ON",
# musl doesn't have -latomic
"LIBCXX_HAS_ATOMIC_LIB": "OFF",
"LIBCXXABI_ENABLE_THREADS": "ON",
"LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL": "OFF",
"LIBCXXABI_USE_COMPILER_RT": "ON",
"LIBCXXABI_USE_LLVM_UNWINDER": "ON",
"LIBCXXABI_ENABLE_STATIC_UNWINDER": "ON",
"LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY": "ON",
"LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY": "ON",
"LIBCXXABI_ENABLE_SHARED": "OFF",
"LIBUNWIND_USE_COMPILER_RT": "ON",
}
for k, v in target_runtime_opts.items():
opts[f"RUNTIMES_{target}_{k}"] = v
opts["LLVM_RUNTIME_TARGETS"] = target
opts["LLVM_BUILTIN_TARGETS"] = target
opts["LLVM_ENABLE_RUNTIMES"] = ";".join(RUNTIME_TARGETS)
def generate(self):
tc = CMakeToolchain(self)
tc.preprocessor_definitions["_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE"] = ""
tc.preprocessor_definitions["_LIBCPP_HAS_MUSL_LIBC"] = "ON"
tc.generate()
deps = CMakeDeps(self)
deps.set_property("zlib", "cmake_find_mode", "both")
deps.generate()
def build(self):
opts = CMAKE_OPTIONS.copy()
sysroot = self.dependencies["stage2-sysroot"].package_folder
self.add_compiler_options(opts)
# zlib_dir = self.dependencies["zlib"].package_folder
opts["ZLIB_ROOT"] = sysroot
opts[
"CMAKE_REQUIRED_INCLUDES"
] = f"{sysroot}/lib/clang/17/include {sysroot}/include"
opts["CMAKE_REQUIRED_LIBRARIES"] = f"-L{sysroot}/lib -lz"
# opts["LLVM_EXTERNALIZE_DEBUGINFO"] = "ON"
# opts["LLVM_DEBUGINFO_OUTPUT_DIR"] = f"{self.package_folder}/debug"
self.add_runtimes_and_builtins(opts)
for target in opts["LLVM_RUNTIME_TARGETS"].split(";"):
extra_target = None
bin_dir = Path(self.package_folder) / "bin"
bin_dir.mkdir(exist_ok=True, parents=True)
opts["LLVM_ENABLE_PROJECTS"] = ";".join(PROJECTS)
opts["LLVM_DISTRIBUTION_COMPONENTS"] = ";".join(TOOLCHAIN_TARGETS)
stage1 = Path(self.dependencies["stage2-sysroot"].package_folder)
opts["LLVM_TABLEGEN"] = str(stage1 / "bin" / "llvm-tblgen")
opts["CLANG_TABLEGEN"] = str(stage1 / "bin" / "clang-tblgen")
llvm_dir = self.dependencies["llvm-source"].buildenv_info.vars(
self, scope="build"
)
build_dir = os.path.join(self.build_folder, "build")
os.makedirs(build_dir)
with current_dir(build_dir):
cm = CMake(self)
cm.configure(
opts,
build_script_folder=os.path.join(llvm_dir["LLVM_SOURCE_DIR"], "llvm"),
)
cm.build(target="install-builtins")
cm.build(target="install-compiler-rt")
cm.build(target="install-runtimes")
# cm.build(target="install-toolchain-stripped")
cm.build(target="install-distribution-stripped")
def package_info(self):
bindir = Path(os.path.join(self.package_folder, "bin"))
clang_lib_dir = Path(
os.path.join(
self.package_folder, "lib", "clang", get_version("llvm_major"), "lib"
)
)
self.runenv_info.prepend_path(
"PATH",
str(bindir),
)
self.buildenv_info.define("CC", str(bindir / "clang"))
self.buildenv_info.define("CXX", str(bindir / "clang++"))
self.buildenv_info.define("AR", str(bindir / "llvm-ar"))
self.buildenv_info.define("NM", str(bindir / "llvm-nm"))
self.buildenv_info.define("RANLIB", str(bindir / "llvm-ranlib"))
self.buildenv_info.append("sysroot", self.package_folder)
f = os.path.join(self.package_folder, "toolchain.cmake")
self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", f)
self.conf_info.define("tools.build:sysroot", self.package_folder)
self.buildenv_info.define_path("SYSROOT", self.package_folder)

View File

@ -0,0 +1,33 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -14,29 +14,64 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
from conan.tools.cmake import CMakeToolchain, CMakeDeps
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
from conf.base.zlib import ZlibBase
from conf.utils import get_version, with_musl_toolchain
from conf.utils import get_version, with_musl_toolchain, copy_dependency_tree
class Zlib(ZlibBase):
name = "zlib"
def build_requirements(self):
super().build_requirements()
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
options = {
"stage": [1, 2],
}
default_options = {"stage": 1}
def build_requirements(self):
if self.options.stage == 1:
self.requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
else:
self.requires(
f"clang/{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, "TARGET")
self.buildenv_info.prepend_path("PATH", f"{self.build_folder}/sysroot")
with_musl_toolchain(self, tc, sysroot=f"{self.build_folder}/sysroot")
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def create_sysroot(self):
sysroot = Path(self.build_folder) / "sysroot"
sysroot.mkdir()
clang = "clang-bootstrap" if self.options.stage == 1 else "clang"
copy_dependency_tree(self, [clang, "musl"], sysroot)
def build(self):
self.create_sysroot()
sysroot = f"{self.build_folder}/sysroot"
cmake = CMake(self)
cmake.configure(
{
"BUILD_SHARED_LIBS": False,
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"CMAKE_SYSROOT": sysroot,
},
build_script_folder=f"zlib-{self.version}",
)
self.run("ninja zlibstatic")

View File

@ -15,24 +15,36 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
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
from conf.utils import get_version, with_musl_toolchain, copy_dependency_tree
class Zstd(ZstdBase):
name = "zstd"
def build_requirements(self):
super().build_requirements()
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
options = {
"stage": [1, 2],
}
default_options = {"stage": 1}
def build_requirements(self):
if self.options.stage == 1:
self.requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
else:
self.requires(
f"clang/{get_version('llvm')}@{self.user}/{self.channel}",
visible=False,
)
self.requires(f"musl/{get_version('musl')}@{self.user}/{self.channel}")
def generate(self):
@ -42,3 +54,31 @@ class Zstd(ZstdBase):
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def create_sysroot(self):
sysroot = Path(self.build_folder) / "sysroot"
sysroot.mkdir()
clang = "clang-bootstrap" if self.options.stage == 1 else "clang"
copy_dependency_tree(self, [clang, "musl"], sysroot)
def build(self):
self.create_sysroot()
sysroot = f"{self.build_folder}/sysroot"
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",
"CMAKE_SYSROOT": sysroot,
},
build_script_folder=f"zstd-{self.version}/build/cmake/",
)
cmake.build()
cmake.install()

View File

@ -3,7 +3,7 @@ include(common)
[settings]
os=Linux
arch=x86_64
build_type=Release
build_type=RelWithDebInfo
compiler=gcc
compiler.version=12.2
@ -12,5 +12,9 @@ compiler.libcxx=libstdc++
[buildenv]
LD=lld
[options]
cmake/*:libc=glibc
ninja/*:libc=glibc
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

View File

@ -6,7 +6,7 @@ arch=x86_64
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.version=17-stage1
compiler.libcxx=libc++
clang-bootstrap/*:compiler=gcc
@ -18,5 +18,10 @@ CC=clang
CXX=clang++
LD=lld
[options]
*/*:stage=1
cmake/*:libc=glibc
ninja/*:libc=glibc
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

24
profiles/stage2 Normal file
View File

@ -0,0 +1,24 @@
{% set LLVM_VERSION = os.getenv("LLVM_VERSION") %}
[settings]
os=Linux
arch=x86_64
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.libcxx=libc++
[buildenv]
CC=clang
CXX=clang++
LD=lld
[options]
*/*:stage=2
cmake/*:libc=musl
ninja/*:libc=musl
[conf]
tools.cmake.cmaketoolchain:generator=Ninja