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

preprocess and custom_target results in ninja dependency error #13884

Open
julianneswinoga opened this issue Nov 8, 2024 · 0 comments
Open

Comments

@julianneswinoga
Copy link

Describe the bug
Using compiler .preprocess() and custom_target() results in ninja dependency error but not a meson error:

ninja: error: '/tmp/meson_preprocessor_bug/buildDir/preprocessor_0.p/lscript.pp.ld', needed by 'lscript.pp.strip.ld', missing and no known rule to make it

yet afaik the dependency chain should be:

lscript.ld < lscript.pp.ld < lscript.pp.strip.ld < exe
^source      ^preprocess     ^strip_lscript.sh

To Reproduce

project('my_project', 'c')

preprocesssed_lscript = meson.get_compiler('c').preprocess(
    'lscript.ld',
    output: '@BASENAME@.pp.ld',
)[0]

linker_script_tgt = custom_target(
    'lscript',
    input: preprocesssed_lscript.full_path(),
    output: '@BASENAME@.strip.ld',
    command: [files('strip_lscript.sh'), '@INPUT@', '@OUTPUT@'],
    depends: [preprocesssed_lscript],
)
linker_script_dep = declare_dependency(sources: [linker_script_tgt])
output_file = linker_script_tgt.full_path()
add_project_link_arguments(['-T', f'@output_file@'], language: 'c')

executable('exe', ['main.c'], dependencies: [linker_script_dep])

results in

The Meson build system
Version: 1.6.0
Source dir: /tmp/meson_preprocessor_bug
Build dir: /tmp/meson_preprocessor_bug/buildDir
Build type: native build
Project name: my_project
Project version: undefined
C compiler for the host machine: ccache cc (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C linker for the host machine: cc ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
meson.build:8: WARNING: Source item '/tmp/meson_preprocessor_bug/buildDir/preprocessor_0.p/lscript.pp.ld' cannot be converted to File object, because it is a generated file. This will become a hard error in meson 2.0.
Build targets in project: 3

Found ninja-1.10.1 at /usr/bin/ninja
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/meson_preprocessor_bug/buildDir -j 16 -v
ninja: Entering directory `/tmp/meson_preprocessor_bug/buildDir'
ninja: error: '/tmp/meson_preprocessor_bug/buildDir/preprocessor_0.p/lscript.pp.ld', needed by 'lscript.pp.strip.ld', missing and no known rule to make it

(full repo: https://github.com/julianneswinoga/meson_preprocessor_bug)

Expected behavior
Dependency chain to be built correctly and build to start.

system parameters

  • Plain native build
  • OS: Ubuntu 22.04.5
  • python --version: 3.10.12
  • meson --version: 1.6.0
  • ninja --version: 1.10.1
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

1 participant