Commit Graph

206 Commits

Author SHA1 Message Date
Andrew Turner
4ea56599e8 Port the NetBSD ubsan runtime to the FreeBSD kernel.
This allows us to build the ubsan code added in r340189 into the kernel
with the KUBSAN option. This will report when undefined behaviour is
detected in the currently running kernel.

As it can be large, the kernel is 65MB on arm64, loader may not be able to
load the kernel on all architectures so is disabled by default for now.

Sponsored by:	DARPA, AFRL
2018-11-06 17:32:07 +00:00
John Baldwin
58b6812de1 Only invoke 'ls' if the local modules directory exists.
This avoids a spurious make warning if /usr/local/sys/modules doesn't
exist.

Submitted by:	rgrimes
Reported by:	markj
2018-10-30 18:20:34 +00:00
John Baldwin
cd785c1b34 Permit local kernel modules to be built as part of a kernel build.
Add support for "local" modules.  By default, these modules are
located in LOCALBASE/sys/modules (where LOCALBASE defaults to
/usr/local).  Individual modules can be built along with a kernel by
defining LOCAL_MODULES to the list of modules.  Each is assumed to be
a subdirectory containing a valid Makefile.  If LOCAL_MODULES is not
specified, all of the modules present in LOCALBASE/sys/modules are
built and installed along with the kernel.

This means that a port that installs a kernel module can choose to
install its source along with a suitable Makefile to
/usr/local/sys/modules/<foo>.  Future kernel builds will then include
that kernel module using the kernel configuration's opt_*.h headers
and install it into /boot/kernel along with other kernel-specific
modules.

This is not trying to solve the issue of folks running GENERIC release
kernels, but is instead aimed at folks who build their own kernels.
For those folks this ensures that kernel modules from ports will
always be using the right KBI, etc.  This includes folks running any
KBI-breaking kernel configs (such as PAE).

There are still some kinks to be worked out with cross-building (we
probably shouldn't include local modules in cross-built kernels by
default), but this is a sufficient starting point.

Reviewed by:	imp
MFC after:	3 months
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D16966
2018-10-30 00:23:37 +00:00
Ed Maste
08d0704d74 Switch reproducible builds to unmodified src tree mode
newvers.sh supports two modes for reproducible builds:

 -r    Reproducible build.  Do not embed directory names, user
       names, time stamps or other dynamic information into
       the output file.  This is intended to allow two builds
       done at different times and even by different people on
       different hosts to produce identical output.

 -R    Reproducible build if the tree represents an unmodified
       checkout from a version control system.  Metadata is
       included if the tree is modified.

Switch to the second mode when reproducible builds are enabled.
The value of a reproducible build is much less when building from an
uncontrolled, modified src tree, and -R likely provides the best
compromise in allowing the REPRODUCIBLE_BUILD knob to be enabled by
default for the release.

Approved by:	re (kib)
Sponsored by:	The FreeBSD Foundation
2018-09-11 19:19:07 +00:00
Bryan Drewery
817f7baa74 Use OBJS_DEPEND_GUESS for forced opt_global.h dependency.
MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-07-04 00:18:36 +00:00
Matt Macy
9f7b089e95 Enable MODULE_TIED by default for modules compiled with the kernel
Requested by: jhb
2018-07-03 23:05:42 +00:00
Bryan Drewery
cd1acc77e6 Fix .depend.foo.o tracking for sys/conf/files defined compilations.
Some example files:
  ia32_genassym.o
  acpi_wakecode.o

The old mkdep method also lacked tracking these files.

Objects defined in sys/conf/files with no-obj and no-implicit-rule get their
own targets defined in the kernel Makefile but lack having their objects added
to DEPENDOBJS so never get a .depend file generated.  Normally if an object is
in OBJS it will get a .depend file.

Fix this by looking for .o files in CLEAN and ensuring they are part of
the -MD filtering and .depend loading.  This is a hack.  Other solutions
could exist involving sys/conf/files or config(8) to auto add these to
DEPENDFILES/DEPENDOBJS but this method seems reliable enough without being
intrusive or error-prone for new files.

