Skip to content

Commit d2f49ca

Browse files
committed
Improve mkdeps
Our makefile generator now accepts badly formatted include lines. It's now more hermetic with better error checking in the cosmo repo, and it can be configured to not be hermetic at all.
1 parent 241f949 commit d2f49ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+465
-532
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(
329329
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x)))) $(INCS) $(INCS)
330330
$(file >$@,$(INCS))
331331
o/$(MODE)/depend: o/$(MODE)/.x o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt $(SRCS) $(HDRS) $(INCS)
332-
$(COMPILE) -AMKDEPS -L320 $(MKDEPS) -o $@ -r o/$(MODE)/ @o/$(MODE)/srcs.txt @o/$(MODE)/hdrs.txt @o/$(MODE)/incs.txt
332+
$(COMPILE) -AMKDEPS -L320 $(MKDEPS) -o $@ -s -r o/$(MODE)/ @o/$(MODE)/srcs.txt @o/$(MODE)/hdrs.txt @o/$(MODE)/incs.txt
333333

334334
o/$(MODE)/srcs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
335335
$(file >$@) $(foreach x,$(SRCS),$(file >>$@,$(x)))

bin/fatcosmocc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ NEED_JOIN=
240240
NEED_EQUAL=
241241
NEED_OUTPUT=
242242
APELINKFLAGS=
243+
FLAGS_X86_64=
244+
FLAGS_AARCH64=
243245
INPUT_FILE_COUNT=0
244246
for x; do
245247
if [ x"$x" != x"${x#* }" ]; then
@@ -335,6 +337,14 @@ for x; do
335337
continue
336338
elif [ x"$x" = x"-march=native" ]; then
337339
fatal_error "-march=native can't be used when building fat binaries"
340+
elif [ x"$x" != x"${x#-Xx86_64}" ]; then
341+
x=${x#-Xx86_64} # e.g. -Xx86_64,-msse3,-mavx,-mavx2,-mf16c,-mfma
342+
FLAGS_X86_64="$FLAGS_X86_64 ${x//,/ }"
343+
continue
344+
elif [ x"$x" != x"${x#-Xaarch64}" ]; then
345+
x=${x#-Xaarch64}
346+
FLAGS_aarch64="$FLAGS_aarch64 ${x//,/ }"
347+
continue
338348
elif [ x"$x" = x"-dumpversion" ]; then
339349
echo $GCC_VERSION
340350
Exit 0
@@ -473,6 +483,7 @@ build_object() {
473483
$CFLAGS_X86_64 \
474484
$CPPFLAGS_X86_64 \
475485
"$@" \
486+
$FLAGS_X86_64 \
476487
$PRECIOUS
477488
log_command "$@"
478489
"$@" || exit
@@ -492,6 +503,7 @@ build_object() {
492503
$CFLAGS_AARCH64 \
493504
$CPPFLAGS_AARCH64 \
494505
"$@" \
506+
$FLAGS_AARCH64 \
495507
$PRECIOUS &&
496508
log_command "$@"
497509
"$@" || exit

build/bootstrap/mkdeps.com

35.3 KB
Binary file not shown.

libc/calls/getrlimit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "libc/intrin/asan.internal.h"
2424
#include "libc/intrin/describeflags.internal.h"
2525
#include "libc/intrin/strace.internal.h"
26+
#include "libc/runtime/runtime.h"
2627
#include "libc/runtime/stack.h"
2728
#include "libc/runtime/syslib.internal.h"
2829
#include "libc/sysv/consts/rlimit.h"

libc/calls/internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ int64_t GetConsoleOutputHandle(void);
3131
int IsWindowsExecutable(int64_t, const char16_t *);
3232
void InterceptTerminalCommands(const char *, size_t);
3333

34-
forceinline int64_t __getfdhandleactual(int fd) {
35-
return g_fds.p[fd].handle;
36-
}
37-
3834
forceinline bool __isfdopen(int fd) {
3935
return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind != kFdEmpty;
4036
}

libc/calls/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static int ioctl_default(int fd, unsigned long request, void *arg) {
7575
return sys_ioctl(fd, request, arg);
7676
} else if (__isfdopen(fd)) {
7777
if (g_fds.p[fd].kind == kFdSocket) {
78-
handle = __getfdhandleactual(fd);
78+
handle = g_fds.p[fd].handle;
7979
if ((rc = _weaken(__sys_ioctlsocket_nt)(handle, request, arg)) != -1) {
8080
return rc;
8181
} else {

libc/calls/ischardev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ bool32 ischardev(int fd) {
5656
} else {
5757
return __isfdkind(fd, kFdConsole) || __isfdkind(fd, kFdDevNull) ||
5858
(__isfdkind(fd, kFdFile) &&
59-
GetFileType(__getfdhandleactual(fd)) == kNtFileTypeChar);
59+
GetFileType(g_fds.p[fd].handle) == kNtFileTypeChar);
6060
}
6161
}

libc/calls/pthread_yield.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/calls/calls.h"
2020
#include "libc/dce.h"
21-
#include "libc/nexgen32e/yield.h"
2221
#include "libc/runtime/runtime.h"
2322
#include "libc/runtime/syslib.internal.h"
2423
#include "libc/thread/thread.h"
@@ -32,7 +31,7 @@ int pthread_yield(void) {
3231
if (IsXnuSilicon()) {
3332
__syslib->__pthread_yield_np();
3433
} else if (IsOpenbsd()) {
35-
spin_yield(); // sched_yield() is punishingly slow on OpenBSD
34+
pthread_pause_np(); // sched_yield() is punishingly slow on OpenBSD
3635
} else {
3736
sched_yield();
3837
}

libc/calls/read-nt.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct Keystrokes {
142142

143143
static struct Keystrokes __keystroke;
144144

145-
textwindows void __keystroke_wipe(void) {
145+
textwindows void WipeKeystrokes(void) {
146146
bzero(&__keystroke, sizeof(__keystroke));
147147
}
148148

@@ -754,8 +754,8 @@ static textwindows ssize_t ReadFromConsole(struct Fd *f, void *data,
754754
return rc;
755755
}
756756

757-
textwindows ssize_t sys_read_nt_impl(int fd, void *data, size_t size,
758-
int64_t offset, sigset_t waitmask) {
757+
textwindows ssize_t ReadBuffer(int fd, void *data, size_t size, int64_t offset,
758+
sigset_t waitmask) {
759759

760760
// switch to terminal polyfill if reading from win32 console
761761
struct Fd *f = g_fds.p + fd;
@@ -786,18 +786,18 @@ textwindows ssize_t sys_read_nt_impl(int fd, void *data, size_t size,
786786
}
787787
}
788788

789-
static textwindows ssize_t sys_read_nt2(int fd, const struct iovec *iov,
790-
size_t iovlen, int64_t opt_offset,
791-
sigset_t waitmask) {
789+
static textwindows ssize_t ReadIovecs(int fd, const struct iovec *iov,
790+
size_t iovlen, int64_t opt_offset,
791+
sigset_t waitmask) {
792792
ssize_t rc;
793793
size_t i, total;
794794
if (opt_offset < -1) return einval();
795795
while (iovlen && !iov[0].iov_len) iov++, iovlen--;
796796
if (iovlen) {
797797
for (total = i = 0; i < iovlen; ++i) {
798798
if (!iov[i].iov_len) continue;
799-
rc = sys_read_nt_impl(fd, iov[i].iov_base, iov[i].iov_len, opt_offset,
800-
waitmask);
799+
rc =
800+
ReadBuffer(fd, iov[i].iov_base, iov[i].iov_len, opt_offset, waitmask);
801801
if (rc == -1) {
802802
if (total && errno != ECANCELED) {
803803
return total;
@@ -811,15 +811,15 @@ static textwindows ssize_t sys_read_nt2(int fd, const struct iovec *iov,
811811
}
812812
return total;
813813
} else {
814-
return sys_read_nt_impl(fd, NULL, 0, opt_offset, waitmask);
814+
return ReadBuffer(fd, NULL, 0, opt_offset, waitmask);
815815
}
816816
}
817817

818818
textwindows ssize_t sys_read_nt(int fd, const struct iovec *iov, size_t iovlen,
819819
int64_t opt_offset) {
820820
ssize_t rc;
821821
sigset_t m = __sig_block();
822-
rc = sys_read_nt2(fd, iov, iovlen, opt_offset, m);
822+
rc = ReadIovecs(fd, iov, iovlen, opt_offset, m);
823823
__sig_unblock(m);
824824
return rc;
825825
}

libc/calls/setrlimit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "libc/intrin/describeflags.internal.h"
2626
#include "libc/intrin/strace.internal.h"
2727
#include "libc/macros.internal.h"
28+
#include "libc/runtime/runtime.h"
2829
#include "libc/runtime/syslib.internal.h"
2930
#include "libc/sysv/consts/rlimit.h"
3031
#include "libc/sysv/errfuns.h"

0 commit comments

Comments
 (0)