NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-mips/59064 (jemalloc switch to 5.3 broke userland)



Can you try the attached patch?  Will require a clean build of
anything that uses bsd.lib.mk.  (Will also need something to wash the
embarrassment off my face if this turns out to be the culprit!)
# HG changeset patch
# User Taylor R Campbell <riastradh%NetBSD.org@localhost>
# Date 1744468511 0
#      Sat Apr 12 14:35:11 2025 +0000
# Branch trunk
# Node ID 322da4dc83ede0aad9db9ac0a0e3b31143a7eddb
# Parent  abced29d5da6d71badf2de46a8b1e589d4703b90
# EXP-Topic riastradh-pr59064-jemalloc53fallout
bsd.lib.mk: Redo rev. 1.418 more selectively.

Previously, in rev. 1.418, I had changed:

 .if ${LIBISPRIVATE} != "no"
...
 . if defined(NOSTATICLIB) && ${MKPICLIB} != "no"
 MAKESTATICLIB?=	no
 . elif ${LIBISPRIVATE} != "pic"
 MKPIC:=		no
 . endif
...
 .endif
...
-.if ${LIBISPRIVATE} == "pic"
+.if ${MKPIC} != "no"
 CFLAGS+=        -fPIC
 AFLAGS+=        -fPIC
 .endif

This was an attempt to obviate the need for grody conditionals in
private shared libraries like libuv:

.if ${MACHINE} == "sun2"
LIBISPRIVATE=yes
.else
LIBISPRIVATE=pic
.endif

This is wrong, after all, because you can also do MKPIC=no on
non-sun2 platforms if you really want a static build, and it's a mess
to have to write it out in every case.

My theory in making that change was that:

(a) on MKPIC=yes platforms in makefiles without LIBISPRIVATE=yes,
    we're building with -fPIC anyway, so ${MKPIC} != no is right;

(b) on MKPIC=yes platforms in makefiles with LIBISPRIVATE=yes, we
    shouldn't build with -fPIC and the conditional above sets
    MKPIC=no in that case, so ${MKPIC} != no is right;

(c) on MKPIC=no platforms (mainly sun2), no matter what LIBISPRIVATE
    is set to, we shouldn't build with -fPIC, so ${MKPIC} != no is
    right.

But (a) is wrong, because we use the same makefile to build .pico and
.o objects from which we link (PIC) .so and (non-PIC) .a libraries,
and the distinction is made not in CFLAGS/AFLAGS but in PICFLAGS and
CSHLIBFLAGS.

So, to obviate the need for the .if sun2 conditionals around
LIBISPRIVATE=pic, but avoid breaking everything _other_ than
LIBISPRIVATE=pic, let's make the addition of -fPIC to CFLAGS/AFLAGS
conditional on _both_ LIBISPRIVATE=pic _and_ MKPIC=yes.

PR port-mips/59064: jemalloc switch to 5.3 broke userland

diff -r abced29d5da6 -r 322da4dc83ed share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk	Fri Apr 11 19:15:42 2025 +0000
+++ b/share/mk/bsd.lib.mk	Sat Apr 12 14:35:11 2025 +0000
@@ -59,7 +59,7 @@ AFLAGS+=        ${PIE_AFLAGS}
 .endif
 # The -fPIC is needed for libraries that include other libraries
 # The order matters here, PIC needs to be last
-.if ${MKPIC} != "no"
+.if ${LIBISPRIVATE} == "pic" && ${MKPIC} != "no"
 CFLAGS+=        -fPIC
 AFLAGS+=        -fPIC
 .endif


Home | Main Index | Thread Index | Old Index