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.
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.
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).
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(-)
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(-)