diff options
author | Jessica Clarke <jrtc27@FreeBSD.org> | 2023-07-14 04:34:03 +0000 |
---|---|---|
committer | Jessica Clarke <jrtc27@FreeBSD.org> | 2023-07-14 04:34:03 +0000 |
commit | 5d4f8df451aa942701ecfced80516f3584b589d9 (patch) | |
tree | bcff2d87a8947e7f58ef1a8ebf7157ed5b650421 | |
parent | 0a5e35a7b1811308bcb2aa2e6c7e7bd49dfc9770 (diff) | |
download | src-5d4f8df451aa942701ecfced80516f3584b589d9.tar.gz src-5d4f8df451aa942701ecfced80516f3584b589d9.zip |
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")
-rw-r--r-- | Makefile.libcompat | 6 |
1 files 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 \ |