vasprintf compilation error on `alpine:edge` (`restrict` keyword in C++ ?)
Mizux opened this issue · 4 comments
Spotted project: google/or-tools (CI CMake x Alpine:edge x C++ job), mizux/dotnet-native (CI CMake x Alpine:edge)
note: Alpine seems to pull fortify-headers recently https://pkgs.alpinelinux.org/package/edge/main/x86_64/fortify-headers
Trace:
$ cd mizux/dotnet-native
$ make --directory=ci amd64_alpine_build
...
#0 0.517 cd /home/project/build/Foo && /usr/bin/g++ -DFoo_EXPORTS -I/home/project/Foo/include -O3 -DNDEBUG -std=c++17 -fPIC -MD -MT Foo/CMakeFiles/Foo.dir/src/Foo.cpp.o -MF CMakeFiles/Foo.dir/src/Foo.cpp.o.d -o CMakeFiles/Foo.dir/src/Foo.cpp.o -c /home/project/Foo/src/Foo.cpp
#0 0.789 In file included from /usr/include/c++/13.2.1/cstdio:42,
#0 0.789 from /usr/include/c++/13.2.1/ext/string_conversions.h:45,
#0 0.789 from /usr/include/c++/13.2.1/bits/basic_string.h:4109,
#0 0.789 from /usr/include/c++/13.2.1/string:54,
#0 0.789 from /home/project/Foo/include/foo/Foo.hpp:4,
#0 0.789 from /home/project/Foo/src/Foo.cpp:1:
#0 0.789 /usr/include/fortify/stdio.h:229:54: error: expected ',' or '...' before 'strp'
#0 0.789 229 | _FORTIFY_FN(vasprintf) int vasprintf(char **restrict strp, const char *restrict fmt, __builtin_va_list ap)
#0 0.789 | ^~~~
#0 0.789 /usr/include/fortify/stdio.h:229:28: error: conflicting declaration of C function 'int vasprintf(char**)'
#0 0.789 229 | _FORTIFY_FN(vasprintf) int vasprintf(char **restrict strp, const char *restrict fmt, __builtin_va_list ap)
#0 0.789 | ^~~~~~~~~
#0 0.789 In file included from /usr/include/fortify/stdio.h:23:
#0 0.789 /usr/include/stdio.h:186:5: note: previous declaration 'int vasprintf(char**, const char*, __va_list_tag*)'
#0 0.789 186 | int vasprintf(char **, const char *, __isoc_va_list);
#0 0.789 | ^~~~~~~~~
#0 0.790 /usr/include/fortify/stdio.h: In function 'int vasprintf(char**)':
#0 0.790 /usr/include/fortify/stdio.h:234:36: error: 'strp' was not declared in this scope
#0 0.790 234 | int ret = __orig_vasprintf(strp, fmt, ap);
#0 0.790 | ^~~~
#0 0.791 /usr/include/fortify/stdio.h:234:42: error: 'fmt' was not declared in this scope
#0 0.791 234 | int ret = __orig_vasprintf(strp, fmt, ap);
#0 0.791 | ^~~
#0 0.792 /usr/include/fortify/stdio.h:234:47: error: 'ap' was not declared in this scope
#0 0.792 234 | int ret = __orig_vasprintf(strp, fmt, ap);
#0 0.792 | ^~
#0 0.792 /usr/include/fortify/stdio.h: At global scope:
#0 0.792 /usr/include/fortify/stdio.h:343:52: error: expected ',' or '...' before 'strp'
#0 0.792 343 | _FORTIFY_FN(asprintf) int asprintf(char **restrict strp, const char *restrict fmt, ...)
#0 0.792 | ^~~~
#0 0.792 /usr/include/fortify/stdio.h:343:27: error: conflicting declaration of C function 'int asprintf(char**)'
#0 0.792 343 | _FORTIFY_FN(asprintf) int asprintf(char **restrict strp, const char *restrict fmt, ...)
#0 0.792 | ^~~~~~~~
#0 0.792 /usr/include/stdio.h:185:5: note: previous declaration 'int asprintf(char**, const char*, ...)'
#0 0.792 185 | int asprintf(char **, const char *, ...);
#0 0.792 | ^~~~~~~~
#0 0.793 /usr/include/fortify/stdio.h: In function 'int asprintf(char**)':
#0 0.793 /usr/include/fortify/stdio.h:348:35: error: 'strp' was not declared in this scope
#0 0.793 348 | int ret = __orig_asprintf(strp, fmt, __builtin_va_arg_pack());
#0 0.793 | ^~~~
#0 0.794 /usr/include/fortify/stdio.h:348:41: error: 'fmt' was not declared in this scope
#0 0.794 348 | int ret = __orig_asprintf(strp, fmt, __builtin_va_arg_pack());
#0 0.794 | ^~~
#0 1.022 gmake[2]: *** [Foo/CMakeFiles/Foo.dir/build.make:76: Foo/CMakeFiles/Foo.dir/src/Foo.cpp.o] Error 1
#0 1.022 gmake[2]: Leaving directory '/home/project/build'
#0 1.022 gmake[1]: *** [CMakeFiles/Makefile2:462: Foo/CMakeFiles/Foo.dir/all] Error 2
#0 1.022 gmake[1]: Leaving directory '/home/project/build'
#0 1.023 gmake: *** [Makefile:146: all] Error 2
#0 1.026
------
src:
https://github.com/Mizux/dotnet-native/blob/main/ci/Makefile
https://github.com/Mizux/dotnet-native/blob/main/ci/docker/alpine/Dockerfile
Seems to comes from:
- https://git.2f30.org/fortify-headers/commit/1becad43298e74ba73bc66f9d44523e5d121c667.html
- 1becad4
restrict
keyword in C++ aka missing some extern C ?
note: if using alpine clang-18
aka adding
FROM devel AS build
+RUN apk add --no-cache clang18
+ENV CC=clang-18 CXX=clang++-18
RUN cmake --version
here: https://github.com/Mizux/dotnet-native/blob/main/ci/docker/alpine/Dockerfile#L31
I got this new issue:
trace:
$ cd mizux/dotnet-native
$ make --directory=ci amd64_alpine_build
...
r/__/__/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx.o.d -o CMakeFiles/dotnet_Bar.dir/__/__/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx.o -c /home/project/build/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx
#0 4.203 In file included from /home/project/build/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx:169:
#0 4.203 /usr/include/fortify/string.h:62:5: error: arithmetic on a pointer to void
#0 4.203 62 | if __fh_overlap(__od, __n, __os, __n)
#0 4.203 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#0 4.203 /usr/include/fortify/fortify-headers.h:144:28: note: expanded from macro '__fh_overlap'
#0 4.203 144 | ((a) < (b) && (b) < ((a) + (__fh_size_t)(len_a))) \
#0 4.203 | ~~~ ^
#0 4.203 In file included from /home/project/build/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx:169:
#0 4.203 /usr/include/fortify/string.h:62:5: error: arithmetic on a pointer to void
#0 4.203 62 | if __fh_overlap(__od, __n, __os, __n)
#0 4.204 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#0 4.204 /usr/include/fortify/fortify-headers.h:145:35: note: expanded from macro '__fh_overlap'
#0 4.204 145 | || ((b) < (a) && (a) < ((b) + (__fh_size_t)(len_b))) \
#0 4.204 | ~~~ ^
#0 4.838 2 errors generated.
#0 4.846 gmake[2]: *** [Bar/dotnet/CMakeFiles/dotnet_Bar.dir/build.make:76: Bar/dotnet/CMakeFiles/dotnet_Bar.dir/__/__/dotnet/Mizux.DotnetNative/Bar/barCSHARP_wrap.cxx.o] Error 1
#0 4.846 gmake[2]: Leaving directory '/home/project/build'
#0 4.846 gmake[1]: *** [CMakeFiles/Makefile2:685: Bar/dotnet/CMakeFiles/dotnet_Bar.dir/all] Error 2
#0 4.846 gmake[1]: Leaving directory '/home/project/build'
#0 4.847 gmake: *** [Makefile:146: all] Error 2
#0 4.849
------
seems to come from: https://git.2f30.org/fortify-headers/commit/8513fddefca4c6e3982718732afeec71bad4e688.html
I think this is another downstream bug report: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16200 which uses g++