Reported by:	bde
MFC after:	3 weeks
Sponsored by:	Dell EMC
2018-07-03 21:29:04 +00:00
Bryan Drewery
44e4164832 Fix r335906+r335907 to not pass multiple source files to genoffset_test.o target.
This is working around a bug with the FAST_DEPEND logic with custom targets
that use .ALLSRC.

Reported by:	mmacy
2018-07-03 20:03:19 +00:00
Bryan Drewery
a46134b641 Handle .depend for genoffset_test.o 2018-07-03 19:24:52 +00:00
Bryan Drewery
4cee7eae0d No need to make a copy to build genoffset_test.o 2018-07-03 19:24:44 +00:00
Matt Macy
018617b8ba explain the purpose of genoffset_test 2018-07-03 18:39:43 +00:00
Matt Macy
87c259d436 ensure that offset.inc is generated first 2018-07-03 18:20:42 +00:00
Matt Macy
6443773dab make critical_{enter, exit} inline
Avoid pulling in all of the <sys/proc.h> dependencies by
automatically generating a stripped down thread_lite exporting
only the fields of interest. The field declarations are type checked
against the original and the offsets of the generated result is
automatically checked.

kib has expressed disagreement and would have preferred to simply
use genassym style offsets (which loses type check enforcement).
jhb has expressed dislike of it due to header pollution and a
duplicate structure. He would have preferred to just have defined
thread in _thread.h. Nonetheless, he admits that this is the only
viable solution at the moment.

The impetus for this came from mjg's D15331:
"Inline critical_enter/exit for amd64"

Reviewed by: jeff
Differential Revision: https://reviews.freebsd.org/D16078
2018-07-03 01:55:09 +00:00
Jason A. Harmening
28da5c6d7a Remove MK_AUTO_OBJ from env passed to PORTS_MODULES
This fixes a failure to resolve object file paths seen when buildkernel
(which sets MK_AUTO_OBJ=yes) and installkernel (which sets MK_AUTO_OBJ=no)
are run as separate steps.  r329232 partially fixed this scenario by removing
MAKEOBJDIR, but it seems the AUTO_OBJ setting also needs to be on the same
page for the build and install steps.

Reviewed by:	bdrewery
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14143
2018-03-31 05:17:12 +00:00
Ed Maste
fc2a8776a2 Rename assym.s to assym.inc
assym is only to be included by other .s files, and should never
actually be assembled by itself.

Reviewed by:	imp, bdrewery (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14180
2018-03-20 17:58:51 +00:00
Bryan Drewery
71b126549d Fix rebase mismerge in r330724.
X-MFC-With:	r330724
MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-03-10 02:13:48 +00:00
Bryan Drewery
906ce865c2 Don't skip reading depend for 'make obj' unless it is alone.
This was effectively done in bsd.dep.mk quite some time ago.

MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-03-10 02:10:26 +00:00
Bryan Drewery
003a0576c9 Skip reading depend files with -V unless looking up a depend variable.
This speeds up some simple -V lookups significantly.

Reported by:	bde
MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-03-10 02:10:19 +00:00
Bryan Drewery
501608626d ports modules: Don't leak AUTO_OBJ changes into the port builds.
This came about when r328489 made ports modules builds no longer use the
in-tree share/mk files, but didn't cleanup MAKEOBJDIR from the
environment.

This fixes "Variable OBJTOP is recursive".

Sponsored by:	Dell EMC
2018-02-13 17:51:16 +00:00
Jason A. Harmening
283f8a5c33 Remove system makefile path directives from env passed to PORTS_MODULES step
Previously, MAKESYSPATH as well as '-m' directives in MAKEFLAGS would cause
any port rebuilt during the PORTS_MODULES stage to consume system makefiles
from $(SRCROOT)/share/mk instead of those installed under /usr/share/mk.
For kernel modules that need to build against an updated src tree this
makes sense; less so for <bsd.port.mk> or  any userspace library or utility
the port may also happen to install.

Before 11.0, this probably didn't matter much in practice.  But the addition
of src.libnames.mk under $(SRCROOT)/share/mk in 11.0 breaks any consumer of
bsd.prog.mk and DPADD/LDADD during PORTS_MODULES.

Address the build breakage by removing MAKESYSPATH and any occurrence of
'-m' from MAKEFLAGS in the environment created for the port build.
Instead set SYSDIR so that any kmod built by the port will still consume
conf/kmod.mk from the updated src tree, assuming it uses <bsd.kmod.mk>

Reviewed by:	bdrewery
MFC after:	2 weeks
Differential Revision: 	https://reviews.freebsd.org/D13053
2018-01-27 20:13:36 +00:00
Alex Richardson
454ce38321 Use ln -n instead of -h to allow building the kernel on Linux
Both flags do the same thing but -n is more widely supported.

Reviewed By:	jhb, emaste
Approved By:	jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D13936
2018-01-16 21:43:57 +00:00
Bryan Drewery
7cc780d771 DEPENDSRCS not used here.
Sponsored by:	Dell EMC
2017-12-05 02:23:27 +00:00
Bryan Drewery
b4585565d5 Rename DEPENDFILES_OBJS to DEPENDFILES.
This is to be consistent with bsd.dep.mk using DEPENDFILES after
r325677.

Sponsored by:	Dell EMC
2017-12-05 02:23:23 +00:00
Bryan Drewery
b00ea69b51 Fix PORTS_MODULES+'make reinstallkernel' trying to run bogus 'make redeinstall'.
Also fix 'make installkernel' running 'make deinstall' twice.

PR:		201779
MFC after:	2 weeks
Sponsored by:	Dell
2017-11-18 20:01:05 +00:00
Warner Losh
1cbb58886a Remove build system support for lint.
Differential Revision: https://reviews.freebsd.org/D13124
2017-11-17 18:16:46 +00:00
Bryan Drewery
96dd05dd7d Quote ${MAKE} when passing in env in case it contains spaces.
Downstream we are wrapping MAKE with a limits(1) call which
interferes with these non-quoted cases.

Sponsored by:	Dell EMC Isilon
2017-08-16 17:54:24 +00:00
Bryan Drewery
ecc39238d3 Allow -DNO_SKIP_DEPEND to override the _SKIP_DEPEND logic.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-07-25 16:46:12 +00:00
Bryan Drewery
c2fd1d01e8 Allow disabling dependency tracking if DEPEND_CFLAGS is empty.
This falls back on using the guesssed dependencies if so.
Also remove a pre-bmake check while here.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-07-24 23:32:40 +00:00
Bryan Drewery
711019f70d Slightly simplify logic for which depend file is expected.
This is a NOP.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-07-24 23:32:36 +00:00
Bryan Drewery
f80b8a886d META_MODE: Fix not writing .meta files in the kernel build.
This was a regression in r320220 due to improper porting of the
same logic from share/mk/bsd.dep.mk and having only tested with
-DNO_FILEMON at the time.

Pointyhat to:	bdrewery
Reported by:	Mark Millard, dhw, O. Hartmann
Sponsored by:	Dell EMC Isilon
2017-07-12 19:01:25 +00:00
Bryan Drewery
210ecc0021 Rework logic for skipping .depend/.meta file read/stat/writes.
- Rename _SKIP_READ_DEPEND to _SKIP_DEPEND since it also avoids writing.
- This now uses .NOMETA to avoid reading any .meta files related to
  DEPENDOBJS.  Objects not in OBJS/DEPENDOBJS may still have their .meta
  files read in if they are in the dependency graph.
- This also avoids statting .meta and .depend files in the META_MODE +
  -DNO_FILEMON case.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-06-22 05:34:41 +00:00
Bryan Drewery
202d6f8c61 Fix various 'make *clean *all *install' combinations.
This follows commits like r320174 in share/mk/bsd.dep.mk.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-06-21 19:55:26 +00:00
Bryan Drewery
6d75a7a852 Support skipping 'make obj' tree-walk.
This is part of a larger effort for WITH_AUTO_OBJ and a WORLDFAST
option.

Sponsored by:	Dell EMC Isilon
2017-05-09 20:21:38 +00:00
Enji Cooper
d61db6be37 Use "build" instead of "all" when building ports modules
"all" in ports currently means "stage the ports", which requires root today,
and brings to light other potential issues, like ENAMETOOLONG with staged
directories (bug 161481, etc).

This fixes buildkernel for me when run as a non-root user, assuming all
of the prerequisites have been installed beforehand and are up-to-date.

MFC after:	1 month
Discussed with:	swills (IRC)
Sponsored by:	Dell EMC Isilon
2017-02-28 04:48:30 +00:00
Ed Maste
0e8b3ab348 Exclude -flto when building *genassym.o
The build process generates *assym.h using nm from *genassym.o (which is
in turn created from *genassym.c).

When compiling with link-time optimization (LTO) using -flto, .o files
are LLVM bitcode, not ELF objects. This is not usable by genassym.sh,
so remove -flto from those ${CC} invocations.

Submitted by:	George Rimar
Reviewed by:	dim
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D9659
2017-02-21 18:59:17 +00:00
Ian Lepore
0a201eeac2 Use ${.OBJDIR} to refer to the kernel build object dir, instead of trying
to recreate it from ${MAKEOBJDIRPREFIX} and ${SRC_BASE} and ${KERNCONF},
the latter being especially problematic when KERNCONF is set to the names
of multiple kernel configs.
2016-12-22 21:11:42 +00:00
Ed Maste
602f95d4c4 Add WITH_REPRODUCIBLE_BUILD src.conf(5) knob to disable kernel metadata
The kernel builds reproducibly, except for the time, date, user, and
hostname baked into the kernel (reported at startup and via the
kern.version sysctl for uname).  Add a build knob to disable the
inclusion of this metadata.

Reviewed by:	jhb
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	Reproducible Builds World Summit 2, Berlin
Differential Revision:	https://reviews.freebsd.org/D8809
2016-12-15 21:26:58 +00:00
Marcel Moolenaar
2b4da8aa20 When MAKEOBJDIRPREFIX points to a case-insensitive file system, the
build can break when different source files create the same target
files (case-insensitivity speaking).  This is the case for object
files compiled with -fpic and shared libraries. The former uses
an extension of ".So", and the latter an extension ".so".  Rename
shared object files from *.So to *.pico to match what NetBSD does.

See also r305855

MFC after:	1 month
Sponsored by:	Bracket Computing
Differential Revision:	https://reviews.freebsd.org/D7906
2016-09-24 15:11:27 +00:00
Bryan Drewery
c30c436a58 FAST_DEPEND: Fix 'make all install' not properly rebuilding based on .depend.* files.
An optimization is in place to skip reading the .depend.* files with
'make install'.  This was too strong and broke 'make all install' and
'make foo.o foo install'.  Now only skip reading the dependency files
if all make targets ran are install targets.

The problem comes about because headers are only added in as a guessed
dependency if .depend.* files do not yet exist.  If they do exist, even
if being skipped from being read, then the header dependencies are not
applied.  This applies to all #included files, and not just headers.

Reported by:	kib
MFC after:	1 day
Sponsored by:	EMC / Isilon Storage Division
2016-08-23 19:37:18 +00:00
Bryan Drewery
786c805027 PORTS_MODULES: Don't leak in CC/CXX/CPP.
These may have ccache in them or -target/--sysroot from external
compiler or SYSTEM_COMPILER support.  Many ports do not support
a CC with spaces in it, such as emulators/virtualbox-ose-kmod.
Passing --sysroot to ports makes no sense as ports doesn't support
--sysroot currently.
If these variables need to be overridden for ports then they can
be set in make.conf or passed as make arguments.

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-12 11:06:54 +00:00
Bryan Drewery
799483e49e META_MODE: Don't generate or read _EXTRADEPEND dependencies when using filemon.
The DPADD data in .depend will be redundant with what is in the .meta file.

Also extend NO_EXTRADEPEND support to bsd.prog.mk.

Approved by:	re (blanket, META_MODE)
Sponsored by:	EMC / Isilon Storage Division
2016-06-21 21:55:03 +00:00
Bryan Drewery
c155decc4b WITH_META_MODE: Do include headers for specific guessed dependencies
This is a follow-up to r300343.

This is important for the OBJS_DEPEND_GUESS usage in
gnu/usr.bin/cc/cc_tools.

See comments for more details.

Approved by:	re (implicit)
Sponsored by:	EMC / Isilon Storage Division
2016-06-15 23:57:50 +00:00
Jonathan T. Looney
ad8874fd21 Change the default build behavior so we don't compile extra TCP modules by
default. At least initially, the feature to support multiple TCP stacks is
aimed at supporting advanced use cases and TCP development, but it is not
necessarily aimed at a wide audience. Therefore, there is no need to build
and install the extra TCP stacks by default. Instead, the people who are
using or developing this functionality can add the extra option to build/
install the extra TCP stacks.

However, we do want to build the extra TCP stacks as part of test builds
(e.g. LINT or tinderbox) to ensure that developers who are testing their
changes will know that their changes do not break the additional TCP
stack modules.

After this change, a user will need to add WITH_EXTRA_TCP_STACKS=1 to
make.conf or the kernel config in order to build the extra TCP modules.

Differential Revision:	https://reviews.freebsd.org/D6795
Reviewed by:	sjg
Approved by:	re (kib)
2016-06-10 19:06:11 +00:00
Bryan Drewery
5852ae2d99 Revert r301079.
This breaks cross-building with WITH_META_MODE since it will rebuild
'build-tools' during the 'everything' phase.

A more proper fix is coming to bmake to implicitly require .META unless
.NOMETA (and other restrictions) are in place.
2016-06-03 19:25:36 +00:00
Bryan Drewery
292c5292b6 WITH_META_MDE: Fix machine/include and x86/include issues.
- Fixes 'ln: File exists' errors.
- Fixes creating include directories in the source directory as well.

Sponsored by:	EMC / Isilon Storage Division
2016-05-31 23:40:21 +00:00
Bryan Drewery
2dcffa9cb7 WITH_META_MODE: Resolve SYSDIR to avoid changed build commands.
Sponsored by:	EMC / Isilon Storage Division
2016-05-31 23:08:43 +00:00
Bryan Drewery
28849c57d6 WITH_META_MODE: Mitigate switching from without to with META_MODE.
Adding .META to targets-to-build will ensure that they will rebuild if there
is no .meta file.

Adding it to all SUFFIXES and objects ensures that at least objects will
rebuild if there is no .meta file.

This will be reverted if bmake's behavior changes to rebuild on missing .meta
files.

Sponsored by:	EMC / Isilon Storage Division
2016-05-31 21:22:19 +00:00
Bryan Drewery
4977354760 Add some missing .PHONY.
These are relevant for WITH_META_MODE to ensure they are
always reran and don't generate a .meta file.

Sponsored by:	EMC / Isilon Storage Division
2016-05-26 23:20:14 +00:00
Bryan Drewery
3b828e4492 WITH_META_MODE: Fix suffix transformation rules with guessed dependencies.
This is the same problem as r290629.  With META_MODE we do not generate
.depend files, so there is no proper dependency to lookup.  Guessed
dependencies must be used.  If this proves to be a problem then we will
have to generate and use .depend files even with META_MODE.

Sponsored by:	EMC / Isilon Storage Division
2016-05-21 01:31:48 +00:00
Wojciech Macek
1782ba0c1f Revert r298357
Revert workaround fixed by r298361
2016-04-20 22:41:19 +00:00