2020-06-15 14:18:57 +00:00
|
|
|
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
|
|
|
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
|
|
|
|
|
|
|
PKGS += LIBC_INTRIN
|
|
|
|
|
|
|
|
LIBC_INTRIN_ARTIFACTS += LIBC_INTRIN_A
|
|
|
|
LIBC_INTRIN = $(LIBC_INTRIN_A_DEPS) $(LIBC_INTRIN_A)
|
|
|
|
LIBC_INTRIN_A = o/$(MODE)/libc/intrin/intrin.a
|
2023-05-15 08:51:29 +00:00
|
|
|
LIBC_INTRIN_A_FILES := $(wildcard libc/intrin/*)
|
2020-06-15 14:18:57 +00:00
|
|
|
LIBC_INTRIN_A_HDRS = $(filter %.h,$(LIBC_INTRIN_A_FILES))
|
2022-10-17 18:02:04 +00:00
|
|
|
LIBC_INTRIN_A_INCS = $(filter %.inc,$(LIBC_INTRIN_A_FILES))
|
2020-06-15 14:18:57 +00:00
|
|
|
LIBC_INTRIN_A_SRCS_S = $(filter %.S,$(LIBC_INTRIN_A_FILES))
|
|
|
|
LIBC_INTRIN_A_SRCS_C = $(filter %.c,$(LIBC_INTRIN_A_FILES))
|
|
|
|
LIBC_INTRIN_A_SRCS = $(LIBC_INTRIN_A_SRCS_S) $(LIBC_INTRIN_A_SRCS_C)
|
|
|
|
LIBC_INTRIN_A_CHECKS = $(LIBC_INTRIN_A).pkg
|
|
|
|
|
2023-05-15 08:51:29 +00:00
|
|
|
ifeq ($(ARCH), aarch64)
|
|
|
|
LIBC_INTRIN_A_SRCS_S += $(wildcard libc/intrin/aarch64/*.S)
|
2023-06-06 06:35:31 +00:00
|
|
|
LIBC_INTRIN_A_HDRS += libc/intrin/aarch64/asmdefs.internal.h
|
2023-05-15 08:51:29 +00:00
|
|
|
endif
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
LIBC_INTRIN_A_OBJS = \
|
|
|
|
$(LIBC_INTRIN_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
|
|
|
$(LIBC_INTRIN_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
|
|
|
|
|
|
|
LIBC_INTRIN_A_CHECKS = \
|
|
|
|
$(LIBC_INTRIN_A).pkg \
|
|
|
|
$(LIBC_INTRIN_A_HDRS:%=o/$(MODE)/%.ok)
|
|
|
|
|
|
|
|
LIBC_INTRIN_A_DIRECTDEPS = \
|
2021-02-03 14:22:51 +00:00
|
|
|
LIBC_NEXGEN32E \
|
2022-06-26 01:17:31 +00:00
|
|
|
LIBC_NT_KERNEL32 \
|
2023-06-18 07:55:09 +00:00
|
|
|
LIBC_NT_WS2_32 \
|
|
|
|
LIBC_SYSV \
|
|
|
|
LIBC_SYSV_CALLS
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
LIBC_INTRIN_A_DEPS := \
|
|
|
|
$(call uniq,$(foreach x,$(LIBC_INTRIN_A_DIRECTDEPS),$($(x))))
|
|
|
|
|
|
|
|
$(LIBC_INTRIN_A): \
|
|
|
|
libc/intrin/ \
|
|
|
|
$(LIBC_INTRIN_A).pkg \
|
|
|
|
$(LIBC_INTRIN_A_OBJS)
|
|
|
|
|
|
|
|
$(LIBC_INTRIN_A).pkg: \
|
|
|
|
$(LIBC_INTRIN_A_OBJS) \
|
|
|
|
$(foreach x,$(LIBC_INTRIN_A_DIRECTDEPS),$($(x)_A).pkg)
|
|
|
|
|
2022-11-02 05:36:03 +00:00
|
|
|
# we can't use asan because:
|
|
|
|
# __strace_init() calls this before asan is initialized
|
|
|
|
o/$(MODE)/libc/intrin/strace_enabled.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
COPTS += \
|
2022-11-02 05:36:03 +00:00
|
|
|
-fno-sanitize=address
|
|
|
|
|
2022-09-09 23:54:28 +00:00
|
|
|
# we can't use asan because:
|
|
|
|
# asan guard pages haven't been allocated yet
|
|
|
|
o/$(MODE)/libc/intrin/directmap.o \
|
|
|
|
o/$(MODE)/libc/intrin/directmap-nt.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
COPTS += \
|
2022-09-09 23:54:28 +00:00
|
|
|
-ffreestanding \
|
|
|
|
-fno-sanitize=address
|
|
|
|
|
|
|
|
# we want small code size because:
|
|
|
|
# to keep .text.head under 4096 bytes
|
|
|
|
o/$(MODE)/libc/intrin/mman.greg.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
COPTS += \
|
2022-09-09 23:54:28 +00:00
|
|
|
-Os
|
|
|
|
|
2022-05-23 17:15:53 +00:00
|
|
|
# we can't use asan and ubsan because:
|
|
|
|
# this is asan and ubsan
|
2021-05-16 18:16:28 +00:00
|
|
|
o/$(MODE)/libc/intrin/asan.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/ubsan.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2023-06-08 11:37:05 +00:00
|
|
|
-ffreestanding \
|
2021-05-16 18:16:28 +00:00
|
|
|
-fno-sanitize=all \
|
2021-10-14 00:27:13 +00:00
|
|
|
-fno-stack-protector
|
|
|
|
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/asan.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2021-10-14 00:27:13 +00:00
|
|
|
-O2 \
|
|
|
|
-finline \
|
|
|
|
-finline-functions
|
|
|
|
|
2023-05-13 05:42:57 +00:00
|
|
|
o/$(MODE)/libc/intrin/asanthunk.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2023-05-13 05:42:57 +00:00
|
|
|
-x-no-pg \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-sanitize=all \
|
|
|
|
-fno-stack-protector
|
|
|
|
|
2022-05-19 23:57:49 +00:00
|
|
|
# we can't use compiler magic because:
|
|
|
|
# kprintf() is mission critical to error reporting
|
|
|
|
o/$(MODE)/libc/intrin/getmagnumstr.greg.o \
|
|
|
|
o/$(MODE)/libc/intrin/strerrno.greg.o \
|
|
|
|
o/$(MODE)/libc/intrin/strerrdoc.greg.o \
|
|
|
|
o/$(MODE)/libc/intrin/strerror_wr.greg.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/kprintf.greg.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-03-20 15:01:14 +00:00
|
|
|
-fpie \
|
2022-05-19 23:57:49 +00:00
|
|
|
-fwrapv \
|
|
|
|
-x-no-pg \
|
2022-03-20 15:01:14 +00:00
|
|
|
-ffreestanding \
|
2022-05-19 23:57:49 +00:00
|
|
|
-fno-sanitize=all \
|
|
|
|
-fno-stack-protector
|
2022-03-20 15:01:14 +00:00
|
|
|
|
2022-09-05 15:26:03 +00:00
|
|
|
# TODO(jart): Do we really need these?
|
2022-06-12 18:47:20 +00:00
|
|
|
# synchronization primitives are intended to be magic free
|
2022-06-23 17:21:07 +00:00
|
|
|
o/$(MODE)/libc/intrin/futex_wait.o \
|
|
|
|
o/$(MODE)/libc/intrin/futex_wake.o \
|
2022-06-12 18:47:20 +00:00
|
|
|
o/$(MODE)/libc/intrin/gettid.greg.o \
|
|
|
|
o/$(MODE)/libc/intrin/_trylock_debug_4.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/_spinlock_debug_4.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-06-12 18:47:20 +00:00
|
|
|
-fwrapv \
|
|
|
|
-x-no-pg \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-sanitize=all \
|
2022-06-13 02:33:42 +00:00
|
|
|
-mgeneral-regs-only \
|
2022-06-12 18:47:20 +00:00
|
|
|
-fno-stack-protector
|
|
|
|
|
2022-06-16 02:13:47 +00:00
|
|
|
# we can't use asan because:
|
|
|
|
# global gone could be raised
|
|
|
|
o/$(MODE)/libc/intrin/exit.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/restorewintty.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-06-16 02:13:47 +00:00
|
|
|
-fno-sanitize=all
|
|
|
|
|
2023-05-14 16:32:15 +00:00
|
|
|
# we can't use -ftrapv because:
|
|
|
|
# this file implements it
|
|
|
|
o/$(MODE)/libc/intrin/ftrapv.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2023-05-14 16:32:15 +00:00
|
|
|
-ffunction-sections \
|
|
|
|
-ffreestanding \
|
|
|
|
-fwrapv
|
|
|
|
|
2022-06-26 01:17:31 +00:00
|
|
|
# we can't use asan because:
|
|
|
|
# sys_mmap() calls these which sets up shadow memory
|
|
|
|
o/$(MODE)/libc/intrin/describeflags.o \
|
|
|
|
o/$(MODE)/libc/intrin/describeframe.o \
|
|
|
|
o/$(MODE)/libc/intrin/describemapflags.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/describeprotflags.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-06-26 01:17:31 +00:00
|
|
|
-fno-sanitize=address
|
|
|
|
|
2022-04-18 07:01:26 +00:00
|
|
|
o/$(MODE)/libc/intrin/exit1.greg.o \
|
2022-06-26 01:17:31 +00:00
|
|
|
o/$(MODE)/libc/intrin/wsarecv.o \
|
|
|
|
o/$(MODE)/libc/intrin/wsarecvfrom.o \
|
2022-05-18 23:41:29 +00:00
|
|
|
o/$(MODE)/libc/intrin/createfile.o \
|
|
|
|
o/$(MODE)/libc/intrin/reopenfile.o \
|
|
|
|
o/$(MODE)/libc/intrin/deletefile.o \
|
|
|
|
o/$(MODE)/libc/intrin/createpipe.o \
|
|
|
|
o/$(MODE)/libc/intrin/closehandle.o \
|
|
|
|
o/$(MODE)/libc/intrin/openprocess.o \
|
|
|
|
o/$(MODE)/libc/intrin/createthread.o \
|
|
|
|
o/$(MODE)/libc/intrin/findclose.o \
|
|
|
|
o/$(MODE)/libc/intrin/findnextfile.o \
|
|
|
|
o/$(MODE)/libc/intrin/createprocess.o \
|
|
|
|
o/$(MODE)/libc/intrin/findfirstfile.o \
|
|
|
|
o/$(MODE)/libc/intrin/removedirectory.o \
|
|
|
|
o/$(MODE)/libc/intrin/createsymboliclink.o \
|
|
|
|
o/$(MODE)/libc/intrin/createnamedpipe.o \
|
|
|
|
o/$(MODE)/libc/intrin/unmapviewoffile.o \
|
|
|
|
o/$(MODE)/libc/intrin/virtualprotect.o \
|
|
|
|
o/$(MODE)/libc/intrin/flushviewoffile.o \
|
|
|
|
o/$(MODE)/libc/intrin/createdirectory.o \
|
|
|
|
o/$(MODE)/libc/intrin/flushfilebuffers.o \
|
|
|
|
o/$(MODE)/libc/intrin/terminateprocess.o \
|
|
|
|
o/$(MODE)/libc/intrin/getfileattributes.o \
|
|
|
|
o/$(MODE)/libc/intrin/getexitcodeprocess.o \
|
|
|
|
o/$(MODE)/libc/intrin/waitforsingleobject.o \
|
|
|
|
o/$(MODE)/libc/intrin/setcurrentdirectory.o \
|
|
|
|
o/$(MODE)/libc/intrin/mapviewoffileex.o \
|
|
|
|
o/$(MODE)/libc/intrin/movefileex.o \
|
|
|
|
o/$(MODE)/libc/intrin/mapviewoffileexnuma.o \
|
|
|
|
o/$(MODE)/libc/intrin/createfilemapping.o \
|
|
|
|
o/$(MODE)/libc/intrin/createfilemappingnuma.o \
|
|
|
|
o/$(MODE)/libc/intrin/waitformultipleobjects.o \
|
Support non-blocking i/o across platforms
This change introduces new tests for `O_NONBLOCK` and `SOCK_NONBLOCK` to
confirm that non-blocking i/o is now working on all supported platforms,
including Windows. For example, you can now say on Windows, MacOS, etc.:
socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
To create a non-blocking IPv4 TCP socket. Or you can enable non-blocking
i/o on an existing socket / pipe / etc. file descriptor by calling fcntl
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
This functionality is polyfilled on older Linux kernels too, e.g. RHEL5.
Now that fcntl() support is much better the FIOCLEX / FIONCLEX polyfills
for ioctl() have been removed since they're ugly non-POSIX diameond APIs
This change fixes a weakness in kprintf() that was causing Windows trace
tools to frequently crash.
2023-07-23 09:56:47 +00:00
|
|
|
o/$(MODE)/libc/intrin/wsagetoverlappedresult.o \
|
2022-05-18 23:41:29 +00:00
|
|
|
o/$(MODE)/libc/intrin/generateconsolectrlevent.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/wsawaitformultipleevents.o: private\
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-03-20 15:01:14 +00:00
|
|
|
-Os \
|
2022-05-18 23:41:29 +00:00
|
|
|
-fwrapv \
|
2022-03-20 15:01:14 +00:00
|
|
|
-ffreestanding \
|
2022-05-18 23:41:29 +00:00
|
|
|
-fno-stack-protector \
|
|
|
|
-fno-sanitize=all
|
2022-03-16 20:33:13 +00:00
|
|
|
|
2023-06-08 11:37:05 +00:00
|
|
|
# privileged functions
|
|
|
|
o/$(MODE)/libc/intrin/dos2errno.o \
|
|
|
|
o/$(MODE)/libc/intrin/have_fsgsbase.o \
|
|
|
|
o/$(MODE)/libc/intrin/getmagnumstr.o \
|
|
|
|
o/$(MODE)/libc/intrin/formatint32.o \
|
|
|
|
o/$(MODE)/libc/intrin/strsignal_r.o \
|
|
|
|
o/$(MODE)/libc/intrin/strerror_wr.o: private \
|
|
|
|
CFLAGS += \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-sanitize=all
|
|
|
|
|
2022-08-11 01:00:45 +00:00
|
|
|
o//libc/intrin/memmove.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2021-09-28 05:58:51 +00:00
|
|
|
-fno-toplevel-reorder
|
|
|
|
|
|
|
|
o//libc/intrin/bzero.o \
|
2021-10-02 15:17:04 +00:00
|
|
|
o//libc/intrin/memcmp.o \
|
2021-09-28 05:58:51 +00:00
|
|
|
o//libc/intrin/memset.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o//libc/intrin/memmove.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2022-04-23 01:55:28 +00:00
|
|
|
-O2 -finline
|
2021-09-28 05:58:51 +00:00
|
|
|
|
2021-10-14 00:27:13 +00:00
|
|
|
o/$(MODE)/libc/intrin/bzero.o \
|
|
|
|
o/$(MODE)/libc/intrin/memcmp.o \
|
2022-08-11 01:00:45 +00:00
|
|
|
o/$(MODE)/libc/intrin/memmove.o: private \
|
2023-06-06 06:35:31 +00:00
|
|
|
CFLAGS += \
|
2021-09-28 05:58:51 +00:00
|
|
|
-fpie
|
2020-08-25 11:23:25 +00:00
|
|
|
|
2023-05-02 02:43:59 +00:00
|
|
|
# these assembly files are safe to build on aarch64
|
2023-05-15 08:51:29 +00:00
|
|
|
o/$(MODE)/libc/intrin/aarch64/%.o: libc/intrin/aarch64/%.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-05-03 01:35:25 +00:00
|
|
|
o/$(MODE)/libc/intrin/fenv.o: libc/intrin/fenv.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-06-18 07:55:09 +00:00
|
|
|
o/$(MODE)/libc/intrin/gcov.o: libc/intrin/gcov.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-05-09 15:08:56 +00:00
|
|
|
o/$(MODE)/libc/intrin/futex.o: libc/intrin/futex.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-06-18 07:55:09 +00:00
|
|
|
o/$(MODE)/libc/intrin/typeinfo.o: libc/intrin/typeinfo.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-05-02 02:43:59 +00:00
|
|
|
o/$(MODE)/libc/intrin/kclocknames.o: libc/intrin/kclocknames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-05-02 20:38:16 +00:00
|
|
|
o/$(MODE)/libc/intrin/kdos2errno.o: libc/intrin/kdos2errno.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/kerrnodocs.o: libc/intrin/kerrnodocs.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/kipoptnames.o: libc/intrin/kipoptnames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/kerrnonames.o: libc/intrin/kerrnonames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/kfcntlcmds.o: libc/intrin/kfcntlcmds.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/kopenflags.o: libc/intrin/kopenflags.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/krlimitnames.o: libc/intrin/krlimitnames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/ksignalnames.o: libc/intrin/ksignalnames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/ksockoptnames.o: libc/intrin/ksockoptnames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/ktcpoptnames.o: libc/intrin/ktcpoptnames.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
|
|
|
o/$(MODE)/libc/intrin/sched_yield.o: libc/intrin/sched_yield.S
|
|
|
|
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
2023-05-02 02:43:59 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
LIBC_INTRIN_LIBS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)))
|
|
|
|
LIBC_INTRIN_HDRS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_HDRS))
|
2022-10-17 18:02:04 +00:00
|
|
|
LIBC_INTRIN_INCS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_INCS))
|
2020-06-15 14:18:57 +00:00
|
|
|
LIBC_INTRIN_SRCS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_SRCS))
|
|
|
|
LIBC_INTRIN_CHECKS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_CHECKS))
|
|
|
|
LIBC_INTRIN_OBJS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_OBJS))
|
|
|
|
$(LIBC_INTRIN_OBJS): $(BUILD_FILES) libc/intrin/intrin.mk
|
|
|
|
|
|
|
|
.PHONY: o/$(MODE)/libc/intrin
|
|
|
|
o/$(MODE)/libc/intrin: $(LIBC_INTRIN_CHECKS)
|