git: 5d4f8df451aa - main - Makefile.libcompat: Make quoting for CC/CXX/CPP more future-proof
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Jul 2023 05:29:00 UTC
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=5d4f8df451aa942701ecfced80516f3584b589d9
commit 5d4f8df451aa942701ecfced80516f3584b589d9
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-07-14 04:34:03 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-07-14 04:34:03 +0000
Makefile.libcompat: Make quoting for CC/CXX/CPP more future-proof
bmake's :Q is for quoting outside of double quotes, but here is inside
double quotes, and as a result it ends up quoting characters that don't
have a special meaning inside double quotes. On the surface this would
seem harmless, but POSIX sh has a strange behaviour (differing from
outside double quotes) that, inside double quotes, a backslash before a
character that never has a special meaning inside double quotes is
passed through. As a result, should LIB${_LIBCOMPAT}CFLAGS contain
something like -DFOO\(x\)=x, we would form "... -DFOO\\\(x\\\)=x ...",
which would be parsed as -DFOO\\(x\\)=x, since the parentheses are never
special inside double quotes (but the backslash itself is), not the
original -DFOO\(x\)=x as intended.
Instead, construct the whole string as a bmake expression and use :Q on
that, without the manual double quotes around everything. Note that the
:L modifier lets you treat an expression like a variable expansion and
apply modifiers to it, i.e. ${expr:L:...} is the same as tmp=expr
${tmp:...} (in essence, ignoring possible differences due to deferred
substitution).
Improves: 537f945fc89f ("Makefile.libcompat: Quote CFLAGS and CXXFLAGS for sub-make")
---
Makefile.libcompat | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile.libcompat b/Makefile.libcompat
index e8d33b905559..b21e27105e99 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -25,9 +25,9 @@ LIB${_LIBCOMPAT}WMAKEENV+= \
# Don't rebuild build-tools targets during normal build.
LIB${_LIBCOMPAT}WMAKEENV+= BUILD_TOOLS_META=.NOMETA
.endif
-LIB${_LIBCOMPAT}WMAKEFLAGS+= CC="${XCC} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
- CXX="${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS:@v@${v:Q}@} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
- CPP="${XCPP} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
+LIB${_LIBCOMPAT}WMAKEFLAGS+= CC=${${XCC} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
+ CXX=${${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
+ CPP=${${XCPP} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
DESTDIR=${WORLDTMP} \
-DNO_CPU_CFLAGS \
MK_BOOT=no \