Skip to content

Fix compilation with GCC 4.3 - #20902

Closed
orgads wants to merge 1 commit into
curl:masterfrom
orgads:gcc-4-pragma
Closed

orgads wants to merge 1 commit into
curl:masterfrom
orgads:gcc-4-pragma

Conversation

@orgads

@orgads orgads commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

error: pragma.... is not supported inside function

@orgads
orgads force-pushed the gcc-4-pragma branch 5 times, most recently from 33c1b8b to 48ab870 Compare March 12, 2026 10:33
Comment thread lib/curl_setup.h Resolved
@vszakats

Copy link
Copy Markdown
Member

If all this complexity is necessary to maintain <4.6 support,
I'm opposing strongly to do it. It's unmaintainable.

@orgads

orgads commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

If all this complexity is necessary to maintain <4.6 support, I'm opposing strongly to do it. It's unmaintainable.

I can limit the change to the places with -Wformat-nonliteral only, this is where we were hit. I thought that if I already fix this, it would be better to cover all the cases of pragma GCC diagnostic push, but I'd be fine with the new ones only.

@orgads

orgads commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

@icing

icing commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Not to look down on your efforts, but I think the project does not want to maintain such old gcc versions. It's not to get it "right" now, it also requires efforts in the future.

@orgads

orgads commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Not to look down on your efforts, but I think the project does not want to maintain such old gcc versions. It's not to get it "right" now, it also requires efforts in the future.

According to all the PickyWarnings logic and all the tweaks in curl_setup, it looks to me like the project actually cares to maintain compilation with everything out there...

I tried to keep the change minimal now. Please review.

Comment thread CMake/PickyWarnings.cmake Resolved
@vszakats

vszakats commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

Not to look down on your efforts, but I think the project does not want to maintain such old gcc versions. It's not to get it "right" now, it also requires efforts in the future.

According to all the PickyWarnings logic and all the tweaks in curl_setup, it looks to me like the project actually cares to maintain compilation with everything out there...

It's mostly remains from the now deleted WinCE support.
Extended after report for a beta release of an ancient GCC
used in an embedded environment.

It's a burden to carry.

May I ask, what do you need such old GCC for?

@orgads

orgads commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

May I ask, what do you need such old GCC for?

We have a very old embedded hardware which uses a very old kernel, and we use a very old toolchain for it, because updating the toolchain would require updating the kernel, which is a great mess.

So far we maintain it successfully. We plan to ditch it in several years, but that won't be soon.

@orgads
orgads force-pushed the gcc-4-pragma branch 2 times, most recently from b43e121 to 25e7600 Compare March 12, 2026 14:00
* GCC diagnostic push was added in GCC 4.6.
* This warning is only enabled in >=4.8 (-Wformat=2).
@icing

icing commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

May I ask, what do you need such old GCC for?

We have a very old embedded hardware which uses a very old kernel, and we use a very old toolchain for it, because updating the toolchain would require updating the kernel, which is a great mess.

So far we maintain it successfully. We plan to ditch it in several years, but that won't be soon.

I can understand your point of view. I do not see us supporting such old toolchains for free. Do you want to talk about commercial support for this?

vszakats added a commit that referenced this pull request Mar 12, 2026
- tool_getparam: revert an unnecessary/no-op C89 warning silencer.
  Follow-up to 09c9afd #20363

- tool_writeout: add comment saying silencing is a no-op for llvm/clang.
  For `strftime()` it is a GCC-specific, as of llvm/clang v22.1.0.
  Follow-up to f07a98a #20366

- unit1652: drop always-false `!defined(__clang__)` guard.
  Pointed-out-by: Orgad Shaneh
  Ref: #20902
  Follow-up to 7e814c8 #16062

- unit1652: document that `-Wformat` is necessary for GCC v5 to v8.
  Follow-up to 71cf0d1 #14772

Closes #20908
@vszakats vszakats closed this in 578ee6b Mar 18, 2026
@orgads
orgads deleted the gcc-4-pragma branch March 18, 2026 10:35
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
- tool_getparam: revert an unnecessary/no-op C89 warning silencer.
  Follow-up to 09c9afd curl#20363

- tool_writeout: add comment saying silencing is a no-op for llvm/clang.
  For `strftime()` it is a GCC-specific, as of llvm/clang v22.1.0.
  Follow-up to f07a98a curl#20366

- unit1652: drop always-false `!defined(__clang__)` guard.
  Pointed-out-by: Orgad Shaneh
  Ref: curl#20902
  Follow-up to 7e814c8 curl#16062

- unit1652: document that `-Wformat` is necessary for GCC v5 to v8.
  Follow-up to 71cf0d1 curl#14772

Closes curl#20908
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
…warnings

Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98a curl#20366
Fixes curl#20892
Fixes curl#20924
Closes curl#20902
Closes curl#20907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants