Bug 277096 - WITHOUT_CLANG does not exclude SANITIZER_SHAREDIR from package file list
Summary: WITHOUT_CLANG does not exclude SANITIZER_SHAREDIR from package file list
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-pkgbase (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-16 17:45 UTC by Siva Mahadevan
Modified: 2024-04-28 08:05 UTC (History)
4 users (show)

See Also:
linimon: maintainer-feedback? (pkgbase)


Attachments
[PATCH] libclang_rt: avoid packaging share files when MK_CLANG=no (826 bytes, patch)
2024-02-28 00:26 UTC, Siva Mahadevan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Siva Mahadevan 2024-02-16 17:45:48 UTC
When building a Pkgbase repository using WITHOUT_CROSS_COMPILER and WITHOUT_TOOLCHAIN (which sets WITHOUT_CLANG), the following residual files are left over:

/usr/lib/clang/17/lib/freebsd/libclang_rt.asan-x86_64.so
/usr/lib/clang/17/share/asan_ignore_list.txt
/usr/lib/clang/17/share/cfi_ignore_list.txt
/usr/lib/clang/17/share/msan_ignore_list.txt

This breaks a Pkgbase system installation using `pkg install -r base -g 'FreeBSD-*'` because the resulting FreeBSD-clang pkg is broken; it erroneously depends on FreeBSD-lld, which doesn't exist due to WITHOUT_TOOLCHAIN being set.

The above files need to be excluded from the install phase to avoid building a FreeBSD-clang Pkgbase package.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-02-16 19:03:24 UTC
Hm, I don't see why only libclang_rt.asan-x86_64.so would be left? If you look at lib/Makefile, it descends into the lib/libclang_rt directory (which produces all the libclang_rt.* files, and the *_ignore_list.txt files), but it's only gated on the compiler type:

# The libraries under libclang_rt can only be built by clang.
.if ${COMPILER_TYPE} == "clang"
_libclang_rt=   libclang_rt
.elif (${MK_ASAN} != "no" || ${MK_UBSAN} != "no") && make(all)
.error Requested build with sanitizers but cannot build runtime libraries!
.endif

Ed, would we also need a test for MK_CLANG==no here?


E.g.:

.if ${COMPILER_TYPE} == "clang" && ${MK_CLANG} != "no"
_libclang_rt=   libclang_rt
.elif (${MK_ASAN} != "no" || ${MK_UBSAN} != "no") && make(all)
.error Requested build with sanitizers but cannot build runtime libraries!
.endif
Comment 2 Siva Mahadevan 2024-02-28 00:26:10 UTC
Created attachment 248805 [details]
[PATCH] libclang_rt: avoid packaging share files when MK_CLANG=no

Testing your fix worked for me and seems reasonable. I'm including your fix as an attached patch for better visibility.
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-04-25 15:44:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=514773a5486d1fa4f2d5acb5af1766965c20765b

commit 514773a5486d1fa4f2d5acb5af1766965c20765b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-25 15:05:29 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-25 15:05:29 +0000

    Skip building libclang_rt when WITHOUT_CLANG is used

    As noted in bug 277096, when building a pkgbase repository using
    WITHOUT_CROSS_COMPILER and WITHOUT_TOOLCHAIN (which sets WITHOUT_CLANG),
    the following residual files are left over:

    /usr/lib/clang/18/lib/freebsd/libclang_rt.asan-x86_64.so
    /usr/lib/clang/18/share/asan_ignore_list.txt
    /usr/lib/clang/18/share/cfi_ignore_list.txt
    /usr/lib/clang/18/share/msan_ignore_list.txt

    This is because the lib/libclang_rt directory is still descended into,
    even if WITHOUT_CLANG is used. Fix it by not descending into the
    libclang_rt directory in that case.

    PR:             277096
    Reported by:    Siva Mahadevan <me@svmhdvn.name>
    MFC after:      3 days

 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-04-28 08:05:28 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e6098a91168e4c90f6d38295f2876fe0e0fe190

commit 9e6098a91168e4c90f6d38295f2876fe0e0fe190
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-25 15:05:29 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-28 08:03:37 +0000

    Skip building libclang_rt when WITHOUT_CLANG is used

    As noted in bug 277096, when building a pkgbase repository using
    WITHOUT_CROSS_COMPILER and WITHOUT_TOOLCHAIN (which sets WITHOUT_CLANG),
    the following residual files are left over:

    /usr/lib/clang/18/lib/freebsd/libclang_rt.asan-x86_64.so
    /usr/lib/clang/18/share/asan_ignore_list.txt
    /usr/lib/clang/18/share/cfi_ignore_list.txt
    /usr/lib/clang/18/share/msan_ignore_list.txt

    This is because the lib/libclang_rt directory is still descended into,
    even if WITHOUT_CLANG is used. Fix it by not descending into the
    libclang_rt directory in that case.

    PR:             277096
    Reported by:    Siva Mahadevan <me@svmhdvn.name>
    MFC after:      3 days

    (cherry picked from commit 514773a5486d1fa4f2d5acb5af1766965c20765b)

 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)