diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index a443de7b71b8..48b23f8900ed 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -114,6 +114,10 @@ DEFINED_PROF= ${PROF} # can override the others. CFLAGS+= ${CONF_CFLAGS} +.if ${LINKER_TYPE} != "bfd" || ${LINKER_VERSION} > 21750 +LDFLAGS+= -Wl,--build-id=sha1 +.endif + # Optional linting. This can be overridden in /etc/make.conf. LINTFLAGS= ${LINTOBJKERNFLAGS} diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index fb00cadeb448..61c136e14f3e 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -125,6 +125,10 @@ CFLAGS.gcc+= --param large-function-growth=1000 CFLAGS+= -fno-common LDFLAGS+= -d -warn-common +.if ${LINKER_TYPE} != "bfd" || ${LINKER_VERSION} > 21750 +LDFLAGS+= -Wl,--build-id=sha1 +.endif + CFLAGS+= ${DEBUG_FLAGS} .if ${MACHINE_CPUARCH} == amd64 CFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer