summaryrefslogtreecommitdiff
path: root/cerbero
diff options
context:
space:
mode:
authorL. E. Segovia <amy@centricular.com>2023-09-17 15:26:53 -0300
committerL. E. Segovia <amy@centricular.com>2023-12-03 11:47:37 -0300
commitbb4710d2f0105597cb2df5e30defe955f8f6e89d (patch)
treeff4466d858e11c23dce9c5e179b25abb028bc2fc /cerbero
parentd00b90ba6ca71faabf1822953536841a9fb8aeec (diff)
rust: Allow using the llvm-tools-preview component within recipes
This is a preliminary change to enable stripping Rust generated libraries in macOS. This component is needed because Rust codegens with LLVM 16 bitcode, while Apple tools can only understand up to LLVM 14 (at least on Big Sur). Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1255>
Diffstat (limited to 'cerbero')
-rw-r--r--cerbero/bootstrap/rust.py5
-rw-r--r--cerbero/build/build.py11
2 files changed, 14 insertions, 2 deletions
diff --git a/cerbero/bootstrap/rust.py b/cerbero/bootstrap/rust.py
index 73ec6a18..67eb9ae6 100644
--- a/cerbero/bootstrap/rust.py
+++ b/cerbero/bootstrap/rust.py
@@ -41,7 +41,7 @@ class RustBootstrapper(BootstrapperBase):
RUSTUP_URL_TPL = '{server}/rustup/archive/{version}/{triple}/rustup-init{exe_suffix}'
RUSTUP_NAME_TPL = 'rustup-init-{version}-{triple}{exe_suffix}'
CHANNEL_URL_TPL = '{server}/dist/channel-rust-{version}.toml'
- COMPONENTS = ('cargo', 'rustc', 'rust-std')
+ COMPONENTS = ('cargo', 'rustc', 'rust-std', 'llvm-tools-preview')
# Update from https://pypi.org/project/tomli/#files
TOMLI_URL = 'https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz'
DOWNLOAD_CHECKSUMS = {
@@ -203,7 +203,8 @@ class RustBootstrapper(BootstrapperBase):
st = os.stat(self.rustup)
os.chmod(self.rustup, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
rustup_args = [self.rustup, '-y', '-v', '--no-modify-path',
- '--default-host', self.build_triple, '--profile', 'minimal']
+ '--default-host', self.build_triple, '--profile', 'minimal',
+ '--component', 'llvm-tools-preview']
for triple in self.target_triples:
rustup_args += ['--target', triple]
rustup_env = self.get_rustup_env()
diff --git a/cerbero/build/build.py b/cerbero/build/build.py
index 38e8ef3d..df873304 100644
--- a/cerbero/build/build.py
+++ b/cerbero/build/build.py
@@ -1247,6 +1247,17 @@ class Cargo(Build, ModifyEnvBase):
with open(os.path.join(dot_cargo, 'config.toml'), 'a') as f:
f.write(s)
+ def get_llvm_tool(self, tool: str) -> Path:
+ '''
+ Gets one of the LLVM tools matching the current Rust toolchain.
+ '''
+ root_dir = subprocess.run([self.config.cargo_home + '/bin/rustc',
+ '--print', 'sysroot'], capture_text=True, text=True, check=True).stdout.strip()
+ tools = glob.glob(f'**/{tool}', root_dir=root_dir)
+ if len(tools) == 0:
+ raise FatalError('Rust {tool} tool not found, try re-running bootstrap')
+ return (Path(root_dir) / tools[0]).resolve()
+
def get_cargo_toml_version(self):
tomllib = self.config.find_toml_module()
if not tomllib: