Skip to content

Commit 33d1f8c

Browse files
committed
Added fixes for rocm build from src
1 parent f83a9f8 commit 33d1f8c

5 files changed

Lines changed: 110 additions & 2 deletions

File tree

script/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MLCommons Automation Scripts
22

3-
*Last updated: 2026-04-24 01:24:52*
3+
*Last updated: 2026-04-24 17:16:41*
44

55
This directory contains automation scripts for MLPerf benchmarks, AI/ML workflows, and development operations.
66

script/get-amdclang/meta.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ new_env_keys:
2121
- MLC_COMPILER_*
2222
- MLC_LINKER_*
2323
- +PATH
24+
- MLC_ROCM_CPULIBS_PATH
2425
deps:
2526
- tags: get,rocm
2627
names:
@@ -48,7 +49,16 @@ variations:
4849
adr:
4950
get-rocm:
5051
tags: _no-runtimes
52+
cpulibs:
53+
env:
54+
MLC_ROCM_INSTALL_CPULIBS: 'yes'
55+
adr:
56+
get-rocm:
57+
tags: _cpulibs
5158
sort: 500
5259
tests:
5360
run_inputs:
5461
- variations_list: []
62+
- variations_list:
63+
- src
64+
- cpulibs

script/get-rocm/meta.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ clean_files: []
1212
new_env_keys:
1313
- MLC_ROMLC_*
1414
- +PATH
15+
- MLC_ROCM_CPULIBS_PATH
1516
prehook_deps:
1617
- enable_if_env:
1718
MLC_REQUIRE_INSTALL:
@@ -41,3 +42,9 @@ variations:
4142
adr:
4243
install-rocm:
4344
tags: _no-runtimes
45+
cpulibs:
46+
env:
47+
MLC_ROCM_INSTALL_CPULIBS: 'yes'
48+
adr:
49+
install-rocm:
50+
tags: _cpulibs

script/install-rocm/customize.py

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import glob
44
import re
5+
import shutil
56

67
try:
78
from urllib.request import urlopen
@@ -40,7 +41,7 @@ def preprocess(i):
4041
env['MLC_ROCM_INSTALL_PREFIX'] = build_install_prefix
4142

4243
targets = 'AMDGPU;X86'
43-
projects = 'clang;lld;clang-tools-extra'
44+
projects = 'clang;lld;clang-tools-extra;flang;compiler-rt'
4445

4546
q = "'"
4647

@@ -131,6 +132,14 @@ def postprocess(i):
131132
env['MLC_ROMLC_INSTALLED_PATH'] = bin_dir
132133
env['MLC_ROMLC_BIN_WITH_PATH'] = os.path.join(bin_dir, 'rocminfo') if os.path.isfile(os.path.join(bin_dir, 'rocminfo')) else clang_path
133134
env['+PATH'] = [bin_dir]
135+
136+
# Install cpulibs if requested
137+
if env.get('MLC_ROCM_INSTALL_CPULIBS', '') == 'yes':
138+
lib_dir = os.path.join(install_dir, 'lib')
139+
os.makedirs(lib_dir, exist_ok=True)
140+
_install_cpulibs(env, lib_dir)
141+
env['MLC_ROCM_CPULIBS_PATH'] = lib_dir
142+
134143
return {'return': 0}
135144

136145
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '/')
@@ -182,4 +191,69 @@ def postprocess(i):
182191
env['MLC_ROMLC_BIN_WITH_PATH'] = os.path.join(installed_path, "rocminfo")
183192
env['+PATH'] = [installed_path]
184193

