Skip to content

Commit 16e0c81

Browse files
mesa: make use of LLVMPipe instead of softpipe
This makes the startup of alacritty faster! Blazingly fast (well kindof)! Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent c8b2f17 commit 16e0c81

File tree

11 files changed

+240
-47
lines changed

11 files changed

+240
-47
lines changed

bootstrap.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,41 @@ tools:
518518
- args: ['ninja', 'install']
519519

520520
packages:
521+
- name: llvm
522+
from_source: llvm
523+
tools_required:
524+
- host-cmake
525+
- host-gcc
526+
pkgs_required:
527+
- mlibc
528+
- zlib
529+
configure:
530+
- args:
531+
- 'cmake'
532+
- '-GNinja'
533+
- '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake'
534+
- '-DCMAKE_INSTALL_PREFIX=/usr'
535+
# We really have to build LLVM in Release mode.
536+
# Building it in debug mode produces tens of GiB of debugging info.
537+
- '-DCMAKE_BUILD_TYPE=Release'
538+
- '-DLLVM_LINK_LLVM_DYLIB=ON'
539+
# RTTI affects the ABI. Hence, we enable it.
540+
- '-DLLVM_ENABLE_RTTI=ON'
541+
- '-DLLVM_TARGETS_TO_BUILD=X86'
542+
- '-DLLVM_TARGET_ARCH=X86_64'
543+
- '-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-aero'
544+
- '-DLLVM_HOST_TRIPLE=x86_64-aero'
545+
# Disable linking against ncurses, which we do not build with -fPIC.
546+
- '-DLLVM_ENABLE_TERMINFO=OFF'
547+
# Suppress developer warnings
548+
- '-Wno-dev'
549+
- '@THIS_SOURCE_DIR@/llvm'
550+
build:
551+
- args: ['ninja', '-j@PARALLELISM@']
552+
- args: ['ninja', 'install/strip']
553+
environ:
554+
DESTDIR: '@THIS_COLLECT_DIR@'
555+
521556
- name: alacritty
522557
source:
523558
subdir: 'bundled'

bootstrap/xorg.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ packages:
513513
tools_required:
514514
- host-pkg-config
515515
- host-gcc
516-
- wayland-scanner
517516
- virtual: pkgconfig-for-target
518517
triple: "x86_64-aero"
519518
- virtual: pkgconfig-for-host
@@ -527,13 +526,21 @@ packages:
527526
- libx11
528527
- libxext
529528
- libxcb
529+
- llvm
530530
configure:
531+
- args: ['cp', '@SOURCE_ROOT@/userland/cross-file.ini', 'meson.cross-file']
532+
- args:
533+
- 'sed'
534+
- '-i'
535+
- "/^# sed adds binaries here.$/a llvm-config = '@SOURCE_ROOT@/userland/cross-llvm-config'"
536+
- 'meson.cross-file'
531537
- args:
532538
- 'meson'
539+
- 'setup'
533540
- '--native-file'
534541
- '@SOURCE_ROOT@/userland/native-file.ini'
535542
- '--cross-file'
536-
- '@SOURCE_ROOT@/userland/cross-file.ini'
543+
- 'meson.cross-file'
537544
- '--prefix=/usr'
538545
- '--libdir=lib'
539546
# The debug build type enables some additional output from Mesa.
@@ -545,6 +552,8 @@ packages:
545552
- '-Ddri-drivers='
546553
- '-Dgallium-drivers=swrast'
547554
- '-Dvulkan-drivers='
555+
# Force Mesa to build with LLVM.
556+
- '-Dllvm=enabled'
548557
- '@THIS_SOURCE_DIR@'
549558
build:
550559
- args: ['ninja', '-j@PARALLELISM@']

