Skip to content

Commit 848524a

Browse files
committed
Fix building Alloy with metrics
1 parent b0324f2 commit 848524a

11 files changed

+612
-575
lines changed

alloy/elision.naive.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

alloy/elision.opt.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

alloy/gcvs.gc.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

alloy/gcvs.rc.config.toml

Lines changed: 0 additions & 22 deletions
This file was deleted.

alloy/premopt.naive.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

alloy/premopt.none.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

alloy/premopt.opt.config.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

artefacts.py

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from contextlib import ExitStack, contextmanager
55
from dataclasses import dataclass
66
from pathlib import Path
7-
from typing import Optional, Tuple
7+
from typing import ClassVar, Dict, Optional, Tuple
8+
9+
import toml
810

911
from util import command_runner
1012

@@ -193,34 +195,73 @@ def build(self):
193195

194196

195197
class Alloy(Artefact):
196-
profile: "ExperimentProfile"
197-
198-
def __init__(self, base: Artefact, profile: "ExperimentProfile"):
198+
DEFAULT_FLAGS: ClassVar[Dict[str, bool]] = {
199+
"gc-metrics": False,
200+
"finalizer-safety-analysis": False,
201+
"finalizer-elision": True,
202+
"premature-finalizer-prevention": True,
203+
"premature-finalizer-prevention-optimize": True,
204+
"gc-default-allocator": True,
205+
}
206+
207+
def __init__(self, base: Artefact, profile: "ExperimentProfile", metrics=False):
199208
self.__dict__.update(base.__dict__)
200209
self.profile = profile
210+
self.metrics = metrics
211+
self._config = None
201212

202213
@property
203214
def config(self) -> Path:
204-
return (
205-
Path("alloy").resolve()
206-
/ f"{self.profile.full.replace('-','.')}.config.toml"
207-
)
215+
if self._config and self._config.exists():
216+
return self._config
217+
218+
config = {
219+
"alloy": self.flags,
220+
"rust": {
221+
"codegen-units": 0,
222+
"optimize": True,
223+
"debug": False,
224+
},
225+
"build": {
226+
"install-stage": 2,
227+
},
228+
"llvm": {
229+
"download-ci-llvm": True,
230+
},
231+
"install": {
232+
"sysconfdir": "etc",
233+
},
234+
}
235+
file = self.src / f"{self.name.replace('-','.')}.config.toml"
236+
with open(file, "w") as f:
237+
toml.dump(config, f)
238+
return file
208239

209240
@property
210-
def install_prefix(self) -> Path:
211-
return BIN_DIR / self.repo.name / self.profile.experiment / self.profile.value
241+
def flags(self):
242+
return self.DEFAULT_FLAGS.copy() | (self.profile.alloy_flags or {})
212243

213244
@property
214-
def path(self) -> Path:
215-
return self.install_prefix / "bin" / "rustc"
245+
def name(self) -> str:
246+
if not self.flags["gc-default-allocator"]:
247+
base = "rustc-upstream"
248+
elif self.flags == self.DEFAULT_FLAGS:
249+
base = "default"
250+
else:
251+
base = self.profile.full
252+
return f"{base}-metrics" if self.metrics else base
253+
254+
@property
255+
def install_prefix(self) -> Path:
256+
return BIN_DIR / self.repo.name / self.name
216257

217258
@property
218259
def build_dir(self) -> Path:
219-
return BUILD_DIR / self.repo.name / self.profile.experiment / self.profile.value
260+
return BUILD_DIR / self.repo.name / self.name
220261

221262
@property
222-
def name(self) -> str:
223-
return f"{self.repo.name} | {self.profile.full}"
263+
def path(self) -> Path:
264+
return self.install_prefix / "bin" / "rustc"
224265

225266
@property
226267
def installed(self) -> bool:
@@ -304,7 +345,11 @@ def env(self):
304345

305346
@property
306347
def alloy(self) -> "Alloy":
307-
return self.profile.alloy()
348+
from build import Metric
349+
350+
is_metrics = self.metric == Metric.METRICS
351+
352+
return Alloy(ALLOY, self.profile, is_metrics)
308353

309354
@prepare_build
310355
def build(self):

0 commit comments

Comments
 (0)