NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/60000: split debug data rules broke ${.TARGET}-dependent flags
>Number: 60000
>Category: toolchain
>Synopsis: split debug data rules broke ${.TARGET}-dependent flags
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 13 08:05:00 +0000 2026
>Originator: Taylor R Campbell
>Release: current, 11?
>Organization:
The ${.TARGET}BSD Foundation
>Environment:
>Description:
Once upon a time, we built program foo and its debug data
foo.debug by two recipes, which roughly reduce to:
foo: foo.o bar.o baz.o
ld -o foo foo.o bar.o baz.o ${LDFLAGS}
foo.debug: foo
objcopy --only-keep-debug foo foo.debug
objcopy --strip-debug \
-p -R .gnu_debuglink --add-gnu-debuglink=foo.debug \
foo
The foo.debug rule is troublesome, though, because it
overwrites foo in place -- this breaks parallel runs and
changes the mtime of foo.debug's own prerequisite foo.
To fix this, I split it into three recipes with appropriate
dependencies:
foo.link: foo.o bar.o baz.o
ld -o foo foo.o bar.o baz.o ${LDFLAGS}
foo.debug: foo.link
objcopy --only-keep-debug foo.link foo.debug
foo: foo.link
objcopy --strip-debug \
-p -R .gnu_debuglink --add-gnu-debuglink=foo.debug \
foo.link foo
Unfortunately, this change had a side effect: any
${.TARGET}-dependent expansion in LDFLAGS is now different,
because previously ${.TARGET} was `foo' and now ${.TARGET} is
`foo.link'. So logic like this changed:
LDFLAGS+= ${"${LDSTATIC.${.TARGET}}" == "-static" :? : ${PIE_LDFLAGS}}
https://nxr.netbsd.org/xref/src/share/mk/bsd.prog.mk?r=1.361#41
Before, if you defined LDSTATIC.foo=-static, it would prevent
LDFLAGS from having `-pie' added. But after the change, you
would have to define LDSTATIC.foo.link=-static to have the same
effect.
>How-To-Repeat:
cd src/tests/lib/csu && nbmake-$MACHINE h_initfini2
This should be a static _non-pie_ because LDSTATIC.h_initfini2
is set to `-static', but instead it is built as a static pie.
>Fix:
1. Audit all the .TARGET-dependent variables.
2. In this case, consider instead using:
.for _P in ${PROGS}
LDFLAGS.${_P}+= ${"${LDSTATIC.${_P}}" == "-static" :? : ${PIE_LDFLAGS}}
.endfor
Home |
Main Index |
Thread Index |
Old Index