Skip to content
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

mocklibc: move the print_indent function to the file where it is used #428

Conversation

vmihalko
Copy link
Collaborator

@vmihalko vmihalko commented Mar 8, 2024

This fixes build error with GCC >= 14 and clang >= 17, failing on:

../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: implicit declaration of function ‘print_indent’ [-Wimplicit-function-declaration]
   25 |   print_indent(stream, indent);
      |   ^~~~~~~~~~~~

Issue reported 11 years ago to (dead) upstream: https://code.google.com/archive/p/mocklibc/issues/3.

Closes: #6

This fixes build error with GCC >= 14 and clang >= 17,
failing on:
```
../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: implicit declaration of function ‘print_indent’ [-Wimplicit-function-declaration]
   25 |   print_indent(stream, indent);
      |   ^~~~~~~~~~~~
```

Closes: polkit-org#6
@vmihalko
Copy link
Collaborator Author

vmihalko commented Mar 8, 2024

After Fedora-40 is released on Tue 2024-04-23, without this change and with the -D tests=true flag, the build will fail (on f40).

@jrybar-rh jrybar-rh merged commit 0d78d1e into polkit-org:main Mar 12, 2024
13 checks passed
@mbiebl
Copy link
Contributor

mbiebl commented Mar 15, 2024

This doesn't seem to actually work / fix it completely, as there is also an outdated copy of mocklibc in subprojects, leading to

> cc -Isubprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p -Isubprojects/mocklibc-1.0/src -I../subprojects/mocklibc-1.0/src -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -MD -MQ subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -MF subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o.d -o subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -c ../subprojects/mocklibc-1.0/src/netgroup-debug.c
> ../subprojects/mocklibc-1.0/src/netgroup-debug.c: In function ‘netgroup_debug_print_entry’:
> ../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: implicit declaration of function ‘print_indent’ [-Werror=implicit-function-declaration]
>    25 |   print_indent(stream, indent);
>       |   ^~~~~~~~~~~~
> cc1: some warnings being treated as errors
> [90/108] cc  -o src/programs/pkexec src/programs/pkexec.p/pkexec.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 '-Wl,-rpath,$ORIGIN/../polkitagent:$ORIGIN/../polkit' -Wl,-rpath-link,/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/polkitagent -Wl,-rpath-link,/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/polkit -Wl,--start-group src/polkitagent/libpolkit-agent-1.so.0.0.0 src/polkit/libpolkit-gobject-1.so.0.0.0 -lpam /usr/lib/x86_64-linux-gnu/libgio-2.0.so /usr/lib/x86_64-linux-gnu/libgobject-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -Wl,--end-group
> [91/108] cc -Isubprojects/mocklibc-1.0/src/libmocklibc.so.0.0.0.p -Isubprojects/mocklibc-1.0/src -I../subprojects/mocklibc-1.0/src -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -MD -MQ subprojects/mocklibc-1.0/src/libmocklibc.so.0.0.0.p/netgroup.c.o -MF subprojects/mocklibc-1.0/src/libmocklibc.so.0.0.0.p/netgroup.c.o.d -o subprojects/mocklibc-1.0/src/libmocklibc.so.0.0.0.p/netgroup.c.o -c ../subprojects/mocklibc-1.0/src/netgroup.c
> [92/108] cc -Itest/polkit/polkitunixgrouptest.p -Itest/polkit -I../test/polkit -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -DHAVE_CONFIG_H -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -D_POLKIT_COMPILATION -D_POLKIT_BACKEND_COMPILATION -MD -MQ test/polkit/polkitunixgrouptest.p/polkitunixgrouptest.c.o -MF test/polkit/polkitunixgrouptest.p/polkitunixgrouptest.c.o.d -o test/polkit/polkitunixgrouptest.p/polkitunixgrouptest.c.o -c ../test/polkit/polkitunixgrouptest.c
> [93/108] cc -Itest/polkit/polkitunixusertest.p -Itest/polkit -I../test/polkit -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -DHAVE_CONFIG_H -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -D_POLKIT_COMPILATION -D_POLKIT_BACKEND_COMPILATION -MD -MQ test/polkit/polkitunixusertest.p/polkitunixusertest.c.o -MF test/polkit/polkitunixusertest.p/polkitunixusertest.c.o.d -o test/polkit/polkitunixusertest.p/polkitunixusertest.c.o -c ../test/polkit/polkitunixusertest.c
> [94/108] cc -Itest/polkit/polkitunixnetgrouptest.p -Itest/polkit -I../test/polkit -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -DHAVE_CONFIG_H -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -D_POLKIT_COMPILATION -D_POLKIT_BACKEND_COMPILATION -MD -MQ test/polkit/polkitunixnetgrouptest.p/polkitunixnetgrouptest.c.o -MF test/polkit/polkitunixnetgrouptest.p/polkitunixnetgrouptest.c.o.d -o test/polkit/polkitunixnetgrouptest.p/polkitunixnetgrouptest.c.o -c ../test/polkit/polkitunixnetgrouptest.c
> ../test/polkit/polkitunixnetgrouptest.c:44:1: warning: ‘test_set_name’ defined but not used [-Wunused-function]
>    44 | test_set_name (void)
>       | ^~~~~~~~~~~~~
> ../test/polkit/polkitunixnetgrouptest.c:28:1: warning: ‘test_new’ defined but not used [-Wunused-function]
>    28 | test_new (void)
>       | ^~~~~~~~
> [95/108] cc -Itest/polkit/polkitidentitytest.p -Itest/polkit -I../test/polkit -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -DHAVE_CONFIG_H -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -D_POLKIT_COMPILATION -D_POLKIT_BACKEND_COMPILATION -MD -MQ test/polkit/polkitidentitytest.p/polkitidentitytest.c.o -MF test/polkit/polkitidentitytest.p/polkitidentitytest.c.o.d -o test/polkit/polkitidentitytest.p/polkitidentitytest.c.o -c ../test/polkit/polkitidentitytest.c
> [96/108] env PKG_CONFIG_PATH=/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/meson-uninstalled PKG_CONFIG=/usr/bin/pkg-config CC=cc /usr/bin/x86_64-linux-gnu-g-ir-scanner --quiet --no-libtool --namespace=Polkit --nsversion=1.0 --warn-all --output src/polkit/Polkit-1.0.gir --c-include=polkit/polkit.h -D_POLKIT_COMPILATION -I/<<PKGBUILDDIR>>/src/polkit -I/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/polkit -I/<<PKGBUILDDIR>>/. -I/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/. -I/<<PKGBUILDDIR>>/src/. -I/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/. --filelist=/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/polkit/libpolkit-gobject-1.so.0.0.0.p/Polkit_1.0_gir_filelist --include=Gio-2.0 --pkg-export=polkit-gobject-1 --cflags-begin -DHAVE_CONFIG_H -I/<<PKGBUILDDIR>>/. -I/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/. -I/<<PKGBUILDDIR>>/src/. -I/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/. -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/gobject-introspection-1.0 --cflags-end --add-include-path=/usr/share/gir-1.0 -L/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/polkit --library polkit-gobject-1 --extra-library=gio-2.0 --extra-library=gobject-2.0 --extra-library=glib-2.0 --extra-library=systemd --extra-library=girepository-1.0 --sources-top-dirs /<<PKGBUILDDIR>>/ --sources-top-dirs /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/
> ../src/polkit/polkitimplicitauthorization.h:61: Warning: Polkit: "out" annotation takes at most one option, 2 given
> <unknown>:: Warning: Polkit: (Interface)Identity: Couldn't find associated structure for 'Identity'
> <unknown>:: Warning: Polkit: (Interface)Subject: Couldn't find associated structure for 'Subject'
> ninja: build stopped: subcommand failed.
> dh_auto_build: error: cd obj-x86_64-linux-gnu && LC_ALL=C.UTF-8 ninja -j8 -v returned exit code 1
> make[1]: *** [debian/rules:51: override_dh_auto_build] Error 25

