You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by br...@apache.org on 2025/06/30 08:31:43 UTC
svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Author: brane
Date: Mon Jun 30 08:31:43 2025
New Revision: 1926869
URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
Log:
In the CMake build, make MockHTTPinC a separats static library and change
flags to use C99 and silence all warnings only for that target.
* test/CMakeLists.txt: Include the MockHTTPinC subdirectory and don't
fiddle with the CMAKE_C_FLAGS.
(TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
(test_all): Depend on an link the mockhttpinc library.
* test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc library.
Added:
serf/trunk/test/MockHTTPinC/CMakeLists.txt (with props)
Modified:
serf/trunk/test/CMakeLists.txt
Modified: serf/trunk/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/test/CMakeLists.txt?rev=1926869&r1=1926868&r2=1926869&view=diff
==============================================================================
--- serf/trunk/test/CMakeLists.txt (original)
+++ serf/trunk/test/CMakeLists.txt Mon Jun 30 08:31:43 2025
@@ -17,6 +17,7 @@
# under the License.
# ===================================================================
+add_subdirectory(MockHTTPinC)
set(TEST_ALL_SOURCES
"test_all.c"
@@ -30,8 +31,6 @@ set(TEST_ALL_SOURCES
"mock_buckets.c"
"mock_sock_buckets.c"
"test_ssl.c"
- "MockHTTPinC/MockHTTP.c"
- "MockHTTPinC/MockHTTP_server.c"
)
set(TEST_ALL_SUITES
@@ -52,11 +51,6 @@ set(SIMPLE_TEST_TARGETS
"serf_bwtp"
)
-if(CC_LIKE_GNUC)
- # MockHTTP requires C99 standard, so use it for the test suite.
- string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-endif()
-
foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
add_executable(${TEST_TARGET} "${TEST_TARGET}.c")
add_dependencies(${TEST_TARGET} serf_static)
@@ -64,10 +58,9 @@ foreach(TEST_TARGET ${SIMPLE_TEST_TARGET
endforeach()
add_executable(test_all ${TEST_ALL_SOURCES})
-add_dependencies(test_all serf_static)
-target_compile_definitions(test_all PRIVATE "-DMOCKHTTP_OPENSSL")
+add_dependencies(test_all serf_static mockhttpinc)
target_include_directories(test_all SYSTEM BEFORE PRIVATE ${SERF_DEPENDENCY_INCLUDES})
-target_link_libraries(test_all serf_static)
+target_link_libraries(test_all serf_static mockhttpinc)
file(GLOB RESPONSE_TEST_CASES "${CMAKE_CURRENT_SOURCE_DIR}/testcases/*.response")
foreach(TEST_CASE ${RESPONSE_TEST_CASES})
Added: serf/trunk/test/MockHTTPinC/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/test/MockHTTPinC/CMakeLists.txt?rev=1926869&view=auto
==============================================================================
--- serf/trunk/test/MockHTTPinC/CMakeLists.txt (added)
+++ serf/trunk/test/MockHTTPinC/CMakeLists.txt Mon Jun 30 08:31:43 2025
@@ -0,0 +1,52 @@
+# ===================================================================
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ===================================================================
+
+set(MockHTTPinC_SOURCES
+ "MockHTTP.c"
+ "MockHTTP_server.c"
+)
+
+# Update compiler options for this library.
+if(CC_LIKE_GNUC)
+ # MockHTTP requires the C99 standard.
+ string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+ # Also silence all warnings.
+ if(NOT SHOW_MockHTTPinC_WARNINGS)
+ string(REGEX REPLACE " *-W[a-z][a-z-]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+ string(APPEND CMAKE_C_FLAGS " -w")
+ endif()
+elseif(MSVC)
+ # Silence warnings from Microsoft's compiler...
+ #
+ # ... of course, somewhere, somehow CMake adds the /W1 warning option
+ # to the command line and then MSVC complains that we're overriding /W1
+ # with /w. But it's more fun this way, or at least more #$@^&@%!
+ # Or maybe that's just MSBuild doing its magic, and it depends on the
+ # build generator. What would life be without its little mysteries?
+ if(NOT SHOW_MockHTTPinC_WARNINGS)
+ string(REGEX REPLACE " */(W|w[de])[0-9]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+ string(APPEND CMAKE_C_FLAGS " /w")
+ endif()
+endif()
+mark_as_advanced(SHOW_MockHTTPinC_WARNINGS)
+
+add_library(mockhttpinc STATIC ${MockHTTPinC_SOURCES})
+target_compile_definitions(mockhttpinc PUBLIC "MOCKHTTP_OPENSSL")
+target_include_directories(mockhttpinc SYSTEM BEFORE
+ PRIVATE ${APR_INCLUDES} ${APRUTIL_INCLUDES})
Propchange: serf/trunk/test/MockHTTPinC/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Re: svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Posted by Daniel Sahlberg <da...@gmail.com>.
Den sön 6 juli 2025 kl 03:13 skrev Branko Čibej <br...@apache.org>:
> On 5. 7. 25 19:44, Daniel Sahlberg wrote:
> > Den tis 1 juli 2025 kl 00:37 skrev Branko Čibej <br...@apache.org>:
> >
> > On 30. 6. 25 23:53, Graham Leggett wrote:
> > > On 30 Jun 2025, at 09:31, brane@apache.org wrote:
> > >
> > >> Author: brane
> > >> Date: Mon Jun 30 08:31:43 2025
> > >> New Revision: 1926869
> > >>
> > >> URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
> > <http://svn.apache.org/viewvc?rev=1926869&view=rev>
> > >> Log:
> > >> In the CMake build, make MockHTTPinC a separats static library
> > and change
> > >> flags to use C99 and silence all warnings only for that target.
> > >>
> > >> * test/CMakeLists.txt: Include the MockHTTPinC subdirectory and
> > don't
> > >> fiddle with the CMAKE_C_FLAGS.
> > >> (TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
> > >> (test_all): Depend on an link the mockhttpinc library.
> > >>
> > >> * test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc
> > library.
> > >
> > > I'm getting this sudden build failure on RHEL9, looks like some
> > header
> > > files are being included in the wrong order if google is to be
> > > believed. Do you see anything like this?
> > >
> > > [ 88%] Building C object
> > > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
> > >
> > > In file included from /usr/include/apr-1/apr.h:19,
> > >
> > > from /usr/include/apr-1/apr_pools.h:43,
> > >
> > > from
> > >
> >
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP_private.h:19,
> > >
> > > from
> > >
> > /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP.c:16:
> > >
> > > /usr/include/apr-1/apr-x86_64.h:632:2: error: #error no decision
> > has
> > > been made on APR_PATH_MAX for your platform
> > >
> > > 632 | #errorno decision has been made on APR_PATH_MAX for your
> > platform
> > >
> > > | ^~~~~
> > >
> >
> >
> > I get the same problem on Rocky Linux 9.
> >
> > $ rm -rf out; svn up -r1926868 && cmake -B out && cmake --build out
> > [... succeeds ...]
> > $ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
> > [... fails ...]
> >
> >
> > No, I'm not seeing that, and I tested on macOS, Debian 12 and
> > Windows.
> > Looking at the include trace, the headers are included are in the
> > correct order. APR_PATH_MAX should be defined in apr.h, based on
> > PATH_MAX from <limits.h>.
> >
> > apr-x86_64.h is not an APR header, so I can't even begin to guess
> > what
> > was patched on RHEL, sorry. I can't imagine in which universe it
> > wouldn't have a standard <limits.h> header.
> >
> >
> > On RHEL it seems like apr.h is only a stub to include an architecture
> > specific header, a comment in the beginning says "This file is here to
> > prevent a file conflict on multiarch systems. A conflict will occur
> > because apr.h has arch-specific definitions." and it then goes on to
> > #if defined(__i386__)
> > #include "apr-i386.h"
> > [...]
> > #elif defined(__x86_64__)
> > #include "apr-x86_64.h"
> > [...]
> > #endif
> >
> > apr-x86_64.h seems to be the "normal" generated apr.h from APR, with
> > the suitable arch-dependent defines, such as the substitution of
> > #define APR_SIZEOF_VOIDP @voidp_size@
> > I don't think RedHat's special-handling of the header is to blame here.
> >
> > By the way, all I did was restrict the -std=c99 to the MockHTTP
> > sources;
> > before this change, all the tests, including MockHTTP, used C99. So
> > there's really no change in the context of that source file.
> >
> > -- Brane
> >
> >
> > I exported the compile commands (-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
> > and compared the command lines and there are differences in the
> > command line:
> >
> > [[[
> > --- compile_commands_r1926868.txt
> > +++ compile_commands_r1926869.txt
> > [...]
> > - "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
> > -DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI
> > -DSERF_HAVE_BROTLI_DECODER_RESULT -DSERF_HAVE_GSSAPI
> > -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
> > -DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
> > -DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS
> > -I/home/dsg/serf_PR-8 -isystem /usr/include/apr-1.0 -Wall
> > -Wdeclaration-after-statement -Wmissing-prototypes -std=c99 -O3
> > -DNDEBUG -DLINUX -D_REENTRANT -D_GNU_SOURCE -o
> > CMakeFiles/test_all.dir/MockHTTPinC/MockHTTP.c.o -c
> > /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
> > [...]
> > + "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
> > -DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI
> > -DSERF_HAVE_BROTLI_DECODER_RESULT -DSERF_HAVE_GSSAPI
> > -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
> > -DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
> > -DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS
> > -isystem /usr/include/apr-1.0 -std=c99 -w -O3 -DNDEBUG -o
> > CMakeFiles/mockhttpinc.dir/MockHTTP.c.o -c
> > /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
> > [...]
> > ]]]
> >
> > In the RockyLinux instance, it seems like adding -D_REENTRANT to the
> > command line helps.
> >
> > $ rm -rf out; svn up -r1926869 && CFLAGS=-D_REENTRANT cmake -B out &&
> > cmake --build out
> > [... succeeds ...]
> >
> > I'm usually testing on Ubuntu 25.04 (under WSL) and after this
> > revision, I get the following error:
> >
> > [[[
> > [ 88%] Built target serf_bwtp
> > [ 88%] Building C object
> > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
> > /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c: In function
> > ‘methodToCode’:
> > /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c:562:23: error:
> > implicit declaration of function ‘strcasecmp’; did you mean ‘strncmp’?
> > [-Wimplicit-function-declaration]
> > 562 | if (ch1 == 'G' && strcasecmp(code, "GET") == 0)
> > | ^~~~~~~~~~
> > | strncmp
> > gmake[2]: ***
> > [test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/build.make:79:
> > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o] Error 1
> > gmake[1]: *** [CMakeFiles/Makefile2:475:
> > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/all] Error 2
> > gmake: *** [Makefile:146: all] Error 2
> > ]]]
> >
> > With the same checks as above, it seems like -D_GNU_SOURCE makes the
> > trick for me:
> >
> > $ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
> > [...fails...]
> > $ rm -rf out; svn up -r1926869 && CFLAGS=-D_GNU_SOURCE cmake -B out &&
> > cmake --build out
> > [...succeeds...]
> >
> > The same issue still exists in trunk@1926976.
> >
> > I don't know CMake well enough to understand why _REENTRANT and
> > _GNU_SOURCE are added in the main CMakeLists.txt but not in the one in
> > test/MockHTTPinC - I don't seen anything obvious in Brane's change.
> >
> > The failure in Ubuntu 25.04 is also possible to rectify by including
> > <strings.h> in MockHTTP.c.
>
>
> Right, I see the problem now. Having changed MockHTTP to a static
> library, it didn't seem necessary to make it depend on the apr and
> apr-util imported targets, only to use their include paths. And so we
> missed APR's --cpppflags and --cflags.
>
> Does r1926983 help?
>
> -- Brane
>
Yes, it does! r1926982 fail and r1926983 succeeds. Thanks!
Cheers,
Daniel
Re: svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Posted by Branko Čibej <br...@apache.org>.
On 5. 7. 25 19:44, Daniel Sahlberg wrote:
> Den tis 1 juli 2025 kl 00:37 skrev Branko Čibej <br...@apache.org>:
>
> On 30. 6. 25 23:53, Graham Leggett wrote:
> > On 30 Jun 2025, at 09:31, brane@apache.org wrote:
> >
> >> Author: brane
> >> Date: Mon Jun 30 08:31:43 2025
> >> New Revision: 1926869
> >>
> >> URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
> <http://svn.apache.org/viewvc?rev=1926869&view=rev>
> >> Log:
> >> In the CMake build, make MockHTTPinC a separats static library
> and change
> >> flags to use C99 and silence all warnings only for that target.
> >>
> >> * test/CMakeLists.txt: Include the MockHTTPinC subdirectory and
> don't
> >> fiddle with the CMAKE_C_FLAGS.
> >> (TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
> >> (test_all): Depend on an link the mockhttpinc library.
> >>
> >> * test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc
> library.
> >
> > I'm getting this sudden build failure on RHEL9, looks like some
> header
> > files are being included in the wrong order if google is to be
> > believed. Do you see anything like this?
> >
> > [ 88%] Building C object
> > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
> >
> > In file included from /usr/include/apr-1/apr.h:19,
> >
> > from /usr/include/apr-1/apr_pools.h:43,
> >
> > from
> >
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP_private.h:19,
> >
> > from
> >
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP.c:16:
> >
> > /usr/include/apr-1/apr-x86_64.h:632:2: error: #error no decision
> has
> > been made on APR_PATH_MAX for your platform
> >
> > 632 | #errorno decision has been made on APR_PATH_MAX for your
> platform
> >
> > | ^~~~~
> >
>
>
> I get the same problem on Rocky Linux 9.
>
> $ rm -rf out; svn up -r1926868 && cmake -B out && cmake --build out
> [... succeeds ...]
> $ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
> [... fails ...]
>
>
> No, I'm not seeing that, and I tested on macOS, Debian 12 and
> Windows.
> Looking at the include trace, the headers are included are in the
> correct order. APR_PATH_MAX should be defined in apr.h, based on
> PATH_MAX from <limits.h>.
>
> apr-x86_64.h is not an APR header, so I can't even begin to guess
> what
> was patched on RHEL, sorry. I can't imagine in which universe it
> wouldn't have a standard <limits.h> header.
>
>
> On RHEL it seems like apr.h is only a stub to include an architecture
> specific header, a comment in the beginning says "This file is here to
> prevent a file conflict on multiarch systems. A conflict will occur
> because apr.h has arch-specific definitions." and it then goes on to
> #if defined(__i386__)
> #include "apr-i386.h"
> [...]
> #elif defined(__x86_64__)
> #include "apr-x86_64.h"
> [...]
> #endif
>
> apr-x86_64.h seems to be the "normal" generated apr.h from APR, with
> the suitable arch-dependent defines, such as the substitution of
> #define APR_SIZEOF_VOIDP @voidp_size@
> I don't think RedHat's special-handling of the header is to blame here.
>
> By the way, all I did was restrict the -std=c99 to the MockHTTP
> sources;
> before this change, all the tests, including MockHTTP, used C99. So
> there's really no change in the context of that source file.
>
> -- Brane
>
>
> I exported the compile commands (-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
> and compared the command lines and there are differences in the
> command line:
>
> [[[
> --- compile_commands_r1926868.txt
> +++ compile_commands_r1926869.txt
> [...]
> - "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
> -DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI
> -DSERF_HAVE_BROTLI_DECODER_RESULT -DSERF_HAVE_GSSAPI
> -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
> -DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
> -DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS
> -I/home/dsg/serf_PR-8 -isystem /usr/include/apr-1.0 -Wall
> -Wdeclaration-after-statement -Wmissing-prototypes -std=c99 -O3
> -DNDEBUG -DLINUX -D_REENTRANT -D_GNU_SOURCE -o
> CMakeFiles/test_all.dir/MockHTTPinC/MockHTTP.c.o -c
> /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
> [...]
> + "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
> -DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI
> -DSERF_HAVE_BROTLI_DECODER_RESULT -DSERF_HAVE_GSSAPI
> -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
> -DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
> -DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS
> -isystem /usr/include/apr-1.0 -std=c99 -w -O3 -DNDEBUG -o
> CMakeFiles/mockhttpinc.dir/MockHTTP.c.o -c
> /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
> [...]
> ]]]
>
> In the RockyLinux instance, it seems like adding -D_REENTRANT to the
> command line helps.
>
> $ rm -rf out; svn up -r1926869 && CFLAGS=-D_REENTRANT cmake -B out &&
> cmake --build out
> [... succeeds ...]
>
> I'm usually testing on Ubuntu 25.04 (under WSL) and after this
> revision, I get the following error:
>
> [[[
> [ 88%] Built target serf_bwtp
> [ 88%] Building C object
> test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
> /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c: In function
> ‘methodToCode’:
> /home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c:562:23: error:
> implicit declaration of function ‘strcasecmp’; did you mean ‘strncmp’?
> [-Wimplicit-function-declaration]
> 562 | if (ch1 == 'G' && strcasecmp(code, "GET") == 0)
> | ^~~~~~~~~~
> | strncmp
> gmake[2]: ***
> [test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/build.make:79:
> test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o] Error 1
> gmake[1]: *** [CMakeFiles/Makefile2:475:
> test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/all] Error 2
> gmake: *** [Makefile:146: all] Error 2
> ]]]
>
> With the same checks as above, it seems like -D_GNU_SOURCE makes the
> trick for me:
>
> $ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
> [...fails...]
> $ rm -rf out; svn up -r1926869 && CFLAGS=-D_GNU_SOURCE cmake -B out &&
> cmake --build out
> [...succeeds...]
>
> The same issue still exists in trunk@1926976.
>
> I don't know CMake well enough to understand why _REENTRANT and
> _GNU_SOURCE are added in the main CMakeLists.txt but not in the one in
> test/MockHTTPinC - I don't seen anything obvious in Brane's change.
>
> The failure in Ubuntu 25.04 is also possible to rectify by including
> <strings.h> in MockHTTP.c.
Right, I see the problem now. Having changed MockHTTP to a static
library, it didn't seem necessary to make it depend on the apr and
apr-util imported targets, only to use their include paths. And so we
missed APR's --cpppflags and --cflags.
Does r1926983 help?
-- Brane
Re: svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Posted by Daniel Sahlberg <da...@gmail.com>.
Den tis 1 juli 2025 kl 00:37 skrev Branko Čibej <br...@apache.org>:
> On 30. 6. 25 23:53, Graham Leggett wrote:
> > On 30 Jun 2025, at 09:31, brane@apache.org wrote:
> >
> >> Author: brane
> >> Date: Mon Jun 30 08:31:43 2025
> >> New Revision: 1926869
> >>
> >> URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
> >> Log:
> >> In the CMake build, make MockHTTPinC a separats static library and
> change
> >> flags to use C99 and silence all warnings only for that target.
> >>
> >> * test/CMakeLists.txt: Include the MockHTTPinC subdirectory and don't
> >> fiddle with the CMAKE_C_FLAGS.
> >> (TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
> >> (test_all): Depend on an link the mockhttpinc library.
> >>
> >> * test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc library.
> >
> > I'm getting this sudden build failure on RHEL9, looks like some header
> > files are being included in the wrong order if google is to be
> > believed. Do you see anything like this?
> >
> > [ 88%] Building C object
> > test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
> >
> > In file included from /usr/include/apr-1/apr.h:19,
> >
> > from /usr/include/apr-1/apr_pools.h:43,
> >
> > from
> >
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP_private.h:19,
> >
> > from
> > /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP.c:16:
> >
> > /usr/include/apr-1/apr-x86_64.h:632:2: error: #error no decision has
> > been made on APR_PATH_MAX for your platform
> >
> > 632 | #errorno decision has been made on APR_PATH_MAX for your platform
> >
> > | ^~~~~
> >
>
I get the same problem on Rocky Linux 9.
$ rm -rf out; svn up -r1926868 && cmake -B out && cmake --build out
[... succeeds ...]
$ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
[... fails ...]
>
> No, I'm not seeing that, and I tested on macOS, Debian 12 and Windows.
> Looking at the include trace, the headers are included are in the
> correct order. APR_PATH_MAX should be defined in apr.h, based on
> PATH_MAX from <limits.h>.
>
> apr-x86_64.h is not an APR header, so I can't even begin to guess what
> was patched on RHEL, sorry. I can't imagine in which universe it
> wouldn't have a standard <limits.h> header.
>
On RHEL it seems like apr.h is only a stub to include an architecture
specific header, a comment in the beginning says "This file is here to
prevent a file conflict on multiarch systems. A conflict will occur because
apr.h has arch-specific definitions." and it then goes on to
#if defined(__i386__)
#include "apr-i386.h"
[...]
#elif defined(__x86_64__)
#include "apr-x86_64.h"
[...]
#endif
apr-x86_64.h seems to be the "normal" generated apr.h from APR, with the
suitable arch-dependent defines, such as the substitution of
#define APR_SIZEOF_VOIDP @voidp_size@
I don't think RedHat's special-handling of the header is to blame here.
> By the way, all I did was restrict the -std=c99 to the MockHTTP sources;
> before this change, all the tests, including MockHTTP, used C99. So
> there's really no change in the context of that source file.
>
> -- Brane
>
I exported the compile commands (-DCMAKE_EXPORT_COMPILE_COMMANDS=ON) and
compared the command lines and there are differences in the command line:
[[[
--- compile_commands_r1926868.txt
+++ compile_commands_r1926869.txt
[...]
- "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
-DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI -DSERF_HAVE_BROTLI_DECODER_RESULT
-DSERF_HAVE_GSSAPI -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
-DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
-DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS
-I/home/dsg/serf_PR-8 -isystem /usr/include/apr-1.0 -Wall
-Wdeclaration-after-statement -Wmissing-prototypes -std=c99 -O3 -DNDEBUG
-DLINUX -D_REENTRANT -D_GNU_SOURCE -o
CMakeFiles/test_all.dir/MockHTTPinC/MockHTTP.c.o -c
/home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
[...]
+ "command": "/usr/bin/cc -DHAVE_STDBOOL_H=1 -DMOCKHTTP_OPENSSL
-DOPENSSL_NO_STDIO -DSERF_HAVE_BROTLI -DSERF_HAVE_BROTLI_DECODER_RESULT
-DSERF_HAVE_GSSAPI -DSERF_HAVE_OPENSSL_ALPN -DSERF_HAVE_OPENSSL_MALLOC_INIT
-DSERF_HAVE_OPENSSL_SSL_LIBRARY_INIT -DSERF_HAVE_OPENSSL_VERSION_NUM
-DSERF_HAVE_OSSL_HANDSHAKE_STATE -DSERF_HAVE_SSL_LOCKING_CALLBACKS -isystem
/usr/include/apr-1.0 -std=c99 -w -O3 -DNDEBUG -o
CMakeFiles/mockhttpinc.dir/MockHTTP.c.o -c
/home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c",
[...]
]]]
In the RockyLinux instance, it seems like adding -D_REENTRANT to the
command line helps.
$ rm -rf out; svn up -r1926869 && CFLAGS=-D_REENTRANT cmake -B out && cmake
--build out
[... succeeds ...]
I'm usually testing on Ubuntu 25.04 (under WSL) and after this revision, I
get the following error:
[[[
[ 88%] Built target serf_bwtp
[ 88%] Building C object
test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
/home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c: In function ‘methodToCode’:
/home/dsg/serf_PR-8/test/MockHTTPinC/MockHTTP.c:562:23: error: implicit
declaration of function ‘strcasecmp’; did you mean ‘strncmp’?
[-Wimplicit-function-declaration]
562 | if (ch1 == 'G' && strcasecmp(code, "GET") == 0)
| ^~~~~~~~~~
| strncmp
gmake[2]: *** [test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/build.make:79:
test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:475:
test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
]]]
With the same checks as above, it seems like -D_GNU_SOURCE makes the trick
for me:
$ rm -rf out; svn up -r1926869 && cmake -B out && cmake --build out
[...fails...]
$ rm -rf out; svn up -r1926869 && CFLAGS=-D_GNU_SOURCE cmake -B out &&
cmake --build out
[...succeeds...]
The same issue still exists in trunk@1926976.
I don't know CMake well enough to understand why _REENTRANT and _GNU_SOURCE
are added in the main CMakeLists.txt but not in the one in test/MockHTTPinC
- I don't seen anything obvious in Brane's change.
The failure in Ubuntu 25.04 is also possible to rectify by including
<strings.h> in MockHTTP.c.
Cheers,
Daniel
Re: svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Posted by Branko Čibej <br...@apache.org>.
On 30. 6. 25 23:53, Graham Leggett wrote:
> On 30 Jun 2025, at 09:31, brane@apache.org wrote:
>
>> Author: brane
>> Date: Mon Jun 30 08:31:43 2025
>> New Revision: 1926869
>>
>> URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
>> Log:
>> In the CMake build, make MockHTTPinC a separats static library and change
>> flags to use C99 and silence all warnings only for that target.
>>
>> * test/CMakeLists.txt: Include the MockHTTPinC subdirectory and don't
>> fiddle with the CMAKE_C_FLAGS.
>> (TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
>> (test_all): Depend on an link the mockhttpinc library.
>>
>> * test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc library.
>
> I'm getting this sudden build failure on RHEL9, looks like some header
> files are being included in the wrong order if google is to be
> believed. Do you see anything like this?
>
> [ 88%] Building C object
> test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
>
> In file included from /usr/include/apr-1/apr.h:19,
>
> from /usr/include/apr-1/apr_pools.h:43,
>
> from
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP_private.h:19,
>
> from
> /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP.c:16:
>
> /usr/include/apr-1/apr-x86_64.h:632:2: error: #error no decision has
> been made on APR_PATH_MAX for your platform
>
> 632 | #errorno decision has been made on APR_PATH_MAX for your platform
>
> | ^~~~~
>
No, I'm not seeing that, and I tested on macOS, Debian 12 and Windows.
Looking at the include trace, the headers are included are in the
correct order. APR_PATH_MAX should be defined in apr.h, based on
PATH_MAX from <limits.h>.
apr-x86_64.h is not an APR header, so I can't even begin to guess what
was patched on RHEL, sorry. I can't imagine in which universe it
wouldn't have a standard <limits.h> header.
By the way, all I did was restrict the -std=c99 to the MockHTTP sources;
before this change, all the tests, including MockHTTP, used C99. So
there's really no change in the context of that source file.
-- Brane
Re: svn commit: r1926869 - in /serf/trunk/test: CMakeLists.txt MockHTTPinC/CMakeLists.txt
Posted by Graham Leggett <mi...@sharp.fm.INVALID>.
On 30 Jun 2025, at 09:31, brane@apache.org wrote:
> Author: brane
> Date: Mon Jun 30 08:31:43 2025
> New Revision: 1926869
>
> URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
> Log:
> In the CMake build, make MockHTTPinC a separats static library and change
> flags to use C99 and silence all warnings only for that target.
>
> * test/CMakeLists.txt: Include the MockHTTPinC subdirectory and don't
> fiddle with the CMAKE_C_FLAGS.
> (TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
> (test_all): Depend on an link the mockhttpinc library.
>
> * test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc library.
I'm getting this sudden build failure on RHEL9, looks like some header files are being included in the wrong order if google is to be believed. Do you see anything like this?
[ 88%] Building C object test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o
In file included from /usr/include/apr-1/apr.h:19,
from /usr/include/apr-1/apr_pools.h:43,
from /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP_private.h:19,
from /home/minfrin/src/apache/sandbox/serf/test/MockHTTPinC/MockHTTP.c:16:
/usr/include/apr-1/apr-x86_64.h:632:2: error: #error no decision has been made on APR_PATH_MAX for your platform
632 | #error no decision has been made on APR_PATH_MAX for your platform
| ^~~~~
make[2]: *** [test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/build.make:76: test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/MockHTTP.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:393: test/MockHTTPinC/CMakeFiles/mockhttpinc.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Regards,
Graham
--