-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Do not remove -O0 in the middle of a flag #15828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Discard known '-O' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit
I'll just try to reproduce here that nix shell bug with ${SED} vs $SED here what was the problem back then... Edit: I see, got it. Relative paths were the problem back then. But that was happening only where the IFS got changed and those dots need to be used to get the version. For example, |
changequote({,}) | ||
sed_script='s/\([\t ]\|^\)-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)/\1/g' | ||
changequote([,]) | ||
CFLAGS=`echo "$CFLAGS" | sed -e "$sed_script"` | ||
CXXFLAGS=`echo "$CFLAGS" | sed -e "$sed_script"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changequote({,}) | |
sed_script='s/\([\t ]\|^\)-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)/\1/g' | |
changequote([,]) | |
CFLAGS=`echo "$CFLAGS" | sed -e "$sed_script"` | |
CXXFLAGS=`echo "$CFLAGS" | sed -e "$sed_script"` | |
sed_script='s/\([[\t ]]\|^\)-O\([[0-9gsz]]\|fast\|\)\([[\t ]]\|$\)/\1/g' | |
CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script") | |
CXXFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script") |
I've removed previous suggestion and added all in one:
- backticks command substitution replaced with $(...)
- $SED used instead of sed direct command so SED variable can be set at the configure step
SED=../path/to/sed ./configure
- changequote builtin M4 macro is something that ideally should be avoided for the cost of duplicating the [ and ] characters in the sed_script variable a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry and another one. Probably the most important one as CXXFLAGS should be its own variable instead.
diff --git a/build/php.m4 b/build/php.m4
index dee47f6e1a..e13fc3367e 100644
--- a/build/php.m4
+++ b/build/php.m4
@@ -2745,5 +2745,5 @@ dnl
AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
sed_script='s/\([[\t ]]\|^\)-O\([[0-9gsz]]\|fast\|\)\([[\t ]]\|$\)/\1/g'
CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
- CXXFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
+ CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This backports #9647 from master and improves it to avoid accidentally breaking flags ending with something looking like an optimization flag. (#9647 fixed that for flags starting with an optimization flag.)
This should fix #15826