pc64,vkernel64: Prune includes in genassym.cf
In addition, remove the obsolete "opt_nfs.h" header dependency of
genassym.cf in sys/dev/virtual/nvmm/Makefile.
Migrate to the newly imported genassym.sh and generated assym.h
* Remove the old sys/kern/genassym.sh, sys/sys/assym.h and genassym.c
files.
* Migrate the genassym.c code to genassym.cf configs for genassym.sh.
* Update all sources to include the new generated "assym.h" instead of
the old "assym.s".
* Update the kernel makefiles in sys/conf to call genassym.sh to
generate "assym.h".
* Update libc to use genassym.sh to generate "asmcontext.h".
sys/conf: Share compiler flags and rules between kernel and modules
* Move the common CFLAGS to bsd.kern.mk, and include it earlier in
kern.pre.mk and kmod.sh, so the flags ordering in CFLAGS is mostly
preserved.
* Clear the suffix rules and CFLAGS from <sys.mk> and explicitly define
them in bsd.kern.mk, for use in the kernel and modules building.
pc64: Remove redundant symbol exports in genassym.c
The MSR_GSBASE, MSR_KGSBASE and MSR_FSBASE are constants defined in
<machine/specialreg.h> and can be used in assembly code, so no need to
redefine them.
Caught by the new genassym.sh, whose output has different value format
(e.g., `#define MSR_GSBASE 3221225729`) and thus caused redefinition
error in compilation.
While there, remove a few commented symbols as well.
kernel: Import OpenBSD's genassym.sh tool
The new genassym.sh tool uses special inlined assembly code to create
the "assym.h" (ours named "assym.s") from constant C expressions. It
will replace the current sys/kern/genassym.sh tool, which relies on
the special macros in <sys/assym.h> and a custom CC compilation, and
will help simplify the "assym.s" generation code in kern.post.mk and
kmod.mk.
I compared the genassym.sh tool in both NetBSD and OpenBSD and found
OpenBSD version is better maintained, so I chose their version.
I placed this tool in sys/tools/ directory instead of sys/kern/; I think
the former is a better location as there are already some awk tools, and
this genassym.sh will also be used by libc.
sys/conf: Improve ${NORMAL_FWO} command for reuse in kmod.mk
The kmod.mk previously invented its own commands to link a firmware blob
(.fwo). Given that NORMAL_FWO is available through bsd.kern.mk, improve
it and reuse it in kmod.mk.
sys/conf: Clean up makefiles
* Minor logic and code simplifications.
* Remove non-existent 'freebsd/net/ifdi_if.m' from MFILES, and sort the
list.
* Remove obsolete and commented stale contents.
* Simplify the 'hack.So' generation to save a temp file.
* Move -Wno-unused-but-set-variable out of the GCC scope as it's also
supported by Clang.
* Style and whitespace cleanups.
genassym.cf: Tweak for DragonFly
* Don't always define `_KERNEL`, which would cause trouble for libc
where only `_KERNEL_STRUCTURES` should be defined. So just remove this
and rely on the command to define the wanted macro.
* Don't define `offsetof` to avoid redefinition error, because our
<sys/stdint.h> always defines this macro.
kernel: Clean up .fw decoding with ${NORMAL_FW} and <bsd.dragonfly.mk>
* Reuse ${NORMAL_FW} to replace the explicit uudecode commands.
* Use ${DF.SRCTOP} from <bsd.dragonfly.mk> to simplify the complex
paths.
sys/conf/kern.pre.mk: Move ${WERROR} into CFLAGS
Commit 40ec0564adaa677a0dab5299bdd491a2245e94a0 added -Werror to the
kernel build by adjusting config(8) to add -Werror to individual build
rules, so every source in the "files" file that uses a custom
"compile-with" rule needs a manual ${WERROR} addition.
This commit makes ${WERROR} the default by moving it to CFLAGS, and
adjust config(8) to append "-Wno-error" to the build rules if the
"nowerror" keyword is specified for a source. As a result, all the
${WERROR} in the "files" files and in the explicit rules in makefiles
are removed.
sys/conf: Move COPTFLAGS and WERROR to bsd.kern.mk
* Move COPTFLAGS and WERROR to bsd.kern.mk for reusing in kern.pre.mk
and kmod.mk.
* Adjust CFLAGS to order KCFLAGS at last, allowing it to be able to
override some default options, because KCFLAGS is used in individual
makefiles.
etc: run the sub-makes with the source tree's mk files
Pass -m ${.CURDIR}/../share/mk through .MAKEFLAGS, so the sub-makes
use the mk files from this source tree, as the top-level Makefile
already does for preinstall and upgrade, and nrelease does for
distribution.
Reviewed-by: @aly
Use <bsd.dragonfly.mk> to avoid extra path checking
These makefiles need to be included by makefiles in different
directories, so the extra path existence checks are required to handle
this. Now just use <bsd.dragonfly.mk> to simplify this.
cc120,gcc120: Use <bsd.dragonfly.mk> to remove RELUP/TOP_PREFIX hacks
In addition, fix the "tm.h" generation in gnu/lib/csu/Makefile.csu; it
was called from .OBJDIR so the DF.SRCTOP would fail in that case.
share/mk: Add bsd.dragonfly.mk to provide source tree path variables
The include file provides the DF.SRCTOP, DF.RELDIR, DF.RELTOP and
DF.OBJTOP variables to help access the source and object trees, and thus
help avoid the complex and fragile relative paths that depend on the
location of the including makefiles.
In particular, DF.SRCTOP and DF.OBJTOP defines the absolute paths to the
source and object trees, so makefiles using these variables can be
included by any other makefiles, without hacking a variable to fix the
relative-path-based addressing. For example, gnu/usr.bin/cc120 hacks
this need with the "TOP_PREFIX" variable.
This idea is inspired by FreeBSD's SRCTOP, which is defined in
<src.sys.env.mk> and is finally included by <sys.mk>, so it becomes an
early global and can be directly used by any makefiles. We decided to
not touch <sys.mk> but place it in a separate include file (i.e.,
<bsd.dragonfly.mk>), so any makefiles that really want these variables
must explicitly include it. By the way, NetBSD also defines the
[3 lines not shown]
kernel: report the sender in sigwaitinfo() and sigtimedwait()
kern_sigtimedwait() returned only si_signo. lwpsignal() records the
sender's pid and uid in ps_frominfo[] for every signal it posts, and
sendsig() copies them into the siginfo of an SA_SIGINFO handler, but a
signal taken with sigwaitinfo() or sigtimedwait() came back with si_pid
and si_uid 0.
Bug: https://bugs.dragonflybsd.org/issues/3471
Reviewed-by: @dillon
mount_fusefs(8): accept and ignore the "nempty" option
ntfs-3g mounts with "nonempty" by default and libfuse passes it to
mount_fusefs. getmntopts() treats the leading "no" as negation and
looks up "nempty", which is not in the option table, so the mount fails
with "-o nempty: option not supported". Add the ignore entry that
FreeBSD's mount_fusefs(8) has.
Bug: https://bugs.dragonflybsd.org/issues/3459
fuse: fix a lost wakeup in the I/O helper
fuse_io_thread() slept first and drained the queue only after waking.
After draining it released helper_spin and called tsleep()
unconditionally. fuse_vop_strategy() queues a bio under helper_spin,
drops the lock and then calls wakeup(), so a wakeup that arrived
between that final spin_unlock() and the interlock taken inside
tsleep() was lost. The helper then slept forever with the bio queued
and the caller hung in biowait().
Hold helper_spin while checking the queue and use ssleep(), which
takes the sleep-queue interlock and drops the spinlock in one step,
so the wakeup cannot be lost.
Bug: https://bugs.dragonflybsd.org/issues/3459
fuse: honor an explicit ftruncate() size
An earlier write extension sets fnp->sizeoverride, which made
fuse_set_attr() keep the old size and ignore an explicit
ftruncate(). Clear the override for FATTR_SIZE setattrs.
Bug: https://bugs.dragonflybsd.org/issues/3459