meson: 0.50 regression: Default option c_std not applied when cross-compiling

When providing default_options: ['c_std=c99'] to the project, it is not being applied on meson build --cross-file <cross-file> invocation on a simple test project using flexible array members:

ninja -v

[1/2] cc -Itest-executable@exe -I. -I…/…/work -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -pedantic -MD -MQ ‘test-executable@exe/main.c.o’ -MF ‘test-executable@exe/main.c.o.d’ -o ‘test-executable@exe/main.c.o’ -c …/…/work/main.c …/…/work/main.c:5:9: warning: ISO C90 does not support flexible array members [-Wpedantic] int array[]; ^ [2/2] cc -o test-executable ‘test-executable@exe/main.c.o’ -Wl,–no-undefined -Wl,–as-needed

However, after doing any kind of (even unrelated) configuration such as meson configure -Db_asneeded=true, the configuration is being fixed and applies as expected:

ninja -v

[1/2] cc -Itest-executable@exe -I. -I…/…/work -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -g -pedantic -MD -MQ ‘test-executable@exe/main.c.o’ -MF ‘test-executable@exe/main.c.o.d’ -o ‘test-executable@exe/main.c.o’ -c …/…/work/main.c [2/2] cc -o test-executable ‘test-executable@exe/main.c.o’ -Wl,–no-undefined -Wl,–as-needed

Note: I haven’t tested whether this also applies to other default options.


main.c

#include <stdio.h>

struct a {
    int foo;
    int array[];
};

int main(int argc, char* argv[]) {
    printf("Hey!\n");
    return 0;
}

meson.build

project('test-project', 'c', version: '0.0.1', default_options: ['c_std=c99'])
add_project_arguments('-pedantic', language: 'c')
executable('test-executable', 'main.c')

cross-file

[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

[properties]
root = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64'
needs_exe_wrapper = true

[paths]
prefix = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot'

[binaries]
c = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang'
cpp = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang++'
ar = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ar'
as = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-as'
ld = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/ld.lld'
strip = '/usr/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-strip'
pkgconfig = '/usr/bin/pkg-config'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 15 (13 by maintainers)

Commits related to this issue

Most upvoted comments

For c_std that’s new. For c_args and c_link_args this was also the case in 0.49.0.

I’m not sure what c_args is supposed to be used for but the correct C standard depends on the code that is compiled. Cross-compiling or not should not have an effect for this.

And after doing some testing, I must say that it is very confusing that command line options don’t have any effect.