Skip to content

Commit ea39f26

Browse files
committed
Upgrade to Cosmopolitan v3.8.0
The latest cosmocc allows us to use Clang for compilation which improves build latency for this project by 3x.
1 parent c7c4d65 commit ea39f26

File tree

14 files changed

+22
-26
lines changed

14 files changed

+22
-26
lines changed

build/config.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
33

44
PREFIX = /usr/local
5-
COSMOCC = .cosmocc/3.7.1
5+
COSMOCC = .cosmocc/3.8.0
66
TOOLCHAIN = $(COSMOCC)/bin/cosmo
77

88
CC = $(TOOLCHAIN)cc
@@ -14,7 +14,7 @@ INSTALL = install
1414

1515
ARFLAGS = rcsD
1616
CXXFLAGS = -frtti -std=gnu++23
17-
CCFLAGS = -O2 -fexceptions -fsignaling-nans -ffunction-sections -fdata-sections
17+
CCFLAGS = -O2 -g -fexceptions -ffunction-sections -fdata-sections -mclang
1818
CPPFLAGS_ = -iquote. -mcosmo -DGGML_MULTIPLATFORM -Wno-attributes -DLLAMAFILE_DEBUG
1919
TARGET_ARCH = -Xx86_64-mtune=znver4
2020

@@ -52,5 +52,5 @@ clean:; rm -rf o
5252
.PHONY: distclean
5353
distclean:; rm -rf o .cosmocc
5454

55-
.cosmocc/3.7.1:
56-
build/download-cosmocc.sh $@ 3.7.1 13b65b0e659b493bd82f3d0a319d0265d66f849839e484aa2a54191024711e85
55+
.cosmocc/3.8.0:
56+
build/download-cosmocc.sh $@ 3.8.0 813c6b2f95062d2e0a845307a79505424cb98cb038e8013334f8a22e3b92a474

llama.cpp/BUILD.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ o/$(MODE)/llama.cpp/ggml-vector-amd-f16c.o \
4747
o/$(MODE)/llama.cpp/ggml-vector-amd-fma.o \
4848
o/$(MODE)/llama.cpp/ggml-vector-arm80.o \
4949
o/$(MODE)/llama.cpp/ggml-vector-arm82.o: \
50-
private CCFLAGS += -O3
50+
private CCFLAGS += -O3 -mgcc
5151

5252
o/$(MODE)/llama.cpp/ggml-alloc.o \
5353
o/$(MODE)/llama.cpp/ggml-backend.o \
@@ -60,6 +60,9 @@ o/$(MODE)/llama.cpp/ggml-alloc.o \
6060
o/$(MODE)/llama.cpp/common.o: \
6161
private CCFLAGS += -Os
6262

63+
o/$(MODE)/llama.cpp/unicode-data.o: \
64+
private CCFLAGS += -mgcc
65+
6366
o/$(MODE)/llama.cpp/ggml-quants.o: private CXXFLAGS += -Os
6467
o/$(MODE)/llama.cpp/ggml-quants-amd-k8.o: private TARGET_ARCH += -Xx86_64-mtune=k8
6568
o/$(MODE)/llama.cpp/ggml-quants-amd-ssse3.o: private TARGET_ARCH += -Xx86_64-mtune=core2 -Xx86_64-mssse3

llama.cpp/ggml-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ GGML_CALL static void ggml_backend_registry_init(void) {
425425

426426
// add forward decls here to avoid including the backend headers
427427
/* #ifdef GGML_USE_CUDA [jart] */
428-
/* extern GGML_CALL void ggml_backend_cuda_reg_devices(void); */
428+
extern GGML_CALL void ggml_backend_cuda_reg_devices(void);
429429
ggml_backend_cuda_reg_devices();
430430
/* #endif */
431431

llama.cpp/ggml.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,10 @@ inline static void * ggml_aligned_malloc(size_t size) {
144144
if (result != 0) {
145145
// Handle allocation failure
146146
const char *error_desc = "unknown allocation error";
147-
switch (result) {
148-
case EINVAL:
149-
error_desc = "invalid alignment value";
150-
break;
151-
case ENOMEM:
152-
error_desc = "insufficient memory";
153-
break;
147+
if (result == EINVAL) {
148+
error_desc = "invalid alignment value";
149+
} else if (result == ENOMEM) {
150+
error_desc = "insufficient memory";
154151
}
155152
GGML_PRINT("%s: %s (attempted to allocate %6.2f MB)\n", __func__, error_desc, size/(1024.0*1024.0));
156153
GGML_ABORT("fatal error");

llama.cpp/llama-bench/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <string>
1616
#include <unistd.h>
1717
#include <vector>
18-
#include <tool/args/args.h>
18+
#include <cosmo.h>
1919
#include <stdatomic.h>
2020
#include <third_party/nsync/futex.internal.h>
2121

llama.cpp/llava/BUILD.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ LLAMA_CPP_LLAVA_HDRS = $(filter %.h,$(LLAMA_CPP_LLAVA_FILES))
88
LLAMA_CPP_LLAVA_SRCS = $(filter %.cpp,$(LLAMA_CPP_LLAVA_FILES))
99
LLAMA_CPP_LLAVA_OBJS = $(LLAMA_CPP_LLAVA_SRCS:%.cpp=o/$(MODE)/%.o)
1010

11-
.PHONY: tool/args/args.h
12-
1311
o/$(MODE)/llama.cpp/llava/llava.a: \
1412
$(LLAMA_CPP_LLAVA_OBJS)
1513

llama.cpp/main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <string>
1616
#include <unistd.h>
1717
#include <vector>
18-
#include <tool/args/args.h>
18+
#include <cosmo.h>
1919

2020
#include "llamafile/version.h"
2121
#include "llama.cpp/llama.h"

llama.cpp/server/server.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
#include <condition_variable>
2525
#include <atomic>
2626
#include <signal.h>
27-
#include <libc/calls/pledge.h>
28-
#include <tool/args/args.h>
27+
#include <cosmo.h>
2928
#include <libc/dce.h>
3029

3130
double g_prompt_per_second_jart;

llamafile/BUILD.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ o/$(MODE)/llamafile/tinyblas_cpu_sgemm_amd_fma.o \
143143
o/$(MODE)/llamafile/tinyblas_cpu_sgemm_amd_zen4.o \
144144
o/$(MODE)/llamafile/tinyblas_cpu_sgemm_arm80.o \
145145
o/$(MODE)/llamafile/tinyblas_cpu_sgemm_arm82.o: \
146-
private CCFLAGS += -O3 -fopenmp
146+
private CCFLAGS += -O3 -fopenmp -mgcc
147147

148148
################################################################################
149149
# testing

llamafile/ansiblas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace ansiBLAS {
2727

2828
static constexpr int KN = 8;
2929

30-
alignas(64) union Vector {
30+
union alignas(64) Vector {
3131
double v[KN];
3232
};
3333

@@ -94,7 +94,7 @@ struct ansiBLAS {
9494
}
9595

9696
template <int RM, int RN>
97-
__target_clones("avx512f,fma") void gemm(int m0, int m, int n0, int n) {
97+
void gemm(int m0, int m, int n0, int n) {
9898
int ytiles = (m - m0) / RM;
9999
int xtiles = (n - n0) / RN;
100100
int tiles = xtiles * ytiles;

0 commit comments

Comments
 (0)