Search code examples
binaryninjameson-build

Why are the binaries generated by using Meson / Ninja much larger than those compiled by plain valac?


Same source file.

directe compile use valac.

⭕ valac --pkg gtk+-3.0 -X -lm --pkg libcanberra src/Application.vala 
⭕ ls Application 
-rwxrwxr-x 1 eexpss 48K 05-13 19:59 Application

here is part of my meson.build.

project('com.github.eexpress.cairo-timer', 'vala', 'c')

# i18n = import('i18n')

executable(
    meson.project_name(),
    'src/Application.vala',
    dependencies: [
        dependency('gtk+-3.0'),
#       dependency('cairo'),
        dependency('libcanberra')
    ],
#   link_args : '-X',
#   link_args : '-lm',
    link_args : ['-X', '-lm',],
    install: true
)

and use ninja to compile it.

⭕ cd build; ninja
⭕ ls com.github.eexpress.cairo-timer
-rwxrwxr-x 1 eexpss 98K 05-13 17:02 com.github.eexpress.cairo-timer

So the binary file is more larger than above one. why?


Solution

  • Because you didn't enable debugging for valac, but meson enables it by default. Add -g to valac and the output size should be close to equal.

    To see how ninja and valac run the tools to build, enable verbose option by given -v to both commands.

    The minor size differences are, as I assume, from file names in them. Compare the outputs, for example, from readelf --debug-dump=line hello to see the diff.