Skip to content

Commit 1626655

Browse files
fix compiling libc to use correct clang in CI
1 parent 026d574 commit 1626655

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

scripts/dev.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,22 +450,38 @@ def build_libc(release):
450450
"-Wl,--relocatable"
451451
]
452452

453+
clang = 'clang'
454+
llvm_ar = 'llvm-ar'
455+
456+
#NOTE(martin): this is an extremely stupid workaround to play well with github CI runners, which
457+
# have llvm clang only accessible through $(brew --prefix llvm@15), whereas locally we could want to
458+
# use another version.
459+
# TODO: we should probably pass a flag to inform the script it's running in CI. This would avoid picking
460+
# llvm 15 when a later version is available locally?
461+
if platform.system() == "Darwin":
462+
try:
463+
brew_llvm = subprocess.check_output(["brew", "--prefix", "llvm@15", "--installed"], stderr=subprocess.DEVNULL).decode().strip()
464+
except subprocess.CalledProcessError:
465+
brew_llvm = subprocess.check_output(["brew", "--prefix", "llvm", "--installed"]).decode().strip()
466+
clang = os.path.join(brew_llvm, 'bin', 'clang')
467+
llvm_ar = os.path.join(brew_llvm, 'bin', 'llvm-ar')
468+
453469
# compile dummy CRT
454470
subprocess.run([
455-
"clang", *flags, *includes,
471+
clang, *flags, *includes,
456472
"-o", "build/orca-libc/lib/crt1.o",
457473
"src/orca-libc/src/crt/crt1.c"
458474
], check=True)
459475

460476
# compile standard lib
461477
subprocess.run([
462-
"clang", *flags, *includes,
478+
clang, *flags, *includes,
463479
"-o", "build/orca-libc/lib/libc.o",
464480
*cfiles
465481
], check=True)
466482

467483
subprocess.run([
468-
"llvm-ar", "crs",
484+
llvm_ar, "crs",
469485
"build/orca-libc/lib/libc.a",
470486
"build/orca-libc/lib/libc.o"
471487
], check=True)

0 commit comments

Comments
 (0)