194+
# Install cpulibs if requested
195+
if env.get('MLC_ROCM_INSTALL_CPULIBS', '') == 'yes':
196+
lib_dir = os.path.join(os.path.dirname(installed_path), 'lib')
197+
if os.path.isdir(lib_dir):
198+
_install_cpulibs(env, lib_dir)
199+
env['MLC_ROCM_CPULIBS_PATH'] = lib_dir
200+
185201
return {'return': 0}
202+
203+
204+
def _install_cpulibs(env, lib_dir):
205+
"""Copy jemalloc and amdlibm libs into the compiler lib directory."""
206+
207+
copied = []
208+
209+
# Copy jemalloc libs
210+
jemalloc_lib_path = env.get('MLC_JEMALLOC_LIB_PATH', '')
211+
if jemalloc_lib_path and os.path.isdir(jemalloc_lib_path):
212+
for f in os.listdir(jemalloc_lib_path):
213+
if f.startswith('libjemalloc') and (f.endswith('.so') or f.endswith('.a') or '.so.' in f):
214+
src = os.path.join(jemalloc_lib_path, f)
215+
dst = os.path.join(lib_dir, f)
216+
if os.path.isfile(src) and not os.path.islink(src):
217+
shutil.copy2(src, dst)
218+
copied.append(f)
219+
elif os.path.islink(src):
220+
link_target = os.readlink(src)
221+
if os.path.exists(dst) or os.path.islink(dst):
222+
os.remove(dst)
223+
os.symlink(link_target, dst)
224+
copied.append(f'{f} -> {link_target}')
225+
# Create amdalloc -> jemalloc symlinks
226+
for ext in ['.so', '.a']:
227+
jemalloc_name = f'libjemalloc{ext}'
228+
amdalloc_name = f'libamdalloc{ext}'
229+
jemalloc_dst = os.path.join(lib_dir, jemalloc_name)
230+
amdalloc_dst = os.path.join(lib_dir, amdalloc_name)
231+
if os.path.isfile(jemalloc_dst) and not os.path.exists(amdalloc_dst):
232+
os.symlink(jemalloc_name, amdalloc_dst)
233+
copied.append(f'{amdalloc_name} -> {jemalloc_name}')
234+
print(f' Installed jemalloc libs: {copied}')
235+
else:
236+
print(f' WARNING: jemalloc lib path not found: {jemalloc_lib_path}')
237+
238+
# Copy amdlibm (aocl-libm) libs
239+
amdlibm_copied = []
240+
amdlibm_lib_path = env.get('MLC_AOCL_LIBM_LIB_PATH', '')
241+
if amdlibm_lib_path and os.path.isdir(amdlibm_lib_path):
242+
for f in os.listdir(amdlibm_lib_path):
243+
if (f.startswith('libalm') or f.startswith('libamdlibm')) and (f.endswith('.so') or f.endswith('.a') or '.so.' in f):
244+
src = os.path.join(amdlibm_lib_path, f)
245+
dst = os.path.join(lib_dir, f)
246+
if os.path.isfile(src) and not os.path.islink(src):
247+
shutil.copy2(src, dst)
248+
amdlibm_copied.append(f)
249+
elif os.path.islink(src):
250+
link_target = os.readlink(src)
251+
if os.path.exists(dst) or os.path.islink(dst):
252+
os.remove(dst)
253+
os.symlink(link_target, dst)
254+
amdlibm_copied.append(f'{f} -> {link_target}')
255+
print(f' Installed amdlibm libs: {amdlibm_copied}')
256+
else:
257+
print(f' WARNING: amdlibm lib path not found: {amdlibm_lib_path}')
258+
259+
return copied + amdlibm_copied

script/install-rocm/meta.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ new_env_keys:
1616
- MLC_ROMLC_*
1717
- MLC_ROCM_INSTALL_PREFIX
1818
- +PATH
19+
- MLC_ROCM_CPULIBS_PATH
1920
deps:
2021
- tags: detect,os
2122
- tags: detect,sudo
@@ -64,6 +65,22 @@ variations:
6465
group: runtimes
6566
env:
6667
MLC_ROCM_SRC_WITH_RUNTIMES: 'no'
68+
cpulibs:
69+
env:
70+
MLC_ROCM_INSTALL_CPULIBS: 'yes'
71+
deps:
72+
- tags: get,lib,jemalloc
73+
names:
74+
- jemalloc
75+
inherit_variation_tags: true
76+
skip_inherit_variation_groups:
77+
- runtimes
78+
- tags: get,lib,aocl-libm
79+
names:
80+
- aocl-libm
81+
inherit_variation_tags: true
82+
skip_inherit_variation_groups:
83+
- runtimes
6784
default_version: 7.2.2
6885
versions:
6986
7.2.2: {}

0 commit comments

Comments
 (0)