Page MenuHomeFreeBSD

bsd.compat.mk: Allow finding non-internal libraries
ClosedPublic

Authored by bdrewery on Dec 16 2020, 10:17 PM.
Tags
None
Referenced Files
F131752569: D27648.diff
Fri, Oct 10, 9:36 PM
Unknown Object (File)
Aug 14 2025, 3:08 PM
Unknown Object (File)
Jul 26 2025, 4:52 AM
Unknown Object (File)
Jul 7 2025, 10:57 AM
Unknown Object (File)
Jul 5 2025, 11:22 PM
Unknown Object (File)
Jul 5 2025, 10:08 PM
Unknown Object (File)
Jul 1 2025, 11:53 AM
Unknown Object (File)
Jun 30 2025, 2:53 PM
Subscribers

Details

Summary

Currently only libexec/rtld-elf32 uses internal LIBC_NOSSP_PIC during
the build but it gets it directly from the objdir rather than a sysroot.
For example, /usr/obj/usr/src/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a.
We don't stage lib32 libraries in WORLDTMP/usr/lib32 and doing so doesn't
buy much. If we want to use a staged lib32 library then we need to look in
LIBCOMPATTMP where they were staged. For example if LIBC_PIC were wanted then
look for /usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32/libc_pic.a.

Note this problem is part of make everything and not make buildcompat*.

Reported by: rlibby
Sponsored by: Dell EMC

Test Plan

before:

# env OBJTOP=$(make -V OBJTOP) OBJTOPOBJROOT='${OBJTOP}/'  MAKEOBJDIRPREFIX= DESTDIR='${OBJTOP}/tmp' SYSROOT='${DESTDIR}' make -C libexec/rtld-elf32 -V LIBC_PIC -V LIBC_NOSSP_PIC -V LIBC
/scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc_pic.a
/scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a
/scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc.a
# ls -al /scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc_pic.a /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a /scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc.a
ls: /scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc.a: No such file or directory
ls: /scratch/obj/root/git/freebsd2/amd64.amd64/tmp/usr/lib32/libc_pic.a: No such file or directory
-rw-r--r--  1 root  wheel  12391432 Nov 25 10:09 /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a

after:

# env OBJTOP=$(make -V OBJTOP) OBJTOPOBJROOT='${OBJTOP}/'  MAKEOBJDIRPREFIX= DESTDIR='${OBJTOP}/tmp' SYSROOT='${DESTDIR}' make -C libexec/rtld-elf32 -V LIBC_PIC -V LIBC_NOSSP_PIC -V LIBC
/scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc_pic.a
/scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a
/scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc.a
# ls -al /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc_pic.a /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc.a
-rw-r--r--  1 root  wheel  12391432 Nov 25 10:09 /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/lib/libc/libc_nossp_pic.a
-r--r--r--  1 root  wheel  12334382 Nov 20 12:28 /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc.a
-r--r--r--  1 root  wheel  12535610 Nov 25 10:12 /scratch/obj/root/git/freebsd2/amd64.amd64/obj-lib32/tmp/usr/lib32/libc_pic.a

I have not yet done a tinderbox but plan to.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I've tested this with buildworld on amd64. Before I was not able to refer to ${LIBC_PIC} from the rtld-elf32 compat Makefile and now I can.

This revision is now accepted and ready to land.Dec 16 2020, 11:51 PM

@brooks made some changes for CheriBSD to use a merged sysroot for compat and normal libraries. I wonder if we should be upstreaming that change instead?

@brooks made some changes for CheriBSD to use a merged sysroot for compat and normal libraries. I wonder if we should be upstreaming that change instead?

IIRC the change with @jhb's idea. The current changes have some issues on amd64 that would need to be solved first (the /usr/include/machine contents of amd64 aren't compatible with -m32 in some cases). I don't think it's an unsolvable problem, but will require some work.