patches/mesa/mesa.patch

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From caa8eb2b0dbe4a49aecb691e3568fb0dc6d1a8e2 Mon Sep 17 00:00:00 2001
1+
From 17fb4ad377b2cd0d43a62af25b8c8375909da019 Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <[email protected]>
3-
Date: Sun, 20 Nov 2022 17:10:35 +1100
3+
Date: Sat, 18 Feb 2023 14:31:17 +1100
44
Subject: [PATCH] <xxx>
55

66
---
@@ -11,11 +11,12 @@ Subject: [PATCH] <xxx>
1111
src/gallium/drivers/llvmpipe/lp_texture.c | 1 -
1212
src/util/debug.c | 1 +
1313
src/util/detect_os.h | 8 ++++++++
14+
src/util/futex.h | 2 +-
1415
src/util/os_misc.c | 4 ++--
1516
src/util/os_time.c | 4 ++--
1617
src/util/u_printf.h | 2 ++
1718
src/util/u_thread.h | 4 ++--
18-
11 files changed, 23 insertions(+), 10 deletions(-)
19+
12 files changed, 24 insertions(+), 11 deletions(-)
1920

2021
diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h
2122
index 5e54c3a..be0e26d 100644
@@ -121,6 +122,19 @@ index 6506948..f5d49de 100644
121122
+#endif
122123

123124
#endif /* DETECT_OS_H */
125+
diff --git a/src/util/futex.h b/src/util/futex.h
126+
index 43097f4..98af1db 100644
127+
--- a/src/util/futex.h
128+
+++ b/src/util/futex.h
129+
@@ -24,7 +24,7 @@
130+
#ifndef UTIL_FUTEX_H
131+
#define UTIL_FUTEX_H
132+
133+
-#if defined(HAVE_LINUX_FUTEX_H)
134+
+#if defined(HAVE_LINUX_FUTEX_H) && defined(__linux__)
135+
#define UTIL_FUTEX_SUPPORTED 1
136+
137+
#include <limits.h>
124138
diff --git a/src/util/os_misc.c b/src/util/os_misc.c
125139
index 31f1c55..cd3e2c7 100644
126140
--- a/src/util/os_misc.c
@@ -201,5 +215,5 @@ index 013e8be..a30eada 100644
201215
clockid_t cid;
202216

203217
--
204-
2.38.1
218+
2.39.1
205219

patches/mlibc/mlibc.patch

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
From adcc64e89eb5e570e6ad2bc578fd8b891ee6bd9a Mon Sep 17 00:00:00 2001
1+
From bf4093ec8e528fb9ebcb248d467784e3ecce47cb Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <[email protected]>
3-
Date: Fri, 17 Feb 2023 19:21:05 +1100
3+
Date: Sat, 18 Feb 2023 14:53:00 +1100
44
Subject: [PATCH] <xxx>
55

66
---
77
.gitignore | 2 +
88
options/ansi/generic/stdlib-stubs.cpp | 185 ++++++++++++++++++++++++--
9+
options/ansi/meson.build | 1 +
910
options/glibc/generic/execinfo.cpp | 5 +-
10-
options/posix/generic/dlfcn-stubs.cpp | 1 +
1111
options/rtdl/generic/linker.cpp | 2 +-
12-
sysdeps/aero/generic/aero.cpp | 69 ++++++----
12+
sysdeps/aero/generic/aero.cpp | 77 +++++++----
1313
sysdeps/aero/generic/filesystem.cpp | 51 ++++++-
1414
sysdeps/aero/generic/sockets.cpp | 87 +++++++++++-
1515
sysdeps/aero/generic/time.cpp | 24 ++++
16-
sysdeps/aero/include/aero/syscall.h | 9 ++
16+
sysdeps/aero/include/aero/syscall.h | 10 ++
1717
sysdeps/aero/meson.build | 1 +
18-
11 files changed, 389 insertions(+), 47 deletions(-)
18+
11 files changed, 398 insertions(+), 47 deletions(-)
1919
create mode 100644 sysdeps/aero/generic/time.cpp
2020

2121
diff --git a/.gitignore b/.gitignore
@@ -239,6 +239,18 @@ index c0e54fe..6d9cc52 100644
239239
// TODO: Print PID only if POSIX option is enabled.
240240
if (mlibc::globalConfig().debugMalloc)
241241
mlibc::infoLogger() << "mlibc (PID ?): malloc() returns "
242+
diff --git a/options/ansi/meson.build b/options/ansi/meson.build
243+
index 0820de3..afd8bbe 100644
244+
--- a/options/ansi/meson.build
245+
+++ b/options/ansi/meson.build
246+
@@ -47,6 +47,7 @@ if not no_headers
247+
install_headers(
248+
'include/bits/ansi/timespec.h',
249+
'include/bits/ansi/time_t.h',
250+
+ 'include/bits/ansi/fenv.h',
251+
subdir: 'bits/ansi'
252+
)
253+
endif
242254
diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp
243255
index 3474615..10a2109 100644
244256
--- a/options/glibc/generic/execinfo.cpp
@@ -256,18 +268,6 @@ index 3474615..10a2109 100644
256268
}
257269

258270
char **backtrace_symbols(void *const *, int) {
259-
diff --git a/options/posix/generic/dlfcn-stubs.cpp b/options/posix/generic/dlfcn-stubs.cpp
260-
index fc9fd84..ab57631 100644
261-
--- a/options/posix/generic/dlfcn-stubs.cpp
262-
+++ b/options/posix/generic/dlfcn-stubs.cpp
263-
@@ -27,6 +27,7 @@ char *dlerror(void) {
264-
265-
[[gnu::noinline]]
266-
void *dlopen(const char *file, int flags) {
267-
+ mlibc::infoLogger() << "mlibc memes: " << file << frg::endlog;
268-
auto ra = __builtin_extract_return_addr(__builtin_return_address(0));
269-
return __dlapi_open(file, flags, ra);
270-
}
271271
diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp
272272
index 6eb9d09..2ab5bc9 100644
273273
--- a/options/rtdl/generic/linker.cpp
@@ -282,7 +282,7 @@ index 6eb9d09..2ab5bc9 100644
282282
constexpr bool eagerBinding = true;
283283

284284
diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp
285-
index 29fb961..b5945a8 100644
285+
index 29fb961..31b1a9b 100644
286286
--- a/sysdeps/aero/generic/aero.cpp
287287
+++ b/sysdeps/aero/generic/aero.cpp
288288
@@ -62,29 +62,33 @@ static frg::vector<Slice, MemoryAllocator> create_slice(char *const arg[]) {
@@ -333,7 +333,22 @@ index 29fb961..b5945a8 100644
333333
return 0;
334334
}
335335

336-
@@ -124,7 +128,9 @@ int sys_anon_free(void *pointer, size_t size) {
336+
@@ -114,6 +118,14 @@ int sys_vm_unmap(void *address, size_t size) {
337+
return syscall(SYS_MUNMAP, address, size);
338+
}
339+
340+
+int sys_vm_protect(void *pointer, size_t size, int prot) {
341+
+ auto res = syscall(SYS_MPROTECT, pointer, size, prot);
342+
+ if (res < 0)
343+
+ return -res;
344+
+
345+
+ return 0;
346+
+}
347+
+
348+
int sys_anon_allocate(size_t size, void **pointer) {
349+
return sys_vm_map(nullptr, size, PROT_READ | PROT_WRITE,
350+
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0, pointer);
351+
@@ -124,7 +136,9 @@ int sys_anon_free(void *pointer, size_t size) {
337352
}
338353

339354
void sys_libc_panic() {
@@ -344,7 +359,7 @@ index 29fb961..b5945a8 100644
344359
sys_exit(1);
345360
}
346361

347-
@@ -140,8 +146,15 @@ void sys_exit(int status) {
362+
@@ -140,8 +154,15 @@ void sys_exit(int status) {
348363

349364
pid_t sys_getpid() {
350365
auto result = syscall(SYS_GETPID);
@@ -361,7 +376,7 @@ index 29fb961..b5945a8 100644
361376
return result;
362377
}
363378

364-
@@ -162,11 +175,6 @@ pid_t sys_getpgid(pid_t pid, pid_t *pgid) {
379+
@@ -162,11 +183,6 @@ pid_t sys_getpgid(pid_t pid, pid_t *pgid) {
365380
return 0;
366381
}
367382

@@ -373,7 +388,7 @@ index 29fb961..b5945a8 100644
373388
int sys_clock_get(int clock, time_t *secs, long *nanos) {
374389
struct timespec ts;
375390
auto result = syscall(SYS_GETTIME, clock, &ts);
376-
@@ -233,7 +241,11 @@ uid_t sys_geteuid() {
391+
@@ -233,7 +249,11 @@ uid_t sys_geteuid() {
377392
return 0;
378393
}
379394

@@ -386,7 +401,7 @@ index 29fb961..b5945a8 100644
386401
int sys_seteuid(uid_t euid) UNIMPLEMENTED("sys_seteuid")
387402

388403
gid_t sys_getgid() {
389-
@@ -256,16 +268,19 @@ int sys_setegid(gid_t egid) {
404+
@@ -256,16 +276,19 @@ int sys_setegid(gid_t egid) {
390405
return 0;
391406
}
392407

@@ -633,10 +648,10 @@ index 0000000..460412d
633648
+}
634649
\ No newline at end of file
635650
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
636-
index 12f8dc6..afb45f8 100644
651+
index 12f8dc6..78fc99d 100644
637652
--- a/sysdeps/aero/include/aero/syscall.h
638653
+++ b/sysdeps/aero/include/aero/syscall.h
639-
@@ -64,6 +64,15 @@
654+
@@ -64,6 +64,16 @@
640655
#define SYS_FUTEX_WAIT 57
641656
#define SYS_FUTEX_WAKE 58
642657
#define SYS_LINK 59
@@ -649,6 +664,7 @@ index 12f8dc6..afb45f8 100644
649664
+#define SYS_GETPPID 66
650665
+#define SYS_SOCKET_PAIR 67
651666
+#define SYS_RENAME 68
667+
+#define SYS_MPROTECT 69
652668

653669
// Invalid syscall used to trigger a log error in the kernel (as a hint)
654670
// so, that we can implement the syscall in the kernel.

src/aero_kernel/src/syscall/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ pub fn generic_do_syscall(
234234
SYS_FORK => process::fork(),
235235
SYS_MMAP => process::mmap(b, c, d, e, f, g),
236236
SYS_MUNMAP => process::munmap(b, c),
237+
SYS_MPROTECT => process::mprotect(b, c, d),
237238
SYS_EXEC => process::exec(b, c, d, e, f, g),
238239
SYS_LOG => process::log(b, c),
239240
SYS_UNAME => process::uname(b),

src/aero_kernel/src/syscall/process.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ pub fn munmap(address: usize, size: usize) -> Result<usize, SyscallError> {
216216
}
217217
}
218218

219+
#[syscall]
220+
pub fn mprotect(ptr: usize, size: usize, prot: usize) -> Result<usize, SyscallError> {
221+
let ptr = VirtAddr::new(ptr as _);
222+
let prot = MMapProt::from_bits(prot).ok_or(SyscallError::EINVAL)?;
223+
224+
let task = scheduler::get_scheduler().current_task();
225+
task.vm().mprotect(ptr, size, prot);
226+
227+
Ok(0)
228+
}
229+
219230
#[syscall]
220231
pub fn backtrace() -> Result<usize, SyscallError> {
221232
crate::unwind::unwind_stack_trace();

0 commit comments

Comments
 (0)