Page MenuHomeFreeBSD

msun: LIBCSRCDIR is too fragile, use ${SRCTOP}/lib/libc instead
ClosedPublic

Authored by imp on Aug 30 2023, 10:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 3:35 PM
Unknown Object (File)
Mon, Nov 18, 6:36 AM
Unknown Object (File)
Sat, Nov 16, 11:04 AM
Unknown Object (File)
Oct 19 2024, 11:54 PM
Unknown Object (File)
Oct 16 2024, 7:11 PM
Unknown Object (File)
Oct 16 2024, 7:11 PM
Unknown Object (File)
Oct 16 2024, 7:11 PM
Unknown Object (File)
Oct 16 2024, 7:11 PM
Subscribers
None

Details

Summary

LIBCSRCDIR is defined in bsd.libnames.mk, which is read in later
in the Makefile than
.if exists(${LIBCSRCDIR}/${MACHINE_ARCH})
so we test to see if /${MARCHIN_ARCH} exists which it usually
doesn't (but did for me since I mounted 13.2R SD image there).
Move to defining our own LIBC_SRCTOP in terms of SRCTOP.

Sponsored by: Netflix

Test Plan
sudo mkdir /armv7
make buildworld TARGET_ARCH=armv7

fails because ${LIBSRCDIR} was empty for the exists phase of parsing. If I
have /armv7 then msun fails to build. If I remove /armv7, then it works by
accident (which kinda suggests MACHINE_CPUARCH is always right)...

Diff Detail

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

Event Timeline

imp requested review of this revision.Aug 30 2023, 10:04 PM
imp created this revision.
imp edited the test plan for this revision. (Show Details)

?= isn't the problem, rather that bsd.libnames.mk isn't included yet (and is meant to not be; bsd.lib.mk is the thing that's meant to include it if needed, and bsd.libnames.mk will error if included directly) so the variable is not yet defined (but will be by the time CFLAGS et al are evaluated)

FWIW ?= has nothing to do with it, rather the order in which things a read, ie bsd.libnames.mk isn't read until long after the value of LIBCSRCDIR is needed.

This revision is now accepted and ready to land.Aug 30 2023, 10:09 PM

(which kinda suggests MACHINE_CPUARCH is always right)

The only arches where the correct (as per lib/libc's own definition) LIBC_ARCH isn't MACHINE_CPUARCH is powerpc64(le), which use a common powerpc64 directory, but powerpc64's _fpmath.h is identical to powerpc's _fpmath.h so it happens to not matter.

lib/msun/Makefile
101

Conventionally called LIBC_SRCTOP

102–103

Technically needs :S/powerpc64le/powerpc64/ like elsewhere; harmless given _fpmath.h is the same between powerpc and powerpc64, but could be an issue in future

?= isn't the problem, rather that bsd.libnames.mk isn't included yet (and is meant to not be; bsd.lib.mk is the thing that's meant to include it if needed, and bsd.libnames.mk will error if included directly) so the variable is not yet defined (but will be by the time CFLAGS et al are evaluated)

I'll adjust the commit message.

lib/msun/Makefile
101

OK.

102–103

So maybe it should just be MACHINE_CPUARCH in the future... when we kill 32-bit powerpc :)

This revision now requires review to proceed.Aug 30 2023, 10:52 PM
lib/msun/Makefile
102–111

Yea. This is stupidly gross.

MACHINE_CPUARCH should be powerpc64 for powerpc64 and powerpc64le and powerpc for powerpc and powerpcspe.

Most places in the tree do this, de-facto, but have convoluted logic to make is so. I should do a pass to fix that.

But for now, I've made both here and libc better and will upload that.

lib/libc/Makefile
11

Thinking about it... I should add a note this is copied to msun (and vice versa).

This revision was not accepted when it landed; it landed in state Needs Review.Sep 5 2023, 10:09 PM
This revision was automatically updated to reflect the committed changes.