<blockquote>
<p><code>%remove_optflags 'undesirable'</code><br>
<code>%replace_optflags 'oldval' 'newval'</code></p>
</blockquote>
<p>Then we can have just the simple one. Following works for me:</p>
<pre><code>$ rpm --define "%optflags -flto=auto -O2" --define "%replace_optflags() %global optflags %(echo %optflags | sed s/%{?1}/%{?2}/)" --eval '%replace_optflags "-flto=auto"' --eval 'optflags=%optflags'

optflags= -O2
rpm --define "%optflags -flto=auto -O2" --define "%replace_optflags() %global optflags %(echo %optflags | sed s/%{?1}/%{?2}/)" --eval '%replace_optflags "-O2" "-O3"' --eval 'optflags=%optflags'

optflags=-flto=auto -O3
</code></pre>
<p>Thoughts?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/rpm-software-management/rpm/issues/814?email_source=notifications&email_token=ADLPZU3EACO3O54JVIVRNH3QELAJLA5CNFSM4ILLC5TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4F2YAA#issuecomment-520858624">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ADLPZUZX2HCMGKXF3K6U2RLQELAJLANCNFSM4ILLC5TA">mute the thread</a>.<img src="https://github.com/notifications/beacon/ADLPZUYLKBPBZKMB46JKHRDQELAJLA5CNFSM4ILLC5TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4F2YAA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/rpm-software-management/rpm/issues/814?email_source=notifications\u0026email_token=ADLPZU3EACO3O54JVIVRNH3QELAJLA5CNFSM4ILLC5TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4F2YAA#issuecomment-520858624",
"url": "https://github.com/rpm-software-management/rpm/issues/814?email_source=notifications\u0026email_token=ADLPZU3EACO3O54JVIVRNH3QELAJLA5CNFSM4ILLC5TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4F2YAA#issuecomment-520858624",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>