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

Dependencies should be built before any files of the target (?) #12814

Closed
elmarco opened this issue Feb 6, 2024 · 4 comments
Closed

Dependencies should be built before any files of the target (?) #12814

elmarco opened this issue Feb 6, 2024 · 4 comments

Comments

@elmarco
Copy link
Contributor

elmarco commented Feb 6, 2024

Describe the bug

lib = static_library('dep', 'test.c')

dep = declare_dependency(link_with: lib)

executable('a', 'main.c', dependencies: dep)

generates ninja rules:

build a.p/main.c.o: c_COMPILER ../main.c
 DEPFILE = a.p/main.c.o.d
 DEPFILE_UNQUOTED = a.p/main.c.o.d
 ARGS = -Ia.p -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g

build a: c_LINKER a.p/main.c.o | libdep.a
 LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group libdep.a -Wl,--end-group

It fails when lib is actually from generated source (via custom_target), and main.c depend on it (generated headers).

meson 1.3.99 git 6fcf863

@eli-schwartz
Copy link
Member

It fails when lib is actually from generated source (via custom_target), and main.c depend on it (generated headers).

In that case, the bug report is incomplete and needs to describe the bug well enough to actually model generating the sources and headers.

@eli-schwartz eli-schwartz added the needs-info waiting information from user. May close if no response for long time. label Feb 6, 2024
@elmarco
Copy link
Contributor Author

elmarco commented Feb 6, 2024

It fails when lib is actually from generated source (via custom_target), and main.c depend on it (generated headers).

In that case, the bug report is incomplete and needs to describe the bug well enough to actually model generating the sources and headers.

project('foo', ['c'])

src = custom_target('gen', output: ['test.c', 'test.h'], command: ['touch', '@OUTPUT@'])

lib = static_library('dep', src)

dep = declare_dependency(link_with: lib)

executable('a', 'main.c', dependencies: dep)
#include "test.h"

int test() { return 0; }

@eli-schwartz eli-schwartz added support/RFC and removed needs-info waiting information from user. May close if no response for long time. labels Feb 6, 2024
@elmarco
Copy link
Contributor Author

elmarco commented Feb 6, 2024

thanks @eli-schwartz

patchew-importer pushed a commit to patchew-project/qemu that referenced this issue Feb 6, 2024
Fixes:
   rm -rf b; cd b
  ../configure --enable-modules --target-list=x86_64-softmmu
  ninja qemu-system-x86_64

   In file included from ../ui/dbus-chardev.c:34:
  ../ui/dbus.h:34:10: fatal error: ui/dbus-display1.h: No such file or directory
     34 | #include "ui/dbus-display1.h"
        |          ^~~~~~~~~~~~~~~~~~~~
  compilation terminated.

See also:
mesonbuild/meson#12814

Reported-by: Tokarev, Michael <mjt@tls.msk.ru>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20240206140414.1134857-1-marcandre.lureau@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants