Skip to content

[1.5] script: do not modify CFLAGS in set_cross_vars - #5465

Draft
kolyshkin wants to merge 1 commit into
opencontainers:release-1.5from
kolyshkin:1.5-5464
Draft

kolyshkin wants to merge 1 commit into
opencontainers:release-1.5from
kolyshkin:1.5-5464

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

Backport of #5464 to release-1.5. Original description follows.


This is an alternative to #5456.

When cross-building libseccomp, build_libseccomp resets CFLAGS to an empty value (if it was unset) before each architecture, and set_cross_vars exports it. Autoconf only applies its default CFLAGS (-g -O2) when CFLAGS is unset, so the per-architecture libseccomp builds (which release binaries link against, including for the native architecture) end up unoptimized. See #5456 for performance numbers.

The only reason CFLAGS was touched at all is that set_cross_vars puts -m32 -march=... there for 386, which is why callers had to save and restore it. Pass these flags via CC instead (as autoconf documentation suggests for multilib builds), so set_cross_vars no longer modifies CFLAGS, and remove the now-unneeded save/restore from both build-seccomp.sh and release_build.sh.

This way, a user-provided CFLAGS is passed as is, and if it is unset, configure uses its defaults for all architectures, including 386 (which #5456 does not fix, since set_cross_vars makes CFLAGS non-empty there).

Tested libseccomp 2.6.0 configure (on Debian trixie) with the new set_cross_vars:

  • 386: CC='x86_64-linux-gnu-gcc -m32 -march=i686', CFLAGS='-g -O2';
  • amd64: CC='x86_64-linux-gnu-gcc', CFLAGS='-g -O2'.

When cross-building libseccomp, build_libseccomp resets CFLAGS to an
empty value (if it was unset) before each architecture, and
set_cross_vars exports it. Autoconf only applies its default CFLAGS
(-g -O2) when CFLAGS is unset, so the per-architecture libseccomp
builds (which are what release binaries link against, including for
the native architecture) end up unoptimized.

The only reason CFLAGS was touched at all is that set_cross_vars puts
-m32 -march=... there for 386, which is why callers had to save and
restore it. Pass these flags via CC instead (as autoconf documentation
suggests for multilib builds), so set_cross_vars no longer modifies
CFLAGS, and remove the now-unneeded save/restore dance from both
build-seccomp.sh and release_build.sh.

This way, a user-provided CFLAGS is passed as is, and if it is unset,
configure uses its defaults for all architectures, including 386.

Note that go build does not use CFLAGS (cgo uses CGO_CFLAGS), and it
handles CC with arguments just fine.

Reported-by: Ciprian Hacman <ciprian@hakman.dev>
(cherry picked from commit 6bcc532)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin added the backport/1.5-pr A backport PR to release-1.5 label Sep 13, 2026
@kolyshkin kolyshkin added this to the 1.5.2 milestone Sep 13, 2026
@AkihiroSuda

Copy link
Copy Markdown
Member

Marking as a draft as #5464 is not merged.
Please click "ready for review" when ready.

@AkihiroSuda
AkihiroSuda marked this pull request as draft September 17, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.5-pr A backport PR to release-1.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants