Bug 286975 - Assembly files do not respect SHARED_CFLAGS
Summary: Assembly files do not respect SHARED_CFLAGS
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Many People
Assignee: Brooks Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-21 14:02 UTC by Dapeng Gao
Modified: 2025-05-24 01:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dapeng Gao 2025-05-21 14:02:39 UTC
In `share/mk/bsd.suffixes-extra.mk`, C/C++ files are built with both SHARED_CFLAGS and CFLAGS, but assembly files only receive CFLAGS.

Note that `lib/libc/sys/Makefile.inc` uses `SHARED_CFLAGS` to prevent system call code from being generated within libc, but due to this bug, the code is still being generated.
Comment 1 Brooks Davis freebsd_committer freebsd_triage 2025-05-21 23:27:01 UTC
I think the appropriate assembly targets should include SHARED_CFLAGS, but that's not a complete solution to the problem at hand.  If you just do that you end with an rtld that can't make syscalls because the code in lib/libc/sys/Makefile.inc gets applied to .nossppic files.  I think we also want to add PICO_CFLAGS, etc and use that in the libsys makefile. I'm testing a that now.
Comment 2 Brooks Davis freebsd_committer freebsd_triage 2025-05-22 15:09:32 UTC
The review stack ending with https://reviews.freebsd.org/D50466 adds SHARED_CFLAGS to the preprocessed assembly rules, but also shows why you might not want to use it (.nossppic targets are used by rtld).
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-05-23 23:49:23 UTC
A commit in branch main references this bug:

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

commit 9c20010361854a6034595fdb13cd3583ea13f289
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-05-23 23:35:21 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2025-05-23 23:38:06 +0000

    share/mk: pass SHARED_CFLAGS to PIC and PIE from assembly

    This matches what we do with C sources.  Document SHARED_CFLAGS.

    PR:             286975
    Reviewed by:    jhb, emaste
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D50466

 share/mk/bsd.README            |  3 +++
 share/mk/bsd.suffixes-extra.mk | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-05-23 23:49:25 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=387783da979eb5862f8453e15505c240cbfe28ce

commit 387783da979eb5862f8453e15505c240cbfe28ce
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-05-23 23:33:51 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2025-05-23 23:37:17 +0000

    rtld: get syscall implementations from libsys

    When I added libsys I failed to update rtld's reuse of object files
    from libc to use ones from libsys instead.  This would have turned up
    as a broken system in d7847a8d35143, but SHARED_CFLAGS is not being
    applied to assembly files.

    PR:             286975
    Reviewed by:    jrtc27, jhb
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D50475

 libexec/rtld-elf/rtld-libc/Makefile.inc | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)