mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.66k stars 1.64k forks source link

compiler.sizeof() returns -1 with emscripten #9953

Open peterholzer opened 2 years ago

peterholzer commented 2 years ago

Describe the bug When doing a cross-build with emscripten, compiler.sizeof() returns -1 for any type passed.

To Reproduce

Build file used: meson.build

project(
  'myexec',
  'c'
)

cc = meson.get_compiler ('c')

char_size = cc.sizeof('char')
short_size = cc.sizeof('short')
int_size = cc.sizeof('int')
voidp_size = cc.sizeof('void*')
long_size = cc.sizeof('long')

Cross-File used: emscripten.conf

[binaries]
c = 'emcc'
cpp = 'em++'
ld = 'wasm-ld'
ar = 'emar'
ranlib = 'emranlib'
make = 'emmake'
cmake = 'emcmake'

[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'

[properties]
needs_exe_wrapper = true

Produced the following output:

The Meson build system
Version: 0.59.4
Source dir: /tmp/ad
Build dir: /tmp/ad/build
Build type: cross build
Project name: myexec
Project version: undefined
C compiler for the host machine: emcc (emscripten 3.1.3 "emsdk.sh")
C linker for the host machine: emcc ld.wasm unknown version
C compiler for the build machine: ccache cc (gcc 11.2.1 "cc (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7)")
C linker for the build machine: cc ld.bfd 2.37-10
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: wasm32
Host machine cpu: wasm32
Target machine cpu family: wasm32
Target machine cpu: wasm32
Checking for size of "char" : -1
Checking for size of "short" : -1
Checking for size of "int" : -1
Checking for size of "void*" : -1
Checking for size of "long" : -1
Build targets in project: 0

Found ninja-1.10.2 at /usr/bin/ninja
WARNING: Cross file does not specify strip binary, result will not be stripped.
WARNING: Cross file does not specify strip binary, result will not be stripped.

Expected behavior Return the size of the types. E.g.:

Checking for size of "char" : 1
Checking for size of "short" : 2
Checking for size of "int" : 4
Checking for size of "void*" : 4
Checking for size of "long" : 4

system parameters

peterholzer commented 2 years ago

The same happens with a cross file containing c = ['clang', '--target=wasm32']