remove jemalloc and fall back to libc
completely replacing libc while still supporting all POSIX compliant systems is probably gonna take a little more effort than just one developer. Which is a bummer, but you gotta work with the cards you're dealt, i guess.
This commit is contained in:
parent
a73ea804b5
commit
7eed96edcf
11 changed files with 10 additions and 181 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "contrib/jemalloc"]
|
||||
path = contrib/jemalloc
|
||||
url = https://github.com/jemalloc/jemalloc.git
|
|
@ -13,18 +13,6 @@ endif()
|
|||
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
option(GIT_SUBMODULE "Check submodules during build" ON)
|
||||
if(GIT_SUBMODULE)
|
||||
message(STATUS "Submodule update")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SUBMOD_RESULT
|
||||
)
|
||||
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
||||
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
|
@ -37,8 +25,6 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include(./contrib/jemalloc.cmake)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
add_subdirectory(demo)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756
|
|
@ -1,35 +0,0 @@
|
|||
# See the end of this file for copyright and license terms.
|
||||
|
||||
set(JEMALLOC_SRCDIR "${CMAKE_SOURCE_DIR}/contrib/jemalloc")
|
||||
set(JEMALLOC_PREFIX "${CMAKE_BINARY_DIR}/contrib/jemalloc")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
libjemalloc
|
||||
SOURCE_DIR ${JEMALLOC_SRCDIR}
|
||||
TMP_DIR ${JEMALLOC_PREFIX}
|
||||
STAMP_DIR ${JEMALLOC_PREFIX}
|
||||
CONFIGURE_COMMAND ${JEMALLOC_SRCDIR}/autogen.sh --without-export --enable-static --disable-cxx --srcdir ${JEMALLOC_SRCDIR} --prefix=${JEMALLOC_PREFIX} --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
|
||||
PREFIX ${JEMALLOC_SRCDIR}
|
||||
BUILD_COMMAND make build_lib_static
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_BYPRODUCTS ${JEMALLOC_PREFIX}/lib/libjemalloc.a
|
||||
)
|
||||
|
||||
add_library(jemalloc STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(jemalloc libjemalloc)
|
||||
set_property(
|
||||
TARGET jemalloc
|
||||
PROPERTY IMPORTED_LOCATION ${JEMALLOC_PREFIX}/lib/libjemalloc.a
|
||||
)
|
||||
|
||||
# This file is part of libneo.
|
||||
# Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||
#
|
||||
# libneo is non-violent software: you may only use, redistribute,
|
||||
# and/or modify it under the terms of the CNPLv6+ as found in
|
||||
# the LICENSE file in the source code root directory or at
|
||||
# <https://git.pixie.town/thufie/CNPL>.
|
||||
#
|
||||
# libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
# permitted by applicable law. See the CNPLv6+ for details.
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
add_executable(demo)
|
||||
|
||||
add_compile_options(-nostdlib -nodefaultlibs)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||
|
||||
target_link_libraries(demo PRIVATE neo)
|
||||
|
||||
target_sources(demo PRIVATE
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/** See the end of this file for copyright and license terms. */
|
||||
|
||||
#include "neo.h"
|
||||
#include "neo/_unistd.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
_neo_sys_write(1, "hello, world\n", 14);
|
||||
return 69;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
# See the end of this file for copyright and license terms.
|
||||
|
||||
add_library(neo)
|
||||
add_library(neo STATIC)
|
||||
|
||||
add_compile_options(-nostdlib -nodefaultlibs)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||
add_compile_options(-nodefaultlibs)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
|
||||
target_link_libraries(neo PRIVATE jemalloc)
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE HOST_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(TOLOWER "${HOST_ARCH}" HOST_ARCH)
|
||||
execute_process(COMMAND uname OUTPUT_VARIABLE HOST_OS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(TOLOWER "${HOST_OS}" HOST_OS)
|
||||
|
||||
set(TARGET_ARCH "${HOST_ARCH}" CACHE STRING "Target architecture")
|
||||
set(TARGET_OS "${HOST_OS}" CACHE STRING "Target operating system")
|
||||
|
||||
configure_file(
|
||||
./include/neo/buildconfig.h.in
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
target_sources(neo PRIVATE
|
||||
arch/${TARGET_ARCH}/syscall_${TARGET_OS}.S
|
||||
)
|
|
@ -1,46 +0,0 @@
|
|||
/** See the end of this file for copyright and license terms. */
|
||||
|
||||
.global _neo_syscall
|
||||
|
||||
/*
|
||||
* long _neo_syscall(long number, ...);
|
||||
*
|
||||
* We just want to get stuff working for now, therefore we don't care
|
||||
* about efficiency and just always copy all 6 arguments to the
|
||||
* respective registers and hope Linux just ignores them lmao
|
||||
*
|
||||
* SysV ABI -> Linux syscall
|
||||
* -----------------------------
|
||||
* 1. %rdi -> %rax (number)
|
||||
* 2. %rsi -> %rdi (arg1)
|
||||
* 3. %rdx -> %rsi (arg2)
|
||||
* 4. %rcx -> %rdx (arg3)
|
||||
* 5. %r8 -> %r10 (arg4)
|
||||
* 6. %r9 -> %r8 (arg5)
|
||||
* 7. stack -> %r9 (arg6)
|
||||
*/
|
||||
_neo_syscall:
|
||||
mov %rdi, %rax
|
||||
mov %rsi, %rdi
|
||||
mov %rdx, %rsi
|
||||
mov %rcx, %rdx
|
||||
mov %r8, %r10
|
||||
mov %r9, %r8
|
||||
mov (%rsp), %r9
|
||||
syscall
|
||||
ret /* result is already in %rax */
|
||||
.size _neo_syscall,.-_neo_syscall
|
||||
.type _neo_syscall,function
|
||||
|
||||
/*
|
||||
* This file is part of libneo.
|
||||
* Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||
*
|
||||
* libneo is non-violent software: you may only use, redistribute,
|
||||
* and/or modify it under the terms of the CNPLv6+ as found in
|
||||
* the LICENSE file in the source code root directory or at
|
||||
* <https://git.pixie.town/thufie/CNPL>.
|
||||
*
|
||||
* libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPLv6+ for details.
|
||||
*/
|
40
src/entry.c
40
src/entry.c
|
@ -1,40 +0,0 @@
|
|||
/** See the end of this file for copyright and license terms. */
|
||||
|
||||
#include "neo.h"
|
||||
#include "neo/buildconfig.h"
|
||||
|
||||
extern int main(int argc, char **argv);
|
||||
|
||||
/* this is only temporary to test stuff until i implement syscall() */
|
||||
__attribute__((__noreturn__))
|
||||
static void exit(int code)
|
||||
{
|
||||
register u64 rax __asm__("rax") = 60;
|
||||
register u64 rdi __asm__("rdi") = code;
|
||||
__asm__ __volatile__ (
|
||||
"syscall"
|
||||
: "+r" (rax)
|
||||
: "r" (rdi)
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void _start(void)
|
||||
{
|
||||
int exit_code = main(0, nil);
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of libneo.
|
||||
* Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||
*
|
||||
* libneo is non-violent software: you may only use, redistribute,
|
||||
* and/or modify it under the terms of the CNPLv6+ as found in
|
||||
* the LICENSE file in the source code root directory or at
|
||||
* <https://git.pixie.town/thufie/CNPL>.
|
||||
*
|
||||
* libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPLv6+ for details.
|
||||
*/
|
30
src/unistd.c
30
src/unistd.c
|
@ -1,30 +0,0 @@
|
|||
/** See the end of this file for copyright and license terms. */
|
||||
|
||||
#include "neo.h"
|
||||
#include "neo/_unistd.h"
|
||||
|
||||
/* TODO: get rid of hardcoded syscall numbers */
|
||||
|
||||
isize _neo_sys_write(int fd, const void *buf, usize len)
|
||||
{
|
||||
return _neo_syscall(1, fd, buf, len);
|
||||
}
|
||||
|
||||
void _neo_sys_exit(int status)
|
||||
{
|
||||
_neo_syscall(60, status);
|
||||
while (1); /* should not be reached */
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of libneo.
|
||||
* Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||
*
|
||||
* libneo is non-violent software: you may only use, redistribute,
|
||||
* and/or modify it under the terms of the CNPLv6+ as found in
|
||||
* the LICENSE file in the source code root directory or at
|
||||
* <https://git.pixie.town/thufie/CNPL>.
|
||||
*
|
||||
* libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPLv6+ for details.
|
||||
*/
|
Loading…
Reference in a new issue