diff options
Diffstat (limited to 'build')
-rw-r--r-- | build/config.mk | 14 | ||||
-rw-r--r-- | build/flags.mk | 28 | ||||
-rw-r--r-- | build/flags/pthread.c | 8 | ||||
-rw-r--r-- | build/has/dprintf.c | 8 | ||||
-rw-r--r-- | build/has/pragma-nounroll.c | 10 | ||||
-rw-r--r-- | build/has/pthread-set-name-np.c | 10 | ||||
-rw-r--r-- | build/has/pthread-setname-np.c | 8 | ||||
-rw-r--r-- | build/has/sched-getaffinity.c | 9 | ||||
-rw-r--r-- | build/has/tcsetwinsize.c | 9 | ||||
-rw-r--r-- | build/header.mk | 10 | ||||
-rw-r--r-- | build/pkgs.mk | 2 | ||||
-rw-r--r-- | build/prelude.mk | 8 | ||||
-rwxr-xr-x | build/version.sh | 2 |
13 files changed, 99 insertions, 27 deletions
diff --git a/build/config.mk b/build/config.mk index 6296168..663926c 100644 --- a/build/config.mk +++ b/build/config.mk @@ -7,21 +7,15 @@ include build/prelude.mk include build/exports.mk # All configuration steps -config: gen/config.mk +config: gen/config.mk gen/config.h .PHONY: config -# Makefile fragments generated by `./configure` -MKS := \ - gen/vars.mk \ - gen/flags.mk \ - gen/pkgs.mk - # The main configuration file, which includes the others -gen/config.mk: ${MKS} gen/config.h +gen/config.mk: gen/vars.mk gen/flags.mk gen/pkgs.mk ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ - @printf 'include %s\n' ${MKS} >>$@ - ${VCAT} gen/config.mk + @printf 'include %s\n' $^ >>$@ + ${VCAT} $@ .PHONY: gen/config.mk # Saves the configurable variables diff --git a/build/flags.mk b/build/flags.mk index 2562e03..d6f9499 100644 --- a/build/flags.mk +++ b/build/flags.mk @@ -8,14 +8,16 @@ include gen/vars.mk # Internal flags _CPPFLAGS := -Isrc -Igen -include src/prelude.h -_CFLAGS := -std=c17 -pthread +_CFLAGS := -std=c17 _LDFLAGS := _LDLIBS := # Platform-specific system libraries LDLIBS,DragonFly := -lposix1e +LDLIBS,FreeBSD := -lrt LDLIBS,Linux := -lrt LDLIBS,NetBSD := -lutil +LDLIBS,QNX := -lregex -lsocket LDLIBS,SunOS := -lsec -lsocket -lnsl _LDLIBS += ${LDLIBS,${OS}} @@ -24,30 +26,36 @@ _ASAN := ${TRUTHY,${ASAN}} _LSAN := ${TRUTHY,${LSAN}} _MSAN := ${TRUTHY,${MSAN}} _TSAN := ${TRUTHY,${TSAN}} +_TYSAN := ${TRUTHY,${TYSAN}} _UBSAN := ${TRUTHY,${UBSAN}} _GCOV := ${TRUTHY,${GCOV}} _LINT := ${TRUTHY,${LINT}} _RELEASE := ${TRUTHY,${RELEASE}} +LTO ?= ${RELEASE} +_LTO := ${TRUTHY,${LTO}} + ASAN_CFLAGS,y := -fsanitize=address LSAN_CFLAGS,y := -fsanitize=leak MSAN_CFLAGS,y := -fsanitize=memory -fsanitize-memory-track-origins TSAN_CFLAGS,y := -fsanitize=thread +TYSAN_CFLAGS,y := -fsanitize=type UBSAN_CFLAGS,y := -fsanitize=undefined _CFLAGS += ${ASAN_CFLAGS,${_ASAN}} _CFLAGS += ${LSAN_CFLAGS,${_LSAN}} _CFLAGS += ${MSAN_CFLAGS,${_MSAN}} _CFLAGS += ${TSAN_CFLAGS,${_TSAN}} +_CFLAGS += ${TYSAN_CFLAGS,${_TYSAN}} _CFLAGS += ${UBSAN_CFLAGS,${_UBSAN}} SAN_CFLAGS,y := -fno-sanitize-recover=all -INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_UBSAN}} +INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_TYSAN}${_UBSAN}} SAN := ${NOT,${INSANE}} _CFLAGS += ${SAN_CFLAGS,${SAN}} -# MSAN and TSAN both need all code to be instrumented -YESLIBS := ${NOT,${_MSAN}${_TSAN}} +# MSan, TSan, and TySan need all code to be instrumented +YESLIBS := ${NOT,${_MSAN}${_TSAN}${_TYSAN}} NOLIBS ?= ${NOT,${YESLIBS}} # gcov only intercepts fork()/exec() with -std=gnu* @@ -61,11 +69,14 @@ _CPPFLAGS += ${LINT_CPPFLAGS,${_LINT}} _CFLAGS += ${LINT_CFLAGS,${_LINT}} RELEASE_CPPFLAGS,y := -DNDEBUG -RELEASE_CFLAGS,y := -O3 -flto=auto +RELEASE_CFLAGS,y := -O3 _CPPFLAGS += ${RELEASE_CPPFLAGS,${_RELEASE}} _CFLAGS += ${RELEASE_CFLAGS,${_RELEASE}} +LTO_CFLAGS,y := -flto=auto +_CFLAGS += ${LTO_CFLAGS,${_LTO}} + # Configurable flags CFLAGS ?= -g -Wall @@ -90,7 +101,8 @@ AUTO_FLAGS := \ gen/flags/Wstrict-prototypes.mk \ gen/flags/Wundef-prefix.mk \ gen/flags/bind-now.mk \ - gen/flags/deps.mk + gen/flags/deps.mk \ + gen/flags/pthread.mk gen/flags.mk: ${AUTO_FLAGS} ${MSG} "[ GEN] $@" @@ -101,8 +113,8 @@ gen/flags.mk: ${AUTO_FLAGS} @printf '_LDLIBS := %s\n' "$$XLDLIBS" >>$@ @printf 'NOLIBS := %s\n' "$$XNOLIBS" >>$@ @test "${OS}-${SAN}" != FreeBSD-y || printf 'POSTLINK = elfctl -e +noaslr $$@\n' >>$@ - @cat ${.ALLSRC} >>$@ - @cat ${.ALLSRC:%=%.log} >gen/flags.log + @cat $^ >>$@ + @cat ${^:%=%.log} >gen/flags.log ${VCAT} $@ .PHONY: gen/flags.mk diff --git a/build/flags/pthread.c b/build/flags/pthread.c new file mode 100644 index 0000000..db09aa4 --- /dev/null +++ b/build/flags/pthread.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +/// _CFLAGS += -pthread + +int main(void) { + return 0; +} diff --git a/build/has/dprintf.c b/build/has/dprintf.c new file mode 100644 index 0000000..c206fa3 --- /dev/null +++ b/build/has/dprintf.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <stdio.h> + +int main(void) { + return dprintf(1, "%s\n", "Hello world!"); +} diff --git a/build/has/pragma-nounroll.c b/build/has/pragma-nounroll.c new file mode 100644 index 0000000..2bdae14 --- /dev/null +++ b/build/has/pragma-nounroll.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +/// -Werror + +int main(void) { +#pragma nounroll + for (int i = 0; i < 100; ++i); + return 0; +} diff --git a/build/has/pthread-set-name-np.c b/build/has/pthread-set-name-np.c new file mode 100644 index 0000000..324aab9 --- /dev/null +++ b/build/has/pthread-set-name-np.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <pthread.h> +#include <pthread_np.h> + +int main(void) { + pthread_set_name_np(pthread_self(), "name"); + return 0; +} diff --git a/build/has/pthread-setname-np.c b/build/has/pthread-setname-np.c new file mode 100644 index 0000000..a3b94c1 --- /dev/null +++ b/build/has/pthread-setname-np.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <pthread.h> + +int main(void) { + return pthread_setname_np(pthread_self(), "name"); +} diff --git a/build/has/sched-getaffinity.c b/build/has/sched-getaffinity.c new file mode 100644 index 0000000..6f8fd98 --- /dev/null +++ b/build/has/sched-getaffinity.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <sched.h> + +int main(void) { + cpu_set_t set; + return sched_getaffinity(0, sizeof(set), &set); +} diff --git a/build/has/tcsetwinsize.c b/build/has/tcsetwinsize.c new file mode 100644 index 0000000..6717415 --- /dev/null +++ b/build/has/tcsetwinsize.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <termios.h> + +int main(void) { + const struct winsize ws = {0}; + return tcsetwinsize(0, &ws); +} diff --git a/build/header.mk b/build/header.mk index f940e52..f15829a 100644 --- a/build/header.mk +++ b/build/header.mk @@ -20,6 +20,7 @@ HEADERS := \ gen/has/acl-trivial.h \ gen/has/builtin-riscv-pause.h \ gen/has/confstr.h \ + gen/has/dprintf.h \ gen/has/extattr-get-file.h \ gen/has/extattr-get-link.h \ gen/has/extattr-list-file.h \ @@ -35,9 +36,13 @@ HEADERS := \ gen/has/getprogname.h \ gen/has/io-uring-max-workers.h \ gen/has/pipe2.h \ + gen/has/pragma-nounroll.h \ gen/has/posix-getdents.h \ gen/has/posix-spawn-addfchdir-np.h \ gen/has/posix-spawn-addfchdir.h \ + gen/has/pthread-set-name-np.h \ + gen/has/pthread-setname-np.h \ + gen/has/sched-getaffinity.h \ gen/has/st-acmtim.h \ gen/has/st-acmtimespec.h \ gen/has/st-birthtim.h \ @@ -51,6 +56,7 @@ HEADERS := \ gen/has/string-to-flags.h \ gen/has/strtofflags.h \ gen/has/tcgetwinsize.h \ + gen/has/tcsetwinsize.h \ gen/has/timegm.h \ gen/has/timer-create.h \ gen/has/tm-gmtoff.h \ @@ -64,9 +70,9 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS} @printf '// %s\n' "$@" >$@ @printf '#ifndef BFS_CONFIG_H\n' >>$@ @printf '#define BFS_CONFIG_H\n' >>$@ - @cat ${.ALLSRC} >>$@ + @cat $^ >>$@ @printf '#endif // BFS_CONFIG_H\n' >>$@ - @cat gen/flags.log ${.ALLSRC:%=%.log} >gen/config.log + @cat gen/flags.log ${^:%=%.log} >gen/config.log ${VCAT} $@ @printf '%s' "$$CONFFLAGS" | build/embed.sh >gen/confflags.i @printf '%s' "$$XCC" | build/embed.sh >gen/cc.i diff --git a/build/pkgs.mk b/build/pkgs.mk index 5de9ac2..f692739 100644 --- a/build/pkgs.mk +++ b/build/pkgs.mk @@ -19,7 +19,7 @@ gen/pkgs.mk: ${HEADERS} printf '_LDFLAGS += %s\n' "$$(build/pkgconf.sh --ldflags "$$@")"; \ printf '_LDLIBS := %s $${_LDLIBS}\n' "$$(build/pkgconf.sh --ldlibs "$$@")"; \ }; \ - gen $$(grep -l ' true$$' ${.ALLSRC} | sed 's|.*/\(.*\)\.h|\1|') >>$@ + gen $$(grep -l ' true$$' $^ | sed 's|.*/\(.*\)\.h|\1|') >>$@ ${VCAT} $@ .PHONY: gen/pkgs.mk diff --git a/build/prelude.mk b/build/prelude.mk index c25dea4..6250d73 100644 --- a/build/prelude.mk +++ b/build/prelude.mk @@ -9,11 +9,9 @@ # We don't use any suffix rules .SUFFIXES: -# GNU make has $^ for the full list of targets, while BSD make has $> and the -# long-form ${.ALLSRC}. We could write $^ $> to get them both, but that would -# break if one of them implemented support for the other. So instead, bring -# BSD's ${.ALLSRC} to GNU. -.ALLSRC ?= $^ +# GNU make has $^ for the full list of targets, while BSD make has $> (and the +# long-form ${.ALLSRC}). We use the GNU version, bringing it to BSD like this: +^ ?= $> # Installation paths DESTDIR ?= diff --git a/build/version.sh b/build/version.sh index ba5447f..ec0663a 100755 --- a/build/version.sh +++ b/build/version.sh @@ -14,5 +14,5 @@ if [ "${VERSION-}" ]; then elif [ -e "$DIR/.git" ] && command -v git >/dev/null 2>&1; then git -C "$DIR" describe --always --dirty else - echo "4.0.4" + echo "4.0.8" fi |