mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 14:09:12 +00:00
Improve build system
- Reduce full build latency from ~20s to ~18s - Bring back silent mode if `make V=0` is passed - Demodernize utimes() polyfill so it works RHEL5 - Delete some old shell scripts that are no longer needed - Truncate long lines when outputting builds to Emacs buffers
This commit is contained in:
parent
c797f139bb
commit
b740cca642
39 changed files with 440 additions and 916 deletions
|
@ -263,6 +263,7 @@ int sys_sync_nt(void) hidden;
|
|||
int sys_sysinfo_nt(struct sysinfo *) hidden;
|
||||
int sys_truncate_nt(const char *, u64) hidden;
|
||||
int sys_unlinkat_nt(int, const char *, int) hidden;
|
||||
int sys_utimes_nt(const char *, const struct timeval[2]) hidden;
|
||||
int sys_utimensat_nt(int, const char *, const struct timespec *, int) hidden;
|
||||
ssize_t sys_open_nt(int, const char *, u32, i32) nodiscard hidden;
|
||||
ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden;
|
||||
|
|
33
libc/calls/sys_utimes_nt.c
Normal file
33
libc/calls/sys_utimes_nt.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
textwindows int sys_utimes_nt(const char *path, const struct timeval tv[2]) {
|
||||
struct timespec ts[2];
|
||||
if (tv) {
|
||||
ts[0].tv_sec = tv[0].tv_sec;
|
||||
ts[0].tv_nsec = tv[0].tv_usec * 1000;
|
||||
ts[1].tv_sec = tv[1].tv_sec;
|
||||
ts[1].tv_nsec = tv[1].tv_usec * 1000;
|
||||
return sys_utimensat_nt(AT_FDCWD, path, ts, 0);
|
||||
} else {
|
||||
return sys_utimensat_nt(AT_FDCWD, path, NULL, 0);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
/**
|
||||
* Creates new file or changes modified time on existing one.
|
||||
|
@ -28,7 +30,12 @@
|
|||
* @see creat()
|
||||
*/
|
||||
int touch(const char *file, uint32_t mode) {
|
||||
int fd;
|
||||
if ((fd = open(file, O_CREAT | O_WRONLY, mode)) == -1) return -1;
|
||||
return close(fd);
|
||||
int rc, fd, olderr;
|
||||
olderr = errno;
|
||||
if ((rc = utimes(file, NULL)) == -1 && errno == ENOENT) {
|
||||
errno = olderr;
|
||||
if ((fd = open(file, O_CREAT | O_WRONLY, mode)) == -1) return -1;
|
||||
return close(fd);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -26,16 +26,17 @@
|
|||
*
|
||||
* @param times if NULL means now
|
||||
* @return 0 on success or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int utime(const char *path, const struct utimbuf *times) {
|
||||
struct timespec ts[2];
|
||||
struct timeval tv[2];
|
||||
if (times) {
|
||||
ts[0].tv_sec = times->actime;
|
||||
ts[0].tv_nsec = 0;
|
||||
ts[1].tv_sec = times->modtime;
|
||||
ts[1].tv_nsec = 0;
|
||||
return utimensat(AT_FDCWD, path, ts, 0);
|
||||
tv[0].tv_sec = times->actime;
|
||||
tv[0].tv_usec = 0;
|
||||
tv[1].tv_sec = times->modtime;
|
||||
tv[1].tv_usec = 0;
|
||||
return utimes(path, tv);
|
||||
} else {
|
||||
return utimensat(AT_FDCWD, path, NULL, 0);
|
||||
return utimes(path, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "libc/time/time.h"
|
||||
|
||||
textwindows int sys_utimensat_nt(int dirfd, const char *path,
|
||||
const struct timespec ts[2], int flags) {
|
||||
const struct timespec ts[2], int flags) {
|
||||
int i, rc;
|
||||
int64_t fh;
|
||||
uint16_t path16[PATH_MAX];
|
||||
|
|
|
@ -17,12 +17,33 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
#define __NR_utimensat_linux 0x118 /*RHEL5:CVE-2010-3301*/
|
||||
|
||||
int sys_utimensat(int dirfd, const char *path, const struct timespec ts[2],
|
||||
int flags) {
|
||||
int rc, olderr;
|
||||
struct timeval tv[2];
|
||||
if (!IsXnu()) {
|
||||
return __sys_utimensat(dirfd, path, ts, flags);
|
||||
olderr = errno;
|
||||
rc = __sys_utimensat(dirfd, path, ts, flags);
|
||||
if (((rc == -1 && errno == ENOSYS) || rc == __NR_utimensat_linux) &&
|
||||
dirfd == AT_FDCWD && !flags) {
|
||||
errno = olderr;
|
||||
if (ts) {
|
||||
tv[0].tv_sec = ts[0].tv_sec;
|
||||
tv[0].tv_usec = ts[0].tv_nsec / 1000;
|
||||
tv[1].tv_sec = ts[1].tv_sec;
|
||||
tv[1].tv_usec = ts[1].tv_nsec / 1000;
|
||||
rc = sys_utimes(path, tv);
|
||||
} else {
|
||||
rc = sys_utimes(path, NULL);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
} else {
|
||||
return sys_utimensat_xnu(dirfd, path, ts, flags);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
*
|
||||
* @param ts is atime/mtime, or null for current time
|
||||
* @param flags can have AT_SYMLINK_NOFOLLOW
|
||||
* @note no rhel5 support
|
||||
* @note no xnu/rhel5 support if dirfd≠AT_FDCWD∨flags≠0
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int utimensat(int dirfd, const char *path,
|
||||
const struct timespec ts[hasatleast 2], int flags) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
|
@ -24,17 +26,17 @@
|
|||
*
|
||||
* @param times is access/modified and NULL means now
|
||||
* @return 0 on success or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @see stat()
|
||||
*/
|
||||
int utimes(const char *path, const struct timeval tv[hasatleast 2]) {
|
||||
struct timespec ts[2];
|
||||
if (tv) {
|
||||
ts[0].tv_sec = tv[0].tv_sec;
|
||||
ts[0].tv_nsec = tv[0].tv_usec * 1000;
|
||||
ts[1].tv_sec = tv[1].tv_sec;
|
||||
ts[1].tv_nsec = tv[1].tv_usec * 1000;
|
||||
return utimensat(AT_FDCWD, path, ts, 0);
|
||||
int utimes(const char *path, const struct timeval tv[2]) {
|
||||
if (!IsWindows()) {
|
||||
/*
|
||||
* we don't modernize utimes() into utimensat() because the
|
||||
* latter is poorly supported and utimes() works everywhere
|
||||
*/
|
||||
return sys_utimes(path, tv);
|
||||
} else {
|
||||
return utimensat(AT_FDCWD, path, NULL, 0);
|
||||
return sys_utimes_nt(path, tv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,8 +151,6 @@ $(LIBC_NT_NTDLL_A): \
|
|||
libc/nt/ntdll/ \
|
||||
$(LIBC_NT_NTDLL_A).pkg \
|
||||
$(LIBC_NT_NTDLL_A_OBJS)
|
||||
@$(file >$@.cmd) $(file >>$@.cmd,$(ARCHIVE) $@ $^ >$(LIBC_NT_NTDLL_A).cmd)
|
||||
@$(ARCHIVE) $@ $^
|
||||
|
||||
$(LIBC_NT_NTDLL_A).pkg: \
|
||||
$(LIBC_NT_NTDLL_A_OBJS) \
|
||||
|
|
|
@ -61,31 +61,25 @@ o/$(MODE)/libc/unicode: $(LIBC_UNICODE) $(LIBC_UNICODE_CHECKS)
|
|||
o/$(MODE)/libc/unicode/eastasianwidth.bin: \
|
||||
libc/unicode/eastasianwidth.txt \
|
||||
o/$(MODE)/tool/decode/mkwides.com
|
||||
@TARGET=$@ ACTION=MKWIDES build/do \
|
||||
o/$(MODE)/tool/decode/mkwides.com -o $@ $<
|
||||
@$(COMPILE) -AMKWIDES -T$@ o/$(MODE)/tool/decode/mkwides.com -o $@ $<
|
||||
o/$(MODE)/libc/unicode/eastasianwidth.bin.lz4: \
|
||||
o/$(MODE)/libc/unicode/eastasianwidth.bin \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com
|
||||
@TARGET=$@ ACTION=LZ4 build/do \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
@$(COMPILE) -ALZ4 -T$@ o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
o/$(MODE)/libc/unicode/eastasianwidth.s: \
|
||||
o/$(MODE)/libc/unicode/eastasianwidth.bin.lz4 \
|
||||
o/$(MODE)/tool/build/lz4toasm.com
|
||||
@TARGET=$@ ACTION=BIN2ASM build/do \
|
||||
o/$(MODE)/tool/build/lz4toasm.com -s kEastAsianWidth -o $@ $<
|
||||
@$(COMPILE) -ABIN2ASM -T$@ o/$(MODE)/tool/build/lz4toasm.com -s kEastAsianWidth -o $@ $<
|
||||
|
||||
o/$(MODE)/libc/unicode/combiningchars.bin: \
|
||||
libc/unicode/unicodedata.txt \
|
||||
o/$(MODE)/tool/decode/mkcombos.com
|
||||
@TARGET=$@ ACTION=MKCOMBOS build/do \
|
||||
o/$(MODE)/tool/decode/mkcombos.com -o $@ $<
|
||||
@$(COMPILE) -AMKCOMBOS -T$@ o/$(MODE)/tool/decode/mkcombos.com -o $@ $<
|
||||
o/$(MODE)/libc/unicode/combiningchars.bin.lz4: \
|
||||
o/$(MODE)/libc/unicode/combiningchars.bin \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com
|
||||
@TARGET=$@ ACTION=LZ4 build/do \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
@$(COMPILE) -ALZ4 -T$@ o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
o/$(MODE)/libc/unicode/combiningchars.s: \
|
||||
o/$(MODE)/libc/unicode/combiningchars.bin.lz4 \
|
||||
o/$(MODE)/tool/build/lz4toasm.com
|
||||
@TARGET=$@ ACTION=BIN2ASM build/do \
|
||||
o/$(MODE)/tool/build/lz4toasm.com -s kCombiningChars -o $@ $<
|
||||
@$(COMPILE) -ABIN2ASM -T$@ o/$(MODE)/tool/build/lz4toasm.com -s kCombiningChars -o $@ $<
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue