Conversation
kolyshkin
left a comment
There was a problem hiding this comment.
Oh my.
I think the right approach here should use something like
if [ -v CFLAGS ]; then
local original_cflags="$CFLAGS"
fi
...
# Reset CFLAGS.
if [ -v original_cflags ]; then
CFLAGS="$original_cflags"
else
unset CFLAGS
fiThe per-architecture loop resets CFLAGS to an empty value when the caller leaves it unset. set_cross_vars then exports it, causing configure to skip its default -g -O2 flags. Release builds link against these per-architecture copies of libseccomp, including for the native architecture. Unset CFLAGS when it was originally unset, allowing configure to apply its defaults on architectures that do not add their own CFLAGS. Preserve explicitly empty and custom caller values. Signed-off-by: Ciprian Hacman <ciprian@hakman.dev>
a2e4c45 to
29be50b
Compare
|
Thanks for the review @kolyshkin, updated. |
kolyshkin
left a comment
There was a problem hiding this comment.
Thanks, this works!
Yet better idea is to not change CFLAGS in set_cross_vars, so we won't have to save/restore it
We also have the same issue in script/release_build.sh. Opened #5464 as an alternative |
Thanks, looks like a more complete alternative. I don't think there's any reason to keep this one open anymore. |
When
CFLAGSis unset, the per-architecture libseccomp build loop resets it to an empty value andset_cross_varsexports it. This prevents Autoconf from applying its default-g -O2flags, leaving libseccomp unoptimized. Release builds link against these per-architecture copies, including for the native architecture.Restore an unset
CFLAGSbefore each architecture build instead of exporting an empty value. This lets configure choose its defaults whenset_cross_varsdoes not add architecture-specificCFLAGS, while preserving explicitly empty and custom caller values.In an amd64 comparison of matched runc v1.5.1 builds with libseccomp 2.6.0 on an Azure D16ds_v5, building libseccomp with
-g -O2instead of emptyCFLAGSreduced meanrunc runtime with containerd's RuntimeDefault seccomp profile from 43.16 ms to 36.24 ms, approximately 16%, over 200 samples per variant.