Skip to content

Commit

Permalink
Merge pull request #2251 from MagnusS/musl1-2-5
Browse files Browse the repository at this point in the history
Upgrade to latest musl 1.2.5 (via 1.1.24)
  • Loading branch information
alfreb committed Sep 7, 2024
2 parents 392a804 + d5f6bb5 commit 7d7f30d
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 113 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

project (includeos C CXX)

option(SMP "Compile with SMP (multiprocessing)" OFF)
option(SMP "Compile with SMP (multiprocessing)" ON)
option(PROFILE "Compile with startup profilers" OFF)

include(cmake/includeos.cmake)
Expand Down
2 changes: 1 addition & 1 deletion cmake/os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ set(CMAKE_SKIP_RPATH ON)
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")

option(FOR_PRODUCTION "Stop the OS when conditions not suitable for production" ON)
option(FOR_PRODUCTION "Stop the OS when conditions not suitable for production" OFF)
if (FOR_PRODUCTION)
set(PROD_USE "--defsym __for_production_use=0x2000")
else()
Expand Down
16 changes: 6 additions & 10 deletions deps/musl-unpatched/default.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{ nixpkgs ?
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz";
sha256 = "1ndiv385w1qyb3b18vw13991fzb9wg4cl21wglk89grsfsnra41k";
}
, stdenv
, pkgs ? import nixpkgs { config = {}; overlays = []; crossSystem = { config = stdenv.targetPlatform.config; }; }
{
stdenv
, pkgs
, linuxHeaders ? null
}:
stdenv.mkDerivation rec {
pname = "musl-unpatched";
version = "1.1.18";
version = "1.2.5";

src = fetchGit {
url = "git://git.musl-libc.org/musl";
rev = "eb03bde2f24582874cb72b56c7811bf51da0c817";
rev = "0784374d561435f7c787a555aeab8ede699ed298";
};

enableParallelBuilding = true;

configurePhase = ''
echo "Configuring with musl's configure script"
echo "Target platform is ${stdenv.targetPlatform.config}"
./configure --prefix=$out --disable-shared --enable-debug CROSS_COMPILE=${stdenv.targetPlatform.config}-
./configure --prefix=$out --with-malloc=oldmalloc --disable-shared --enable-debug CROSS_COMPILE=${stdenv.targetPlatform.config}-
'';

# Copy linux headers - taken from upstream nixpkgs musl, needed for libcxx to build
Expand Down
16 changes: 6 additions & 10 deletions deps/musl/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
{ nixpkgs ?
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz";
sha256 = "1ndiv385w1qyb3b18vw13991fzb9wg4cl21wglk89grsfsnra41k";
}
, stdenv
, pkgs ? import nixpkgs { config = {}; overlays = []; crossSystem = { config = stdenv.targetPlatform.config; }; }
{
stdenv
, pkgs
, linuxHeaders ? null
}:
stdenv.mkDerivation rec {
pname = "musl-includeos";
version = "1.1.18";
version = "1.2.5";

src = fetchGit {
url = "git://git.musl-libc.org/musl";
rev = "eb03bde2f24582874cb72b56c7811bf51da0c817";
rev = "0784374d561435f7c787a555aeab8ede699ed298";
};

enableParallelBuilding = true;
Expand All @@ -38,7 +34,7 @@ stdenv.mkDerivation rec {
configurePhase = ''
echo "Configuring with musl's configure script"
echo "Target platform is ${stdenv.targetPlatform.config}"
./configure --prefix=$out --disable-shared --enable-debug CROSS_COMPILE=${stdenv.targetPlatform.config}-
./configure --prefix=$out --disable-shared --enable-debug --with-malloc=oldmalloc CROSS_COMPILE=${stdenv.targetPlatform.config}-
'';

CFLAGS = "-Wno-error=int-conversion -nostdinc";
Expand Down
148 changes: 95 additions & 53 deletions deps/musl/patches/includeos_syscalls.h
Original file line number Diff line number Diff line change
@@ -1,52 +1,74 @@
#pragma once

#define __includeos(num, ...) extern long syscall_##num(long,...)
#if !defined(SYS_set_thread_area)
#define SYS_set_thread_area
#endif

extern long syscall_n(long,...);
extern long syscall_SYS_brk(void*);
extern long syscall_SYS_close(long,...);
extern long syscall_SYS_epoll_wait(long,...);
extern long syscall_SYS_exit_group(long,...);
extern long syscall_SYS_exit(long,...);
extern long syscall_SYS_fadvise(long,...);
extern long syscall_SYS_fallocate(long,...);
extern long syscall_SYS_fcntl(long,...);
extern long syscall_SYS_flistxattr(long,...);
#if !defined(SYS_fork)
#define SYS_fork
#endif

#define __includeos(num, ...) extern long syscall_##num()

extern long syscall_n();
extern long syscall_nr();
extern long syscall_SYS_brk();
extern long syscall_SYS_close();
extern long syscall_SYS_copy_file_range();
extern long syscall_SYS_epoll_wait();
extern long syscall_SYS_execveat();
extern long syscall_SYS_exit_group();
extern long syscall_SYS_exit();
extern long syscall_SYS_fadvise();
extern long syscall_SYS_fallocate();
extern long syscall_SYS_fcntl();
extern long syscall_SYS_flistxattr();
extern long syscall_SYS_fork();
extern long syscall_SYS_fremovexattr(long,...);
extern long syscall_SYS_fsetxattr(long,...);
extern long syscall_SYS_futex(long, ...);
extern long syscall_SYS_getdents(long,...);
extern long syscall_SYS_fremovexattr();
extern long syscall_SYS_fsetxattr();
extern long syscall_SYS_futex();
extern long syscall_SYS_futex_time64();
extern long syscall_SYS_get_robust_list();
extern long syscall_SYS_getdents();
extern long syscall_SYS_getegid();
extern long syscall_SYS_geteuid();
extern long syscall_SYS_getgid();
extern long syscall_SYS_getpid();
extern long syscall_SYS_getppid();
extern long syscall_SYS_getrandom();
extern long syscall_SYS_gettid();
extern long syscall_SYS_getuid();
extern long syscall_SYS_inotify_init();
extern long syscall_SYS_ioctl(long, long, long, ...);
extern long syscall_SYS_lremovexattr(long,...);
extern long syscall_SYS_mmap2(long,...);
extern long syscall_SYS_msgctl(long,...);
extern long syscall_SYS_msgget(long,...);
extern long syscall_SYS_ioctl();
extern long syscall_SYS_lremovexattr();
extern long syscall_SYS_membarrier();
extern long syscall_SYS_memfd_create();
extern long syscall_SYS_mmap2();
extern long syscall_SYS_mlock2();
extern long syscall_SYS_msgctl();
extern long syscall_SYS_msgget();
extern long syscall_SYS_munlockall();
extern long syscall_SYS_name_to_handle_at();
extern long syscall_SYS_open_by_handle_at();
extern long syscall_SYS_pause();
extern long syscall_SYS_poll(long,...);
extern long syscall_SYS_removexattr(long,...);
extern long syscall_SYS_rt_sigqueueinfo(long, ...);
extern long syscall_SYS_sched_getaffinity(long, ...);
extern long syscall_SYS_poll();
extern long syscall_SYS_ppoll();
extern long syscall_SYS_ppoll_time64();
extern long syscall_SYS_removexattr();
extern long syscall_SYS_rt_sigqueueinfo();
extern long syscall_SYS_sched_getaffinity();
extern long syscall_SYS_sched_yield();
extern long syscall_SYS_semctl(long,...);
extern long syscall_SYS_semget(long,...);
extern long syscall_SYS_semop(long,...);
extern long syscall_SYS_semtimedop(long,...);
extern long syscall_SYS_semctl();
extern long syscall_SYS_semget();
extern long syscall_SYS_semop();
extern long syscall_SYS_semtimedop();
extern long syscall_SYS_semtimedop_time64();
extern long syscall_SYS_setsid();
extern long syscall_SYS_set_tid_address(long,...);
extern long syscall_SYS_shmat(long,...);
extern long syscall_SYS_set_tid_address();
extern long syscall_SYS_shmat();
extern long syscall_SYS_sync();
extern long syscall_SYS_vhangup();
extern int syscall_SYS_open(const char *path, int oflag, ... );
extern int syscall_SYS_open(const char *path, int oflag, ...);

__includeos(SYS_access);
__includeos(SYS_acct);
Expand All @@ -59,10 +81,14 @@ __includeos(SYS_chmod);
__includeos(SYS_chown);
__includeos(SYS_chroot);
__includeos(SYS_clock_adjtime);
__includeos(SYS_clock_adjtime64);
__includeos(SYS_clock_getres);
__includeos(SYS_clock_gettime);
__includeos(SYS_clock_gettime64);
__includeos(SYS_clock_nanosleep);
__includeos(SYS_clock_nanosleep_time64);
__includeos(SYS_clock_settime);
__includeos(SYS_clock_settime64);
__includeos(SYS_delete_module);
__includeos(SYS_dup);
__includeos(SYS_dup2);
Expand All @@ -75,11 +101,13 @@ __includeos(SYS_eventfd);
__includeos(SYS_eventfd2);
__includeos(SYS_execve);
__includeos(SYS_faccessat);
__includeos(SYS_faccessat2);
__includeos(SYS_fanotify_init);
__includeos(SYS_fanotify_mark);
__includeos(SYS_fchdir);
__includeos(SYS_fchmod);
__includeos(SYS_fchmodat);
__includeos(SYS_fchmodat2);
__includeos(SYS_fchown);
__includeos(SYS_fchownat);
__includeos(SYS_fdatasync);
Expand Down Expand Up @@ -140,6 +168,8 @@ __includeos(SYS_mq_notify);
__includeos(SYS_mq_open);
__includeos(SYS_mq_timedreceive);
__includeos(SYS_mq_timedsend);
__includeos(SYS_mq_timedreceive_time64);
__includeos(SYS_mq_timedsend_time64);
__includeos(SYS_mq_unlink);
__includeos(SYS_mremap);
__includeos(SYS_msgrcv);
Expand All @@ -158,13 +188,16 @@ __includeos(SYS_ppoll);
__includeos(SYS_prctl);
__includeos(SYS_pread);
__includeos(SYS_preadv);
__includeos(SYS_preadv2);
__includeos(SYS_prlimit64);
__includeos(SYS_process_vm_readv);
__includeos(SYS_process_vm_writev);
__includeos(SYS_pselect6);
__includeos(SYS_pselect6_time64);
__includeos(SYS_ptrace);
__includeos(SYS_pwrite);
__includeos(SYS_pwritev);
__includeos(SYS_pwritev2);
__includeos(SYS_quotactl);
__includeos(SYS_read);
__includeos(SYS_readahead);
Expand All @@ -181,6 +214,7 @@ __includeos(SYS_rt_sigpending);
__includeos(SYS_rt_sigprocmask);
__includeos(SYS_rt_sigsuspend);
__includeos(SYS_rt_sigtimedwait);
__includeos(SYS_rt_sigtimedwait_time64);
__includeos(SYS_sched_getparam);
__includeos(SYS_sched_get_priority_max);
__includeos(SYS_sched_get_priority_min);
Expand All @@ -191,6 +225,7 @@ __includeos(SYS_sched_setparam);
__includeos(SYS_sched_setscheduler);
__includeos(SYS_select);
__includeos(SYS_sendfile);
__includeos(SYS_set_thread_area);
__includeos(SYS_setdomainname);
__includeos(SYS_setfsgid);
__includeos(SYS_setfsuid);
Expand All @@ -217,6 +252,7 @@ __includeos(SYS_signalfd4);
__includeos(SYS_socketcall);
__includeos(SYS_splice);
__includeos(SYS_stat);
__includeos(SYS_statx);
__includeos(SYS_statfs);
__includeos(SYS_statfs64);
__includeos(SYS_swapoff);
Expand All @@ -234,9 +270,13 @@ __includeos(SYS_timer_delete);
__includeos(SYS_timerfd_create);
__includeos(SYS_timerfd_gettime);
__includeos(SYS_timerfd_settime);
__includeos(SYS_timerfd_gettime64);
__includeos(SYS_timerfd_settime64);
__includeos(SYS_timer_getoverrun);
__includeos(SYS_timer_gettime);
__includeos(SYS_timer_gettime64);
__includeos(SYS_timer_settime);
__includeos(SYS_timer_settime64);
__includeos(SYS_times);
__includeos(SYS_tkill);
__includeos(SYS_truncate);
Expand All @@ -247,32 +287,34 @@ __includeos(SYS_unlink);
__includeos(SYS_unlinkat);
__includeos(SYS_unshare);
__includeos(SYS_utimensat);
__includeos(SYS_utimensat_time64);
__includeos(SYS_utimes);
__includeos(SYS_vmsplice);
__includeos(SYS_wait4);
__includeos(SYS_waitid);
__includeos(SYS_write);
__includeos(SYS_writev);

int socketcall_socket(int,...);
int socketcall_bind(int,...);
int socketcall_connect(int,...);
int socketcall_listen(int,...);
int socketcall_accept(int,...);
int socketcall_getsockname(int,...);
int socketcall_getpeername(int,...);
int socketcall_socketpair(int,...);
int socketcall_send(int,...);
int socketcall_recv(int,...);
int socketcall_sendto(int,...);
int socketcall_recvfrom(int,...);
int socketcall_shutdown(int,...);
int socketcall_setsockopt(int,...);
int socketcall_getsockopt(int,...);
int socketcall_sendmsg(int,...);
int socketcall_recvmsg(int,...);
int socketcall_accept4(int,...);
int socketcall_recvmmsg(int,...);
int syscall_SYS_recvmmsg(int,...);
int syscall_SYS_sendmmsg(int,...);
//int socketcall_sendmmsg(int,...);
int socketcall_socket();
int socketcall_bind();
int socketcall_connect();
int socketcall_listen();
int socketcall_accept();
int socketcall_getsockname();
int socketcall_getpeername();
int socketcall_socketpair();
int socketcall_send();
int socketcall_recv();
int socketcall_sendto();
int socketcall_recvfrom();
int socketcall_shutdown();
int socketcall_setsockopt();
int socketcall_getsockopt();
int socketcall_sendmsg();
int socketcall_recvmsg();
int socketcall_accept4();
int socketcall_recvmmsg();
int syscall_SYS_recvmmsg();
int syscall_SYS_sendmmsg();
int syscall_SYS_recvmmsg_time64();
//int socketcall_sendmmsg();
Loading

0 comments on commit 7d7f30d

Please sign in to comment.