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

-Dtests=true fails to build on BSDs due to -I= instead of -I or -isystem #66

Closed
jbeich opened this issue Jul 9, 2022 · 13 comments
Closed

Comments

@jbeich
Copy link
Contributor

jbeich commented Jul 9, 2022

Regressed by d0cf159. Doesn't affect -Dtests=false (default) builds.

$ meson setup -Dtests=true /tmp/neatvnc_build
$ meson compile -C /tmp/neatvnc_build
[...]
FAILED: test/pixels.p/test-pixels.c.o
cc -Itest/pixels.p -Itest -Itest -Iinclude -I/usr/local/include/pixman-1 -I=/usr/local/include -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu11 -O0 -g '-DPROJECT_VERSION="0.5.0"' -D_GNU_SOURCE -fvisibility=hidden -Wmissing-prototypes '-DGIT_VERSION="v0.5.0-1-gcd23192 (freebsd)"' -MD -MQ test/pixels.p/test-pixels.c.o -MF test/pixels.p/test-pixels.c.o.d -o test/pixels.p/test-pixels.c.o -c test/test-pixels.c
test/test-pixels.c:8:10: fatal error: 'libdrm/drm_fourcc.h' file not found
#include <libdrm/drm_fourcc.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
FAILED: test/pixels.p/.._src_pixels.c.o
cc -Itest/pixels.p -Itest -Itest -Iinclude -I/usr/local/include/pixman-1 -I=/usr/local/include -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu11 -O0 -g '-DPROJECT_VERSION="0.5.0"' -D_GNU_SOURCE -fvisibility=hidden -Wmissing-prototypes '-DGIT_VERSION="v0.5.0-1-gcd23192 (freebsd)"' -MD -MQ test/pixels.p/.._src_pixels.c.o -MF test/pixels.p/.._src_pixels.c.o.d -o test/pixels.p/.._src_pixels.c.o -c src/pixels.c
src/pixels.c:21:10: fatal error: 'libdrm/drm_fourcc.h' file not found
#include <libdrm/drm_fourcc.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

Note, on FreeBSD cross-compilation is often done via poudriere (as used by official package builders) which already isolates host from target. I don't have/use Linux, so don't understand "host leakage" being fixed by d0cf159.

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

Generally, -isystem is preferred over -I when using includes from (system) packages due to the way search paths are ordered and out-of-scope warnings are hidden. I don't know what -I= does as it appears missing from GCC manpage and is too short/has special characters for Google/DuckDuckGo.

@any1
Copy link
Owner

any1 commented Jul 9, 2022

The man page entry for -I says the following:

If dir begins with = or $SYSROOT, then the = or $SYSROOT is replaced by the sysroot prefix; see --sysrootand -isysroot.

I can see how it's hard to find because the string -I= doesn't appear anywhere in the document.

Could it be that the sysroot of your environment is set to an unexpected value?

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

Could it be that the sysroot of your environment is set to an unexpected value?

I don't use sysroot.

$ cat a.c
#include <libdrm/drm_fourcc.h>
int main() {}

$ cc -I=/usr/local/include a.c
a.c:1:10: fatal error: 'libdrm/drm_fourcc.h' file not found
#include <libdrm/drm_fourcc.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.

If Meson is run with CFLAGS+=-v then during build I see

ignoring nonexistent directory "=/usr/local/include"

However, when building without tests something else (e.g., gnutls, libturbojpeg) adds -I/usr/local/include.

@any1
Copy link
Owner

any1 commented Jul 9, 2022

Hmm, I had assumed that if gcc wasn't built with sysroot, the = would be replaced with an empty string. That's probably not the case. If you set --sysroot=/, does that do anything?

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

If you set --sysroot=/, does that do anything?

Makes -I=/usr/local/include work like -I/usr/local/include. Tested both Clang (default) and GCC.

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

If you need to get libdrm flags from pkg-config without overriding search order try using include_type: system like emersion/libliftoff@009570230398.

@any1
Copy link
Owner

any1 commented Jul 9, 2022

@any1
Copy link
Owner

any1 commented Jul 9, 2022

I pushed a partial_dependency based patch to master. Does that solve the problem?

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

Does that solve the problem?

Not yet due to missing libdrm_inc in test/meson.build

FAILED: test/pixels.p/test-pixels.c.o
cc -Itest/pixels.p -Itest -Itest -Iinclude -I/usr/local/include/pixman-1 -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu11 -O0 -g '-DPROJECT_VERSION="0.5.0"' -D_GNU_SOURCE -fvisibility=hidden -Wmissing-prototypes '-DGIT_VERSION="v0.5.0-2-gf4f8f0b (master)"' -MD -MQ test/pixels.p/test-pixels.c.o -MF test/pixels.p/test-pixels.c.o.d -o test/pixels.p/test-pixels.c.o -c test/test-pixels.c
test/test-pixels.c:8:10: fatal error: 'libdrm/drm_fourcc.h' file not found
#include <libdrm/drm_fourcc.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
FAILED: test/pixels.p/.._src_pixels.c.o
cc -Itest/pixels.p -Itest -Itest -Iinclude -I/usr/local/include/pixman-1 -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu11 -O0 -g '-DPROJECT_VERSION="0.5.0"' -D_GNU_SOURCE -fvisi
bility=hidden -Wmissing-prototypes '-DGIT_VERSION="v0.5.0-2-gf4f8f0b (master)"' -MD -MQ test/pixels.p/.._src_pixels.c.o -MF test/pixels.p/.._src_pixels.c.o.d -o test/pixels.p/.._src_pixels.c.o -c src/pixels.c
src/pixels.c:21:10: fatal error: 'libdrm/drm_fourcc.h' file not found
#include <libdrm/drm_fourcc.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.

@any1
Copy link
Owner

any1 commented Jul 9, 2022

Ahh, that was a bit hasty of me. Fixed now.

@jbeich
Copy link
Contributor Author

jbeich commented Jul 9, 2022

Builds fine now, so packaged.

@jbeich jbeich closed this as completed Jul 9, 2022
@any1
Copy link
Owner

any1 commented Jul 9, 2022

Thanks!

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

No branches or pull requests

2 participants