@mbiebl
Copy link
Contributor

mbiebl commented Mar 15, 2024

Relevant downstream bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1066531

I'm a bit confused by test/mocklibc/ and subprojects/mocklibc*

How is this supposed to work?

@mbiebl
Copy link
Contributor

mbiebl commented Mar 15, 2024

/cc @jrybar-rh

@vmihalko
Copy link
Collaborator Author

The plan is to replace the mocklibc from subprojects with the one in the test directory because the one in subprojects does not contain any of the previous fixes of upstream issues https://code.google.com/archive/p/mocklibc/issues. In contrast, the version in the test directory contains all of them.

@mbiebl
Copy link
Contributor

mbiebl commented Mar 16, 2024

What's missing to replace it fully?
It's odd that we have/use two copies atm.

@mbiebl
Copy link
Contributor

mbiebl commented Mar 16, 2024

I'm not really familiar with meson/wrapdb, but would it be possible to get this fixed mocklibc into https://github.com/mesonbuild/wrapdb ?

https://mesonbuild.com/Wrap-dependency-system-manual.html#diff-files

@mbiebl
Copy link
Contributor

mbiebl commented Mar 16, 2024

Afaics, the mocklibc copy in test/mocklibc is not actually used, right?
At least, I don't see it referenced in any of the meson.build files and removing test/mocklibc does not break the build.

@mbiebl mbiebl mentioned this pull request Mar 16, 2024
@mbiebl
Copy link
Contributor

mbiebl commented Mar 16, 2024

@vmihalko please have a look at #436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

print_indent prototype missing from header
3 participants