Re: git: 7bc797e3f380 - main - Add build system support for ASAN+UBSAN instrumentation

From: Kyle Evans <kevans_at_freebsd.org>
Date: Thu, 23 Dec 2021 08:28:48 UTC
On Mon, Aug 2, 2021 at 8:35 AM Alex Richardson <arichardson@freebsd.org> wrote:
>
> The branch main has been updated by arichardson:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=7bc797e3f3807660cf98e5b1bd63545cafe820f8
>
> commit 7bc797e3f3807660cf98e5b1bd63545cafe820f8
> Author:     Alex Richardson <arichardson@FreeBSD.org>
> AuthorDate: 2021-08-02 08:48:21 +0000
> Commit:     Alex Richardson <arichardson@FreeBSD.org>
> CommitDate: 2021-08-02 13:33:24 +0000
>
>     Add build system support for ASAN+UBSAN instrumentation
>
>     This adds two new options WITH_ASAN/WITH_UBSAN that can be set to
>     enable instrumentation of all binaries with AddressSanitizer and/or
>     UndefinedBehaviourSanitizer. This current patch is almost sufficient
>     to get a complete buildworld with sanitizer instrumentation but in
>     order to actually build and boot a system it depends on a few more
>     follow-up commits.
>
>     Reviewed By:    brooks, kib, markj
>     Differential Revision: https://reviews.freebsd.org/D31043
> [...]
> --- a/share/mk/sys.mk
> +++ b/share/mk/sys.mk
> @@ -242,7 +242,7 @@ LFLAGS              ?=
>  # compiler driver flags (e.g. -mabi=*) that conflict with flags to LD.
>  LD             ?=      ld
>  LDFLAGS                ?=
> -_LDFLAGS       =       ${LDFLAGS:S/-Wl,//g:N-mabi=*:N-fuse-ld=*:N--ld-path=*}
> +_LDFLAGS       =       ${LDFLAGS:S/-Wl,//g:N-mabi=*:N-fuse-ld=*:N--ld-path=*:N-fsanitize=*:N-fno-sanitize=*}
>
>  MAKE           ?=      make
>

I know you're just the one that touched it last, but would it be any
easier to enumerate what we *can* pass to the linker from LDFLAGS
rather than what we can't? Now we need to add :N-flto* to this, and I
wonder what else we're going to wind up stumbling across as time goes
on.

Thanks,

Kyle Evans