Skip to content

Put -std=gnu17 on CC for Ruby 2.7 too, its configure ignores cflags - #2650

Merged
eregon merged 1 commit into
rbenv:masterfrom
eregon:gcc15-ruby27
Oct 31, 2026
Merged

eregon merged 1 commit into
rbenv:masterfrom
eregon:gcc15-ruby27

Conversation

@eregon

@eregon eregon commented Oct 31, 2026

Copy link
Copy Markdown
Member

Follow-up of #2649, which worked fine except on Ruby 2.7:
https://github.com/ruby/ruby-builder/actions/runs/41236443425/job/124641118792
Where the cflags=-std=gnu17 was completely ignored.

The configure script of Ruby 2.7.8 is generated by Autoconf 2.71, which runs AC_PROG_CC (setting CFLAGS=-g -O2) before Ruby's own test -z "${CFLAGS+set}" check, so the cflags configure variable is silently ignored and Ruby 2.7 was still compiled as C23 on GCC 15. Ruby 3.0+ unset CFLAGS again in that case, and the tarballs of 2.0 to 2.5 ship an Autoconf 2.69 configure which runs the check first.

The configure script of Ruby 2.7.8 is generated by Autoconf 2.71, which
runs AC_PROG_CC (setting CFLAGS=-g -O2) before Ruby's own
`test -z "${CFLAGS+set}"` check, so the cflags configure variable is
silently ignored and Ruby 2.7 was still compiled as C23 on GCC 15.
Ruby 3.0+ unset CFLAGS again in that case, and the tarballs of 2.0 to
2.5 ship an Autoconf 2.69 configure which runs the check first.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@eregon
eregon requested review from hsbt and mislav October 31, 2026 20:18
@eregon

eregon commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

Maybe we should always override CC and not rely on cflags to be more robust?

I'd imagine it's better if for some reason there is CFLAGS in the environment, OTOH CFLAGS in the environment might want to override our -std=gnu17.

@eregon

eregon commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

Same as #2649 (comment), I'll merge this now, happy to address any review later.

@eregon
eregon merged commit b84455f into rbenv:master Oct 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant