Home | History | Annotate | Download | only in mk
History log of /src/share/mk/bsd.kmodule.mk
RevisionDateAuthorComments
 1.86  16-Jun-2024  pgoyette Import AFLAGS to allow processing of assembler files in modules.
Prerequisite for kern/583346.
 1.85  06-May-2024  mrg use objcopy's --compress-debug-sections when creating debug files.

this reduces the size of the installed files by over half in most cases,
though the debug set size doesn't really change much (which looks like
close to 1GB of space on amd64 with xdebug installed, similar on arm64,
and about 600MB without xdebug.)

tested by running GDB on a few things, seems just as functional, on amd64,
arm64, and slightly on riscv64.

(first attempt for this feature used "gcc -gz=zlib", but that ends up
making CTF unhappy, but fortunately this works in binutils to create
the .debug files separate to any ctf usage of the main file.)
 1.84  03-Jun-2023  lukem adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}

Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
 1.83  03-Jun-2023  lukem bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER

Provide a single variable
CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
CLANG_NO_ADDR_OF_PACKED_MEMBER
CC_NO_ADDR_OF_PACKED_MEMBER
GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.82  07-May-2023  skrll RISC-V support that works on QEMU with a single hart.

Thanks for Simon Burge for plic(4).
 1.81  07-Aug-2022  riastradh branches: 1.81.2;
bsd.kmodule.mk: Build modules with KDTRACE_HOOKS if MKDTRACE=yes.
 1.80  03-Aug-2022  riastradh sys: Build kernel with -Wno-type-limits.

The type-limits warning is actively harmful because it discourages
writing safe portable overflow detection logic which happens, on some
architectures, to be dead code.
 1.79  17-Jul-2022  riastradh bsd.kmodule.mk: Also sync no-address-of-packed-member.

This is not actually a good idea to disable -- it can lead to real
problems -- but let's just make it the same for the kernel build and
module builds.
 1.78  17-Jul-2022  riastradh bsd.kmodule.mk: Use -Wno-attributes like conf/Makefie.kern.inc.
 1.77  29-Mar-2022  christos get rid of old style `` command substitution in shell and use $() instead.
 1.76  29-Mar-2021  simonb On MIPS if we compile C files as N64, compile assembly with the same ABI.
 1.75  23-Mar-2021  simonb Work in progress for MIPS modules. Only tested on mipseb64, not yet
enabled anywhere.
 1.74  07-Mar-2021  rin Build modules for PPC_OEA64 on evbppc64.
 1.73  07-Mar-2021  rin whitespace --> tab. No functional changes.
 1.72  18-Oct-2020  christos Handle the no-addr-of-packed-member only for the files that need it, not
globally.
 1.71  10-Sep-2020  rin Turn off -mpltseq for kernel modules on powerpc for GCC >= 9.

Otherwise, object files compiled with -mlongcall contain relocation types
referring PLT, which our in-kernel linker cannot handle.

This ends up with failure in kernel module load with
``kobj_reloc: unexpected relocation type 31'' (31 == R_PPC_PLT16_HA here).

See descriptions for -mlongcall in gcc(1) of GCC9 for more details.
 1.70  06-Sep-2020  mrg add support for new GCC 9 warnings that may be too much to fix
right now. new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree. mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it. (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.) clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
 1.69  27-Jul-2020  skrll Don't define _LKM. LKMs are dead. Long live modules.
 1.68  11-May-2020  skrll Update the list of hppa options to build working kernel modules.
 1.67  02-May-2020  rin Fix previous; add missing <module>.kmod.debug to realall.
 1.66  01-May-2020  christos Install <module>.kmod.debug files for kernel crash debugging.
 1.65  04-Apr-2020  christos make sure _OSRELEASE is defined where it is needed.
 1.64  04-Apr-2020  christos Infrastructure for putting kernel+modules in /netbsd/kernel and
/netbsd/modules respectively instead of /netbsd and
/stand/<arch>/<version>/modules. This is only supported for x86,
and is turned off by default. To try it, add KERNEL_DIR=yes in your
/mk.conf and install a system from that build.
 1.63  01-Dec-2019  jmcneill Build aarch64 modules without fp or simd instructions.
 1.62  05-Jul-2019  hannken branches: 1.62.2;
