CMake: ensure C99 is enabled for ryu #114

Closed
mwtoews wants to merge 0 commits from mwtoews:c99 into main

Building on an older computer with GNU 4.8.5 shows the error:

$ cmake ..
-- GEOS: Using default build type: Release
-- GEOS: Run-time output: /tmp/geos-3.10.0beta1/build/bin
-- GEOS: Archives output: /tmp/geos-3.10.0beta1/build/lib
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
...
$ VERBOSE=1 make
...
[  1%] Building C object src/deps/CMakeFiles/ryu.dir/ryu/d2s.c.o
cd /tmp/geos-3.10.0beta1/build/src/deps && /usr/bin/cc  -I/tmp/geos-3.10.0beta1/src/deps  -O3 -DNDEBUG -fPIC   -o CMakeFiles/ryu.dir/ryu/d2s.c.o   -c /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c
/tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c: In function ‘to_chars_fixed’:
/tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:644:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (uint32_t i = 0; i < trailing_integer_zeros; i++)
  ^
/tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:644:2: note: use option -std=c99 or -std=gnu99 to compile your code
/tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:650:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (uint32_t i = 0; i < leading_decimal_zeros; i++)
   ^
make[2]: *** [src/deps/CMakeFiles/ryu.dir/ryu/d2s.c.o] Error 1
make[2]: Leaving directory `/tmp/geos-3.10.0beta1/build'
make[1]: *** [src/deps/CMakeFiles/ryu.dir/all] Error 2
make[1]: Leaving directory `/tmp/geos-3.10.0beta1/build'
make: *** [all] Error 2

This patch sets a target property C_STANDARD 99 for ryu, which fixes the issue.

Building on an older computer with GNU 4.8.5 shows the error: ``` $ cmake .. -- GEOS: Using default build type: Release -- GEOS: Run-time output: /tmp/geos-3.10.0beta1/build/bin -- GEOS: Archives output: /tmp/geos-3.10.0beta1/build/lib -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works ... $ VERBOSE=1 make ... [ 1%] Building C object src/deps/CMakeFiles/ryu.dir/ryu/d2s.c.o cd /tmp/geos-3.10.0beta1/build/src/deps && /usr/bin/cc -I/tmp/geos-3.10.0beta1/src/deps -O3 -DNDEBUG -fPIC -o CMakeFiles/ryu.dir/ryu/d2s.c.o -c /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c: In function ‘to_chars_fixed’: /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:644:2: error: ‘for’ loop initial declarations are only allowed in C99 mode for (uint32_t i = 0; i < trailing_integer_zeros; i++) ^ /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:644:2: note: use option -std=c99 or -std=gnu99 to compile your code /tmp/geos-3.10.0beta1/src/deps/ryu/d2s.c:650:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (uint32_t i = 0; i < leading_decimal_zeros; i++) ^ make[2]: *** [src/deps/CMakeFiles/ryu.dir/ryu/d2s.c.o] Error 1 make[2]: Leaving directory `/tmp/geos-3.10.0beta1/build' make[1]: *** [src/deps/CMakeFiles/ryu.dir/all] Error 2 make[1]: Leaving directory `/tmp/geos-3.10.0beta1/build' make: *** [all] Error 2 ``` This patch sets a target property `C_STANDARD 99` for ryu, which fixes the issue.
mwtoews added 1 commit 2021-09-30 16:47:12 -07:00
continuous-integration/drone/pr Build is passing Details
f34802132c
CMake: ensure C99 is enabled for ryu

An alternative is to set(CMAKE_C_STANDARD 99) higher up to initialize the C_STANDARD property on all targets.

See https://cmake.org/cmake/help/latest/variable/CMAKE_C_STANDARD.html

An alternative is to `set(CMAKE_C_STANDARD 99)` higher up to initialize the `C_STANDARD` property on all targets. See https://cmake.org/cmake/help/latest/variable/CMAKE_C_STANDARD.html

Can you please:

  • Rebase this against current main branch
  • Look at why CI is failing (and fix it so it deosn't fail)
  • File a trac ticket explaining why this is needed and reference it in your commits
Can you please: - Rebase this against current main branch - Look at why CI is failing (and fix it so it deosn't fail) - File a trac ticket explaining why this is needed and reference it in your commits

The ci failure is bogus. Was because of the docker image we were using didn't have latest opensssl. That should be fixed now so I'll go ahead and trigger a rerun. Rerruning at https://dronie.osgeo.org/geos/geos/1101/1/2

The ci failure is bogus. Was because of the docker image we were using didn't have latest opensssl. That should be fixed now so I'll go ahead and trigger a rerun. Rerruning at https://dronie.osgeo.org/geos/geos/1101/1/2
pramsey closed this pull request 2021-10-07 09:03:00 -07:00

Thanks! Oh, and for the record, I should share my notes on how the error was replicated. Assuming you have docker:

docker run -it centos:centos7 bash

then within the VM, use the following sequence of commands:

yum install -y epel-release
yum install -y wget bzip2 cmake3 make gcc gcc-c++
update-alternatives --install /usr/bin/cmake cmake /usr/bin/cmake3 1
update-alternatives --install /usr/bin/ctest ctest /usr/bin/ctest3 1
GEOS_VERSION=geos-3.10.0beta3
wget http://download.osgeo.org/geos/${GEOS_VERSION}.tar.bz2
tar xf ${GEOS_VERSION}.tar.bz2
cd ${GEOS_VERSION}
mkdir build
cd build
cmake ..
make
ctest
Thanks! Oh, and for the record, I should share my notes on how the error was replicated. Assuming you have docker: ``` docker run -it centos:centos7 bash ``` then within the VM, use the following sequence of commands: ``` yum install -y epel-release yum install -y wget bzip2 cmake3 make gcc gcc-c++ update-alternatives --install /usr/bin/cmake cmake /usr/bin/cmake3 1 update-alternatives --install /usr/bin/ctest ctest /usr/bin/ctest3 1 GEOS_VERSION=geos-3.10.0beta3 wget http://download.osgeo.org/geos/${GEOS_VERSION}.tar.bz2 tar xf ${GEOS_VERSION}.tar.bz2 cd ${GEOS_VERSION} mkdir build cd build cmake .. make ctest ```
robe added the
bug fix
label 2021-10-09 16:00:53 -07:00
robe added this to the 3.10.0 milestone 2021-10-09 16:00:57 -07:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: geos/geos#114
There is no content yet.