Skip to content

Commit

Permalink
msun: LIBCSRCDIR is too fragile, use ${SRCTOP}/lib/libc instead
Browse files Browse the repository at this point in the history
LIBCSRCDIR is defined in bsd.libnames.mk, which is read in later in the
Makefile than the line:

.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 to treat these uniformily.

Sponsored by:		Netflix
Reviewed by:		sjg
Differential Revision:	https://reviews.freebsd.org/D41661
  • Loading branch information
bsdimp committed Sep 5, 2023
1 parent 815b743 commit b19d8af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
14 changes: 8 additions & 6 deletions lib/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ SHLIBDIR?= /lib

LIBC_SRCTOP?= ${.CURDIR}

# Pick the current architecture directory for libc. In general, this is
# named MACHINE_CPUARCH, but some ABIs are different enough to require
# their own libc, so allow a directory named MACHINE_ARCH to override this.

.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
# Pick the current architecture directory for libc. In general, this is named
# MACHINE_CPUARCH, but some ABIs are different enough to require their own libc,
# so allow a directory named MACHINE_ARCH to override this (though treat
# powerpc64le and powerpc64 the same).
# Note: This is copeid to msun/Makefile
M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
.if exists(${LIBC_SRCTOP}/${M})
LIBC_ARCH=${M}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
Expand Down
20 changes: 15 additions & 5 deletions lib/msun/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,27 @@ COMMON_SRCS+= s_cospi.c s_cospif.c \
s_sinpi.c s_sinpif.c \
s_tanpi.c s_tanpif.c

# LIBCSRCDIR is defined lazily, so can't be used for exists() below
LIBC_SRCTOP=${SRCTOP}/lib/libc
# Location of fpmath.h and _fpmath.h
.if exists(${LIBCSRCDIR}/${MACHINE_ARCH})
LIBC_ARCH=${MACHINE_ARCH}

# Pick the current architecture directory for libc. In general, this is named
# MACHINE_CPUARCH, but some ABIs are different enough to require their own libc,
# so allow a directory named MACHINE_ARCH to override this (though treat
# powerpc64le and powerpc64 the same).
# Note: This is copied from libc/Makefile
M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
.if exists(${LIBC_SRCTOP}/${M})
LIBC_ARCH=${M}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
CFLAGS+= -I${.CURDIR}/src -I${LIBCSRCDIR}/include \
-I${LIBCSRCDIR}/${LIBC_ARCH}

CFLAGS+= -I${.CURDIR}/src -I${LIBC_SRCTOP}/include \
-I${LIBC_SRCTOP}/${LIBC_ARCH}
SYM_MAPS+= ${.CURDIR}/Symbol.map

VERSION_DEF= ${LIBCSRCDIR}/Versions.def
VERSION_DEF= ${LIBC_SRCTOP}/Versions.def
SYMBOL_MAPS= ${SYM_MAPS}

# C99 long double functions
Expand Down

0 comments on commit b19d8af

Please sign in to comment.