Remove plenty of makefile misconfigurations

This commit is contained in:
Justine Tunney 2022-07-21 09:16:38 -07:00
parent 9172fd42a0
commit 8b469389f6
186 changed files with 1408 additions and 901 deletions

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_DCE_H_
#define COSMOPOLITAN_LIBC_DCE_H_
#include "libc/nexgen32e/kcpuids.h"
/*─────────────────────────────────────────────────────────────────────────────╗
cosmopolitan § autotune » dead code elimination
*/

View file

@ -1,4 +1,15 @@
#include "libc/runtime/valist.h"
/* variadic arguments for chibicc */
/* <sync libc/runtime/valist.c> */
struct __va_list {
uint32_t gp_offset;
uint32_t fp_offset;
void *overflow_arg_area;
void *reg_save_area;
};
/* </sync libc/runtime/valist.c> */
void *__va_arg(struct __va_list *, size_t, unsigned, unsigned);
#define __GNUC_VA_LIST 1
#define __gnuc_va_list va_list

View file

@ -34,6 +34,7 @@
#include "libc/mem/mem.h"
#include "libc/nexgen32e/threaded.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/str/path.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
@ -124,7 +125,9 @@ static int unveil_init(void) {
if (errno == EOPNOTSUPP) errno = ENOSYS;
return -1;
}
if (rc < 2) State.fs_mask &= ~LANDLOCK_ACCESS_FS_REFER;
if (rc < 2) {
State.fs_mask &= ~LANDLOCK_ACCESS_FS_REFER;
}
const struct landlock_ruleset_attr attr = {
.handled_access_fs = State.fs_mask,
};
@ -326,6 +329,7 @@ static int sys_unveil_linux(const char *path, const char *permissions) {
* @raise EPERM if unveil() is called after locking
* @note on Linux this function requires Linux Kernel 5.13+
* @see [1] https://docs.kernel.org/userspace-api/landlock.html
* @threadsafe
*/
int unveil(const char *path, const char *permissions) {
int rc;

View file

@ -59,7 +59,16 @@ extern unsigned char __tls_add_nt_rax[];
_Alignas(long) static char __static_tls[5008];
/**
* Enables thread local storage.
* Enables thread local storage for main process.
*
* %fs Linux/BSDs
*
* _Thread_local __get_tls()
*
* pad .tdata .tbss tib
*
*
* Windows/Mac %gs
*
* This function is always called by the core runtime to guarantee TLS
* is always available to your program. You must build your code using
@ -85,19 +94,6 @@ _Alignas(long) static char __static_tls[5008];
* and your `errno` variable also won't be thread safe anymore.
*/
privileged void __enable_tls(void) {
STRACE("__enable_tls()");
// allocate tls memory for main process
//
// %fs Linux/BSDs
// │
// _Thread_local │ __get_tls()
// ┌───┬──────────┬──────────┼───┐
// │pad│ .tdata │ .tbss │tib│
// └───┴──────────┴──────────┼───┘
// │
// Windows/Mac %gs
//
size_t siz;
cthread_t tib;
char *mem, *tls;
@ -179,11 +175,6 @@ privileged void __enable_tls(void) {
//
// 65 48 8b 0R4 25 30 00 00 00 mov %gs:0x30,%R
//
// Whereas on Windows we'll replace it with this:
//
// 0f 1f 40 00 fatnop4
// e8 xx xx xx xx call __tls_mov_nt_%R
//
// Since we have no idea where the TLS instructions exist in the
// binary, we need to disassemble the whole program image. This'll
// potentially take a few milliseconds for some larger programs.
@ -264,6 +255,5 @@ privileged void __enable_tls(void) {
}
// we are now allowed to use tls
// setting this variable
__tls_enabled = true;
}

View file

@ -17,7 +17,15 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
#include "libc/runtime/valist.h"
/* <sync libc/integral/lp64arg.inc> */
struct __va_list {
uint32_t gp_offset;
uint32_t fp_offset;
void *overflow_arg_area;
void *reg_save_area;
};
/* </sync libc/integral/lp64arg.inc> */
static void *__va_arg_mem(struct __va_list *ap, size_t sz, size_t align) {
void *r = (void *)ROUNDUP((intptr_t)ap->overflow_arg_area, align);

View file

@ -1,17 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_RUNTIME_VALIST_H_
#define COSMOPOLITAN_LIBC_RUNTIME_VALIST_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct __va_list {
uint32_t gp_offset;
uint32_t fp_offset;
void *overflow_arg_area;
void *reg_save_area;
};
void *__va_arg(struct __va_list *, size_t, unsigned, unsigned);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RUNTIME_VALIST_H_ */

View file

@ -27,7 +27,6 @@
#include "libc/macros.internal.h"
#include "libc/nt/events.h"
#include "libc/nt/runtime.h"
#include "libc/runtime/valist.h"
#include "libc/sock/sock.h"
#include "libc/sock/syslog.h"
#include "libc/stdio/stdio.h"

View file

@ -24,6 +24,7 @@ LIBC_TESTLIB_A_HDRS = \
libc/testlib/fastrandomstring.h \
libc/testlib/hyperion.h \
libc/testlib/moby.h \
libc/testlib/ugly.h \
libc/testlib/testlib.h
LIBC_TESTLIB_A_SRCS_S = \