Skip to content

Fix compiler pragma warning on GCC <= 4.2 #16152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

Fix compiler pragma warning on GCC <= 4.2 #16152

wants to merge 5 commits into from

Conversation

prpr19xx
Copy link
Contributor

@prpr19xx prpr19xx commented Feb 2, 2025

I get this error on GCC 4.5.2:
curl_setup.h:37: warning: unknown option after '#pragma GCC diagnostic' kind

I don't known which version implemented this, possibly 4.6, but just rule out any 4.x version, which is probably good enough.

@testclutch
Copy link

Analysis of PR #16152 at 9c90db75:

Test http/test_14_auth.py::TestAuth::test_14_03_digest_put_auth[h3] failed, which has NOT been flaky recently, so there could be a real issue in this PR.

Generated by Testclutch

@vszakats
Copy link
Member

vszakats commented Feb 3, 2025

This pragma works without warning in 4.4.0 according to a recent CeGCC port #16062. This is confirmed by godbolt.org with 4.4.7.

More details here: https://gcc.gnu.org/legacy-ml/gcc-help/2011-01/msg00113.html

Can you share your command-line, platform and other details to replicate this?

@prpr19xx
Copy link
Contributor Author

prpr19xx commented Feb 3, 2025

Sorry, I've got my version numbers mixed up. The cross-compiler used is 4.2.0. Here's some test case output:

$ cat gcctest.c
#pragma GCC diagnostic ignored "-Wsign-conversion"

int main(void)
{
    return 0;
}

$ mipsel-linux-gcc -c gcctest.c
gcctest.c:1: warning: unknown option after '#pragma GCC diagnostic' kind

$ mipsel-linux-gcc -v
Using built-in specs.
Target: mipsel-linux-uclibc
Configured with: ../gcc-4.2.0-20070124/configure --prefix=/opt/toolchains/crosstools_hf-linux-2.6.18.0_gcc-4.2-11ts_uclibc-nptl-0.9.29-20070423_20090508/ --build=mipsel-linux --host=mipsel-linux --target=mipsel-linux-uclibc --with-build-sysroot=/usr/src/redhat/BUILD/build_uClibc --enable-languages=c,c++ --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --with-float=hard --enable-threads --infodir=/opt/toolchains/crosstools_hf-linux-2.6.18.0_gcc-4.2-11ts_uclibc-nptl-0.9.29-20070423_20090508/info --mandir=/opt/toolchains/crosstools_hf-linux-2.6.18.0_gcc-4.2-11ts_uclibc-nptl-0.9.29-20070423_20090508/man --with-arch=mips32 --disable-libmudflap --disable-nls --with-gnu-plts
Thread model: posix
gcc version 4.2.0 20070124 (prerelease) - BRCM 11ts-20090508

@prpr19xx prpr19xx changed the title Fix compiler pragma warning on GCC 4.5.2 Fix compiler pragma warning on GCC >4.2 Feb 3, 2025
@vszakats
Copy link
Member

vszakats commented Feb 3, 2025

There are more places in the code that may hit such pragma.
IMO we should either address them all, or draw a limit for legacy gcc
version support. Addressing them brings up the issue of how to make
tests with such old version. 4.2 was released in 2007.

@prpr19xx prpr19xx changed the title Fix compiler pragma warning on GCC >4.2 Fix compiler pragma warning on GCC <= 4.2 Feb 3, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Feb 3, 2025
We don't pursue this, and the necessary `#pragma` got in the way of
compiling curl with gcc 4.2 and older. Drop the logic completely.

Follow-up to 8a266ac curl#15939

Reported-by: prpr19xx on Github
Fixes curl#16152
@vszakats
Copy link
Member

vszakats commented Feb 3, 2025

@prpr19xx I created #16157 which deletes the code that created this problem.
Can you re-test and tell if it fixes it for you?

vszakats added a commit to vszakats/curl that referenced this pull request Feb 3, 2025
We don't pursue this, and the necessary `#pragma` got in the way of
compiling curl with gcc 4.2 and older. Drop the logic completely.

Follow-up to 8a266ac curl#15939

Reported-by: prpr19xx on Github
Fixes curl#16152
@prpr19xx
Copy link
Contributor Author

prpr19xx commented Feb 3, 2025

@vszakats Yes #16157 works fine for me, thanks.

@vszakats
Copy link
Member

vszakats commented Feb 3, 2025

Note for future ref.: This is 4.2.0 pre-release. 4.2.0 stable does support this pragma.

@vszakats vszakats closed this in 2ed232a Feb 3, 2025
@vszakats
Copy link
Member

vszakats commented Feb 3, 2025

Thanks @prpr19xx for your patch and reports. Merged #16157, and this should now be fixed.

@prpr19xx prpr19xx deleted the prpr19xx-gcc452-pragma branch February 3, 2025 21:39
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
We don't pursue this, and the necessary `#pragma` got in the way of
compiling curl with gcc 4.2 and older. Drop the logic completely.

Follow-up to 8a266ac curl#15939

Reported-by: prpr19xx on Github
Fixes curl#16152
Closes curl#16157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants