Skip to content

Commit 179dc4f

Browse files
[GR-34952] Add SulongToolchainNativeProject, use it in espresso.
PullRequest: graal/10230
2 parents 8672051 + b635e26 commit 179dc4f

File tree

7 files changed

+67
-19
lines changed

7 files changed

+67
-19
lines changed

espresso/ci.jsonnet

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@
3030
},
3131
},
3232

33-
windows_8 : devkits["windows-openjdk8"] + common.common + {
34-
capabilities : ['windows', 'amd64']
35-
},
36-
37-
windows_11 : devkits["windows-jdk11"] + common.common + {
38-
capabilities : ['windows', 'amd64']
39-
},
40-
41-
windows_17 : devkits["windows-jdk17"] + common.common + {
42-
capabilities : ['windows', 'amd64']
43-
},
33+
windows_8 : devkits["windows-openjdk8"] + common.windows,
34+
windows_11 : devkits["windows-jdk11"] + common.windows,
35+
windows_17 : devkits["windows-jdk17"] + common.windows,
4436

4537
builds: common.builds + [
4638
// Benchmarks

espresso/ci_common/common.jsonnet

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
local base = import '../ci.jsonnet';
22

3+
local composable = (import "../../common-utils.libsonnet").composable;
4+
local sulong_deps = composable((import "../../common.json").sulong.deps);
5+
36
local _host_jvm(env) = 'graalvm-espresso-' + env;
47
local _host_jvm_config(env) = if std.startsWith(env, 'jvm') then 'jvm' else 'native';
58

@@ -31,7 +34,7 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
3134
],
3235
},
3336

34-
linux: self.common + {
37+
linux: self.common + sulong_deps.linux + {
3538
packages+: {
3639
'00:devtoolset': '==7', # GCC 7.3.1, make 4.2.1, binutils 2.28, valgrind 3.13.0
3740
'01:binutils': '>=2.34',
@@ -50,14 +53,18 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
5053
capabilities+: ['no_frequency_scaling', 'tmpfs25g', 'x52'],
5154
},
5255

53-
darwin: self.common + {
56+
darwin: self.common + sulong_deps.darwin + {
5457
environment+: {
5558
// for compatibility with macOS High Sierra
5659
MACOSX_DEPLOYMENT_TARGET: '10.13',
5760
},
5861
capabilities: ['darwin', 'amd64'],
5962
},
6063

64+
windows: self.common + {
65+
capabilities : ['windows', 'amd64']
66+
},
67+
6168
// generic targets
6269
gate: {targets+: ['gate'], timelimit: "1:00:00"},
6370
postMerge: {targets+: ['post-merge'], notify_emails: ["[email protected]"]},

espresso/mx.espresso/suite.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@
7171
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
7272
]
7373
},
74+
{
75+
"name": "sulong",
76+
"subdir": True,
77+
"urls": [
78+
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
79+
],
80+
"os_arch": {
81+
"windows": {
82+
"<others>": {
83+
"ignore": True,
84+
},
85+
},
86+
}
87+
},
7488
{
7589
"name" : "java-benchmarks",
7690
"subdir": True,
@@ -198,6 +212,7 @@
198212
"<others>": {
199213
"<others>": {
200214
"cflags": ["-Wall", "-Werror"],
215+
"toolchain": "sulong:SULONG_BOOTSTRAP_TOOLCHAIN",
201216
},
202217
},
203218
},
@@ -249,6 +264,7 @@
249264
"-Wl,-current_version,1.0.0",
250265
"-Wl,-compatibility_version,1.0.0"
251266
],
267+
"toolchain": "sulong:SULONG_BOOTSTRAP_TOOLCHAIN",
252268
},
253269
},
254270
"linux": {
@@ -258,6 +274,7 @@
258274
"-Wl,-soname,libjvm.so",
259275
"-Wl,--version-script,<path:espresso:com.oracle.truffle.espresso.mokapot>/mapfile-vers",
260276
],
277+
"toolchain": "sulong:SULONG_BOOTSTRAP_TOOLCHAIN",
261278
},
262279
},
263280
"windows": {

sulong/mx.sulong/mx_sulong.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ def __init__(self, name, dist, bootstrap_dist, tools, suite):
362362
self.name = name
363363
self.dist = dist if isinstance(dist, list) else [dist]
364364
self.bootstrap_provider = create_toolchain_root_provider(name, bootstrap_dist)
365+
self.bootstrap_dist = bootstrap_dist
365366
self.tools = tools
367+
self.llvm_binutil_tools = [tool.upper() for tool in ToolchainConfig._llvm_tool_map]
366368
self.suite = suite
367369
self.mx_command = self.name + '-toolchain'
368370
self.tool_map = {tool: [_exe_sub(alias.format(name=name)) for alias in aliases] for tool, aliases in ToolchainConfig._tool_map.items()}
@@ -410,7 +412,12 @@ def _check_tool(self, tool):
410412
mx.abort("The {} toolchain (defined by {}) does not support tool '{}'".format(self.name, self.dist[0], tool))
411413

412414
def get_toolchain_tool(self, tool):
413-
return os.path.join(self.bootstrap_provider(), 'bin', self._tool_to_exe(tool))
415+
if tool in self._supported_tools():
416+
return os.path.join(self.bootstrap_provider(), 'bin', self._tool_to_exe(tool))
417+
elif tool in self.llvm_binutil_tools:
418+
return os.path.join(self.bootstrap_provider(), 'bin', _exe_sub(tool.lower()))
419+
else:
420+
mx.abort("The {} toolchain (defined by {}) does not support tool '{}'".format(self.name, self.dist[0], tool))
414421

415422
def get_toolchain_subdir(self):
416423
return self.name
@@ -434,7 +441,7 @@ def _get_jar_dists(self):
434441
return [d if ":" in d else self.suite.name + ":" + d for d in self.dist]
435442

436443

437-
_suite.toolchain = ToolchainConfig('native', 'SULONG_TOOLCHAIN_LAUNCHERS', 'SULONG_BOOTSTRAP_TOOLCHAIN',
444+
_suite.toolchain = ToolchainConfig('native', 'SULONG_TOOLCHAIN_LAUNCHERS', 'sulong:SULONG_BOOTSTRAP_TOOLCHAIN',
438445
# unfortunately, we cannot define those in the suite.py because graalvm component
439446
# registration runs before the suite is properly initialized
440447
tools={

sulong/mx.sulong/mx_sulong_suite_constituents.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def getTestFile(self):
329329
class BootstrapToolchainLauncherProject(mx.Project): # pylint: disable=too-many-ancestors
330330
def __init__(self, suite, name, deps, workingSets, theLicense, **kwArgs):
331331
super(BootstrapToolchainLauncherProject, self).__init__(suite, name, srcDirs=[], deps=deps, workingSets=workingSets, d=suite.dir, theLicense=theLicense, **kwArgs)
332+
self.buildDependencies += ['mx:GCC_NINJA_TOOLCHAIN']
332333

333334
def launchers(self):
334335
for tool in self.suite.toolchain._supported_tools():
@@ -338,9 +339,16 @@ def launchers(self):
338339
result = os.path.join(self.get_output_root(), exe)
339340
yield result, tool, exe
340341

342+
def ninja_toolchain_path(self):
343+
return os.path.join(self.get_output_root(), 'toolchain.ninja')
344+
341345
def getArchivableResults(self, use_relpath=True, single=False):
346+
if single:
347+
raise ValueError("Cannot produce single result for BootstrapToolchainLauncherProject")
342348
for result, _, exe in self.launchers():
343349
yield result, os.path.join('bin', exe)
350+
toolchain_path = self.ninja_toolchain_path()
351+
yield toolchain_path, os.path.basename(toolchain_path)
344352

345353
def getBuildTask(self, args):
346354
return BootstrapToolchainLauncherBuildTask(self, args, 1)
@@ -388,6 +396,8 @@ def build(self):
388396
with open(result, "w") as f:
389397
f.write(self.contents(tool, exe))
390398
os.chmod(result, 0o755)
399+
with open(self.subject.ninja_toolchain_path(), "w") as f:
400+
f.write(self.ninja_toolchain_contents())
391401

392402
def clean(self, forBuild=False):
393403
if os.path.exists(self.subject.get_output_root()):
@@ -415,6 +425,20 @@ def contents(self, tool, exe):
415425
else:
416426
return "#!/usr/bin/env bash\n" + "exec " + " ".join(command) + "\n"
417427

428+
def ninja_toolchain_contents(self):
429+
gcc_ninja_toolchain = mx.distribution('mx:GCC_NINJA_TOOLCHAIN')
430+
assert isinstance(gcc_ninja_toolchain, mx.AbstractDistribution) and gcc_ninja_toolchain.get_output()
431+
return """# Ninja rules for the LLVM toolchain
432+
include {gcc_toolchain}
433+
CC = {CC}
434+
CXX = {CXX}
435+
AR = {AR}
436+
437+
""".format(gcc_toolchain=os.path.join(gcc_ninja_toolchain.get_output(), 'toolchain.ninja'),
438+
CC=self.subject.suite.toolchain.get_toolchain_tool('CC'),
439+
CXX=self.subject.suite.toolchain.get_toolchain_tool('CXX'),
440+
AR=self.subject.suite.toolchain.get_toolchain_tool('AR'))
441+
418442

419443
class AbstractSulongNativeProject(mx.NativeProject): # pylint: disable=too-many-ancestors
420444
def __init__(self, suite, name, deps, workingSets, subDir, results=None, output=None, **args):

sulong/mx.sulong/suite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
suite = {
2-
"mxversion" : "5.305.3",
2+
"mxversion" : "5.317.0",
33
"name" : "sulong",
44
"versionConflictResolution" : "latest",
55

@@ -1527,6 +1527,7 @@
15271527
"layout": {
15281528
"./": "dependency:bootstrap-toolchain-launchers/*",
15291529
},
1530+
"asm_requires_cpp": False,
15301531
"buildDependencies" : [
15311532
"SULONG_TOOLCHAIN_LAUNCHERS",
15321533
],

vm/ci_includes/vm.hocon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ builds += [
102102
]
103103
name: gate-vm-build-without-vcs
104104
}
105-
${gate_vm_linux} ${linux-deploy} ${maven_base_8_11} {
105+
${gate_vm_linux} ${linux-deploy} ${maven_base_8_11} ${sulong_linux} {
106106
run: [
107107
${maven_base_8_11.build}
108108
${maven_base_8_11.deploy} [--dry-run, "lafo-maven"]
@@ -112,7 +112,7 @@ builds += [
112112
]
113113
name: gate-vm-maven-dry-run-linux-amd64
114114
}
115-
${gate_vm_linux} ${linux-deploy} ${maven_base_8_11} {
115+
${gate_vm_linux} ${linux-deploy} ${maven_base_8_11} ${sulong_linux} {
116116
downloads+= {
117117
OPEN_JDK_11: ${jdks.openjdk11},
118118
}
@@ -127,7 +127,7 @@ builds += [
127127
]
128128
name: gate-vm-js-on-jdk11-maven-linux-amd64
129129
}
130-
${deploy_vm_linux} ${linux-deploy} ${maven_base_8_11} {
130+
${deploy_vm_linux} ${linux-deploy} ${maven_base_8_11} ${sulong_linux} {
131131
run: [
132132
${maven_base_8_11.build}
133133
${maven_base_8_11.deploy} ["lafo-maven"]

0 commit comments

Comments
 (0)