DaanDeMeyer / reproc

A cross-platform (C99/C++11) process library
MIT License
552 stars 65 forks source link

Build failure with gcc 13 #94

Open opoplawski opened 1 year ago

opoplawski commented 1 year ago

In Fedora 38/Rawhide with gcc 13 reproc 14.2.4 fails to build with:

[ 94%] Building CXX object reproc++/CMakeFiles/reproc++.dir/src/reproc.cpp.o
cd /home/orion/fedora/reproc/reproc-14.2.4/redhat-linux-build/reproc++ && /usr/lib64/ccache/g++ -DREPROCXX_BUILDING -I/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include -I/home/orion/fedora/reproc/reproc-14.2.4/reproc/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -std=c++11 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT reproc++/CMakeFiles/reproc++.dir/src/reproc.cpp.o -MF CMakeFiles/reproc++.dir/src/reproc.cpp.o.d -o CMakeFiles/reproc++.dir/src/reproc.cpp.o -c /home/orion/fedora/reproc/reproc-14.2.4/reproc++/src/reproc.cpp
In file included from /home/orion/fedora/reproc/reproc-14.2.4/reproc++/src/reproc.cpp:1:
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:95:5: error: declaration of 'reproc::options::<unnamed struct> reproc::options::env' changes meaning of 'env' [-fpermissive]
   95 |   } env = {};
      |     ^~~
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:91:5: note: used here to mean 'class reproc::env'
   91 |     env::type behavior;
      |     ^~~
In file included from /home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:11:
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/env.hpp:8:7: note: declared here
    8 | class env : public detail::array {
      |       ^~~
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:107:5: error: declaration of 'reproc::options::<unnamed struct> reproc::options::redirect' changes meaning of 'redirect' [-fpermissive]
  107 |   } redirect = {};
      |     ^~~~~~~~
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:102:5: note: used here to mean 'struct reproc::redirect'
  102 |     redirect err;
      |     ^~~~~~~~
/home/orion/fedora/reproc/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:68:8: note: declared here
   68 | struct redirect {
      |        ^~~~~~~~
DaanDeMeyer commented 1 year ago

I just pushed a new commit to main that hopefully fixes this, can you give it a try?

zaitor commented 1 year ago

Hi - seeing the same in openSUSE. I've added the 2 last commits you did, and its "better" but not there yet.

[   24s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/reproc-14.2.4/build'
[   24s] [ 78%] Building CXX object reproc++/CMakeFiles/reproc++.dir/src/reproc.cpp.o
[   24s] cd /home/abuild/rpmbuild/BUILD/reproc-14.2.4/build/reproc++ && /usr/bin/c++ -DREPROCXX_BUILDING -I/home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/include -I/home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc/include -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -O2 -g -DNDEBUG -std=c++11 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT reproc++/CMakeFiles/reproc++.dir/src/reproc.cpp.o -MF CMakeFiles/reproc++.dir/src/reproc.cpp.o.d -o CMakeFiles/reproc++.dir/src/reproc.cpp.o -c /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/src/reproc.cpp
[   24s] In file included from /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/src/reproc.cpp:1:
[   24s] /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:95:5: error: declaration of 'reproc::options::<unnamed struct> reproc::options::env' changes meaning of 'env' [-Wchanges-meaning]
[   24s]    95 |   } env = {};
[   24s]       |     ^~~
[   24s] /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:91:10: note: used here to mean 'class reproc::env'
[   24s]    91 |     enum env::type behavior;
[   24s]       |          ^~~
[   24s] In file included from /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/include/reproc++/reproc.hpp:11:
[   24s] /home/abuild/rpmbuild/BUILD/reproc-14.2.4/reproc++/include/reproc++/env.hpp:8:7: note: declared here
[   24s]     8 | class env : public detail::array {
[   24s]       |       ^~~
[   24s] make[2]: *** [reproc++/CMakeFiles/reproc++.dir/build.make:79: reproc++/CMakeFiles/reproc++.dir/src/reproc.cpp.o] Error 1
[   24s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/reproc-14.2.4/build'
[   24s] make[1]: *** [CMakeFiles/Makefile2:686: reproc++/CMakeFiles/reproc++.dir/all] Error 2
[   24s] make: *** [Makefile:149: all] Error 2
[   24s] error: Bad exit status from /var/tmp/rpm-tmp.AtSXPF (%build)
[   24s] 
[   24s] RPM build errors:
[   24s]     Bad exit status from /var/tmp/rpm-tmp.AtSXPF (%build)
[   24s] ### VM INTERACTION START ###

Full log available at https://build.opensuse.org/package/live_build_log/home:iznogood:branches:devel:libraries:c_c++/reproc/openSUSE_Factory/x86_64

dirkmueller commented 1 year ago

This patch on top of master/main seems to fix the build. I'm not sure how much this preserves source compatibility. I am surprised that previous compiler versions accepted this ambiguity between types and names.


--- reproc-14.2.4/reproc++/include/reproc++/reproc.hpp  2023-04-04 23:14:25.549923395 +0200
+++ reproc-14.2.4/reproc++/include/reproc++/reproc.hpp  2023-04-04 23:13:00.824489755 +0200
@@ -65,7 +65,7 @@
 using handle = int;
 #endif

-struct redirect {
+struct redirect_t {
   enum type {
     default_, // Unfortunately, both `default` and `auto` are keywords.
     pipe,
@@ -88,7 +88,7 @@

 struct options {
   struct {
-    enum env::type behavior;
+    enum redirect_t::type behavior;
     /*! Implicitly converts from any STL container of string pairs to the
     environment format expected by `reproc_start`. */
     class env extra;
@@ -97,9 +97,9 @@
   const char *working_directory = nullptr;

   struct {
-    struct redirect in;
-    struct redirect out;
-    struct redirect err;
+    struct redirect_t in;
+    struct redirect_t out;
+    struct redirect_t err;
     bool parent;
     bool discard;
     FILE *file;
--- reproc-14.2.4/reproc++/src/reproc.cpp       2023-04-04 23:14:25.549923395 +0200
+++ reproc-14.2.4/reproc++/src/reproc.cpp       2023-04-04 23:13:41.693181299 +0200
@@ -39,7 +39,7 @@
   };
 }

-static reproc_redirect reproc_redirect_from(redirect redirect)
+static reproc_redirect reproc_redirect_from(redirect_t redirect)
 {
   return { static_cast<REPROC_REDIRECT>(redirect.type), redirect.handle,
            redirect.file, redirect.path };
DaanDeMeyer commented 1 year ago

Latest commit on main should fix the build issues.

jetm commented 1 year ago

@DaanDeMeyer Is possible to do a release that includes the fix(es) for gcc v13?

dirkmueller commented 1 year ago

Latest commit on main should fix the build issues.

confirmed!

barracuda156 commented 6 months ago

@DaanDeMeyer Could you please make a new release?