When building a module keep symbols if built with "MKCTF" and "COPTS=-g".
 1.61  09-May-2019  maya G/C unused code.
gcc -combine is no longer a thing, so this entire block isn't usable.
 1.60  21-Jan-2019  christos Most of the mv operations are to move temporary files to their final place.
Some use -f, others don't. This can lead to spurious build failures when
the user performing the build changes. Centralize, and always use -f.
 1.59  11-Jan-2017  joerg branches: 1.59.12; 1.59.14;
Disable a couple of warnings until further investigation.
 1.58  02-Feb-2016  christos branches: 1.58.2;
Add the missing CTFMERGE step.
 1.57  30-Jan-2016  christos Make ctfconvert remove the debugging symbols after it is done converting them.
 1.56  30-Jan-2016  christos If we are building CTF, keep debugging symbols.
 1.55  09-Jul-2015  matt Add _MKTARGET_LINK
 1.54  24-Jun-2015  matt Don't add anything to CFLAGS/LDFLAGS on mips64 is BSD_MK_COMPAT_FILE is set.
 1.53  02-May-2015  matt For mips64, build kmodules using N64 ABI
 1.52  13-Nov-2014  christos do the dependencies in a simpler way using a separate target
 1.51  13-Nov-2014  uebayasi If mkldscript.sh is used to build ${PROG}, depend on it.
 1.50  12-Nov-2014  christos sync both instances of the ldscript.
 1.49  12-Nov-2014  christos add -t to mkldscript
 1.48  12-Nov-2014  christos use ${HOST_SH}
 1.47  12-Nov-2014  christos Enable dynamic link script generation to handle __{start,stop}_link_set_*
via a variable; perhaps delete the variable and always do it?
 1.46  06-Nov-2014  uebayasi Leave .map when linking .kmod.
 1.45  19-Sep-2014  matt Add RISCV-V support.
 1.44  10-Aug-2014  joerg Put GCC/GAS specific options under ACTIVE_CC == "gcc".
 1.43  10-Mar-2014  nakayama -mcmodel option is CPU specific not machine specific.
 1.42  21-Feb-2014  joerg Use small code model for LLVM on SPARC64, it should be equivalent to
GCC's medlow.
 1.41  09-Nov-2013  jmcneill use -fno-unwind-tables when building arm modules
 1.40  18-Sep-2013  martin When compiling kernel modules on sparc64 force the same memory model as
we force for the kernel (i.e. do not rely on compiler defaults here)
 1.39  07-Aug-2013  matt Add support for generating tramponlines in the module at link time.
This is done using some awk scripts and KMODTRAMPOLINE in <machine/asm.h>
It's not as efficient as having the kloader do it but it is a lot simpler.
 1.38  06-Aug-2013  skrll Add -mlong-calls to hppa module builds.
 1.37  10-Aug-2012  joerg branches: 1.37.2;
Remove effectively tautological condition.
 1.36  15-Mar-2012  joerg Decouple HAVE_LLVM from HAVE_GCC. For GCC, add -Wno-format-zero-length
when -Wformat is used.
 1.35  19-Feb-2012  matt Add support for --combine with gcc.
 1.34  16-Feb-2012  christos use osrelease -k to avoid that the path is 6.0_BETA
 1.33  11-Sep-2011  mbalmer branches: 1.33.2; 1.33.4;
Move SYSCTL_USE_DESCR to a better place.
 1.32  10-Sep-2011  apb Move all "clean" and "cleandir" processing to a new bsd.clean.mk
file, as proposed in tech-toolchain.
 1.31  14-Jul-2011  matt VAX kernel modules need to be built with -fno-pic
 1.30  20-Jun-2011  mrg remove most of the remaining HAVE_GCC tests that are always true in
the modern world.
 1.29  17-May-2011  christos branches: 1.29.2;
Enable c99 mode by default.

This has the side effect of complaining for missing prototypes
implicit type declarations and missing return statements.

NB: I've only ran a build on amd64, so other platforms MI code might break.
If you can't wait for me to fix them, revert this commit.
 1.28  17-Apr-2011  mrg prepare for evbppc modules, and allow overriding the ${MACHINE} for
installed modules.
 1.27  02-Jan-2011  matt Kernels modules are c99 (gnu99) just like the kernel.
Add(move) -std=gnu99 to CPPFLAGS (from COPTS).
 1.26  11-Dec-2010  martin Revert last, gcc(1) checks explicitly for -r on some platforms to disable
passing down --relax as well.
 1.25  08-Dec-2010  joerg gcc passes down -r directly to ld, so make it explicitly a linker option.
 1.24  18-Jan-2010  jmmv Generate long calls in modules for arm32 and powerpc to avoid unsupported
relocations by the module loader in the kernel. This makes modules work
in, at least, shark and macppc respectively.

This is obviously a workaround that results in slower code, but at least
makes modules work. I'm adding a comment detailing what the real solution
would be so that the whole thing can be revisited in the future. (Read:
I don't have time now to dig the details of how to implement trampoline
generation.)

(Based on the old bsd.kmod.mk file, I understand that hppa needs this
workaround too, but I can't check this platform.)
 1.23  14-Dec-2009  mrg use "${CC} -r" not "${CC} -Wl,-r" as the latter fools GCC on some targets
and it ends up passing "-r -relax" to ld, which causes ld to barf.
 1.22  14-Dec-2009  matt Merge from matt-nb5-mips64
 1.21  10-Nov-2009  skrll Move the kmodule linker script source into sys/modules/xldscripts. It is
not part of binutils and definitely not GPL v3.

Discussed with mrg.
 1.20  08-Nov-2009  skrll Update for new binutils location.

XXX Why is kmodule under binutils anyway?
 1.19  10-Apr-2009  apb Add LINKSOWN, LINKSGRP, and LINKSMODE variables for use by bsd.links.mk
when installing hard links. They have no effect except when using a
metalog, in which case the information is added to the metalog. In
the future, these variables may be replaced by a method for explicitly
recording hard links in a metadata log.

Also change a few things that called ${INSTALL_LINK} without going
through bsd.links.mk.

Reviewed by perry and joerg. This should fix PR 24457 and PR 41155.
 1.18  24-Jan-2009  rmind branches: 1.18.2;
Revert path of modules back to "/stand".
 1.17  24-Jan-2009  rmind Change path to kernel modules from "/stand" to "/kernel".
Needs to go in before 5.0. Proposed on <tech-kern>.
 1.16  30-Nov-2008  hubertf Work around a bug in Solaris' shs (both /bin and /usr/xpg4/bin)
where "for d in ; ..." results in a syntax error.

Suggested by apb@
 1.15  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.14  05-Nov-2008  elad Don't build kernel modules with PIE.

Discussed with and okay christos@.
 1.13  14-Oct-2008  mrg branches: 1.13.2;
find the kmodule ldscript in the source tree again.

should fix a build issue reported by jmcneill.
 1.12  12-Oct-2008  mrg - install ldscripts on sparc64
- move ldscripts to /usr/libdata/ldscripts
 1.11  24-Aug-2008  gmcgarry Honour HAVE_PCC
 1.10  31-May-2008  dyoung branches: 1.10.2;
Fix two bugs to make MKMODULAR=yes builds will work again, for the
first time.

share/mk/bsd.kmodule.mk: only set _INST_DIRS if KMODULEDIR is not
set. That we we avoid installing some bogus directories in
the DESTDIR and in $DESTDIR/METALOG.

tests/modules/k_helper/Makefile: add missing .include <bsd.own.mk>,
and set the KMODULEDIR that the author seems to have intended.
 1.9  21-May-2008  he Do ${INSTALL_DIR} on all the intermediate directory levels from
the top of the tree down to where the kernel modules are installed,
so that unprivileged builds have a chance at working again.

Note, to use this fix in a tree where you've already hit on this
problem, you need to manually remove the kernel modules in
$DESTDIR/stand/<arch/, and then reinstall them from sys/modules/.
 1.8  21-May-2008  jmcneill Don't echo 'hello sh' when installing modules :-)
 1.7  20-May-2008  ad Install kernel modules into the proper locations, taking machine and
kernel version into account.
 1.6  20-May-2008  ad fno-zero-initialized-in-bss no longer required.
 1.5  20-May-2008  ad Use an ldscript to merge kernel modules' .bss sections into .data. Passing
-fno-common -fno-zero-initialized-in-bss to gcc does not work, and objcopy
refuses to expand the bss section.
 1.4  20-May-2008  ad Kill the tramp stuff, since it can be handled with lkm_map.
 1.3  03-May-2008  ad branches: 1.3.2; 1.3.4;
Pass -d to the linker, to assign space to common objects up front. The kernel
linker isn't smart enough to do that...
 1.2  02-May-2008  ad Build and install modules into /kernel/modules. Each module gets a
directory for properties, blobs, etc. It's not fixed in stone and
can easily be changed if there are issues with the location/layout.
 1.1  02-May-2008  ad - Add a bsd.kmodule.mk to build new style modules.
- Set the file suffix to .kmod
 1.3.4.3  04-Jun-2008  yamt sync with head
 1.3.4.2  18-May-2008  yamt sync with head.
 1.3.4.1  03-May-2008  yamt file bsd.kmodule.mk was added on branch yamt-pf42 on 2008-05-18 12:31:18 +0000
 1.3.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.2.3  05-Oct-2008  mjf Sync with HEAD.
 1.10.2.2  02-Jun-2008  mjf Sync with HEAD.
 1.10.2.1  31-May-2008  mjf file bsd.kmodule.mk was added on branch mjf-devfs2 on 2008-06-02 13:21:43 +0000
 1.13.2.2  06-Jun-2009  bouyer Pull up following revision(s) (requested by snj in ticket #790):
share/mk/bsd.lib.mk: revision 1.298
share/mk/bsd.man.mk: revision 1.100
share/mk/bsd.hostprog.mk: revision 1.55
distrib/sets/maketars: revision 1.66
share/zoneinfo/Makefile: revision 1.43
share/mk/bsd.kmodule.mk: revision 1.19
usr.bin/xinstall/xinstall.c: revisions 1.106 - 1.108 via patch
share/mk/bsd.prog.mk: revision 1.241
share/dict/Makefile: revision 1.17
share/mk/bsd.README: revision 1.249
distrib/common/parselist.awk: revision 1.16
share/mk/bsd.links.mk: revision 1.34
Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.
Changes for installing with a metalog:
* When installing hard links and using a metalog, if -o, -g, -m, or -f
args were explicitly specified on the command line, then believe them,
but do not implicitly believe uname/gname/mode/flags from the file
system.
* Output fields in the same order used by mtree.
Fix -Wshadow -Wcast-qual issues
Re-calculate size and digestresult after stripping, to ensure that
correct values appear in the metalog.
Add LINKSOWN, LINKSGRP, and LINKSMODE variables for use by bsd.links.mk
when installing hard links. They have no effect except when using a
metalog, in which case the information is added to the metalog. In
the future, these variables may be replaced by a method for explicitly
recording hard links in a metadata log.
Also change a few things that called ${INSTALL_LINK} without going
through bsd.links.mk.
Reviewed by perry and joerg. This should fix PR 24457 and PR 41155.
 1.13.2.1  04-Dec-2008  snj branches: 1.13.2.1.2;
Pull up following revision(s) (requested by hubertf in ticket #162):
share/mk/bsd.kmodule.mk: revision 1.16
Work around a bug in Solaris' shs (both /bin and /usr/xpg4/bin)
where "for d in ; ..." results in a syntax error.
Suggested by apb@
 1.13.2.1.2.1  06-Jun-2009  bouyer branches: 1.13.2.1.2.1.2;
Pull up following revision(s) (requested by snj in ticket #790):
share/mk/bsd.lib.mk: revision 1.298
share/mk/bsd.man.mk: revision 1.100
share/mk/bsd.hostprog.mk: revision 1.55
distrib/sets/maketars: revision 1.66
share/zoneinfo/Makefile: revision 1.43
share/mk/bsd.kmodule.mk: revision 1.19
usr.bin/xinstall/xinstall.c: revisions 1.106 - 1.108 via patch
share/mk/bsd.prog.mk: revision 1.241
share/dict/Makefile: revision 1.17
share/mk/bsd.README: revision 1.249
distrib/common/parselist.awk: revision 1.16
share/mk/bsd.links.mk: revision 1.34
Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.
Changes for installing with a metalog:
* When installing hard links and using a metalog, if -o, -g, -m, or -f
args were explicitly specified on the command line, then believe them,
but do not implicitly believe uname/gname/mode/flags from the file
system.
* Output fields in the same order used by mtree.
Fix -Wshadow -Wcast-qual issues
Re-calculate size and digestresult after stripping, to ensure that
correct values appear in the metalog.
Add LINKSOWN, LINKSGRP, and LINKSMODE variables for use by bsd.links.mk
when installing hard links. They have no effect except when using a
metalog, in which case the information is added to the metalog. In
the future, these variables may be replaced by a method for explicitly
recording hard links in a metadata log.
Also change a few things that called ${INSTALL_LINK} without going
through bsd.links.mk.
Reviewed by perry and joerg. This should fix PR 24457 and PR 41155.
 1.13.2.1.2.1.2.3  15-Feb-2014  matt kernel uses -std=gnu99
 1.13.2.1.2.1.2.2  22-Dec-2009  mrg use ${CC} -r not -Wl,-r, from -current.
 1.13.2.1.2.1.2.1  05-Sep-2009  matt Change ${LD} -r to ${CC} ${LDFLAGS} -nostdlib -Wl,-r
This is so ${CC} will invoke ld with appropriate options generated from
${LDFLAGS}
 1.18.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.29.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33.4.1  17-Feb-2012  riz Pull up following revision(s) (requested by christos in ticket #6):
distrib/sets/sets.subr: revision 1.136
share/mk/bsd.kmodule.mk: revision 1.34
sys/conf/osrelease.sh: revision 1.122
Add new -k (for kernel modules) flag to return MM.99.pp for current and MM.mm
for the release branch.
use osrelease -k to avoid that the path is 6.0_BETA
use osrelease.sh -k instead of hand-rolled logic.
 1.33.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.2  30-Oct-2012  yamt sync with head
 1.33.2.1  17-Apr-2012  yamt sync with head
 1.37.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.59.14.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.59.14.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.59.14.1  10-Jun-2019  christos Sync with HEAD
 1.59.12.1  26-Jan-2019  pgoyette Sync with HEAD
 1.62.2.1  08-Dec-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #512):

share/mk/bsd.kmodule.mk: revision 1.63

Build aarch64 modules without fp or simd instructions.
 1.81.2.1  22-Jun-2024  martin Pull up following revision(s) (requested by pgoyette in ticket #724):

sys/modules/compat_netbsd32_16/Makefile: revision 1.5
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.25
sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.26
sys/modules/compat_16/Makefile: revision 1.3
sys/modules/compat_netbsd32_13/Makefile: revision 1.5
sys/modules/compat_16/Makefile: revision 1.4
sys/arch/sun2/sun2/genassym.cf: revision 1.17
sys/arch/sun2/sun2/enable.h: revision 1.5
sys/modules/compat_13/Makefile: revision 1.3
sys/modules/compat_13/Makefile: revision 1.4
sys/modules/compat_13/Makefile: revision 1.5
sys/arch/mips/mips/netbsd32_machdep_16.c: revision 1.8
sys/modules/Makefile.compat: revision 1.1
sys/arch/mips/mips/netbsd32_machdep_13.c: revision 1.4
share/mk/bsd.kmodule.mk: revision 1.86
sys/arch/aarch64/aarch64/netbsd32_machdep_16.c: revision 1.4
sys/arch/powerpc/powerpc/compat_13_machdep.c: revision 1.23
sys/arch/aarch64/aarch64/netbsd32_machdep_13.c: revision 1.4

Import AFLAGS to allow processing of assembler files in modules.
Prerequisite for kern/583346.

Introduce sys/modules/Makefile.compat and hook some compat_1[36]
machdep code into the modules. kern/58346

Ooops missed a source file!

Proteect #include of kernel options files with #ifdef _KERNEL_OPT

XXX Add to existing 10.0 and 9.0 tickets for kern/583346

Include required headers

Add required include for compat_16 machdep code

fix the m68k compat_13 build.

include Makefile.assym to generate assym.h.
use -I. and -x assembler-with-cpp to actually use cpp and find assym.h.
also apply m68k assym.h fix here as well as compat_13.

powerpc64: Provide dummy stubs for compat1[36]
as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
sun2/genassym.cf: Skip KERNBASE for _MODULE
as it is not a compile-time constant; see sun2/vmparam.h.

It should not be, and is not actually, used for modules.

PR kern/58346

sun2/enable.h: Fix -Wold-style-definition for WARNS=5 build as modules
Finally fix sun2 build for PR kern/58346

RSS XML Feed