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

cmake: CheckTypeSize does not work correctly for types > 255? #18238

Open
Viatorus opened this issue Nov 21, 2022 · 1 comment
Open

cmake: CheckTypeSize does not work correctly for types > 255? #18238

Viatorus opened this issue Nov 21, 2022 · 1 comment

Comments

@Viatorus
Copy link

The custom shipped CheckTypeSize module does not handle types greater than 255 bytes correctly.

Version of emscripten/emsdk:
3.1.23

Testing source

cmake_minimum_required(VERSION 3.10)

project(sizeof-test)

include(CheckTypeSize)

check_type_size("char[15]" size1)
check_type_size("char[2048]" size2)
check_type_size("char[2049]" size3)
check_type_size("char[2047]" size4)

message(WARNING "${size1} ${size2} ${size3} ${size4}") # 15 0 1 255

-- Check size of char[15]
-- Check size of char[15] - done
-- Check size of char[2048]
-- Check size of char[2048] - done
-- Check size of char[2049]
-- Check size of char[2049] - done
-- Check size of char[2047]
-- Check size of char[2047] - done
CMake Warning at CMakeLists.txt:63 (message):
  15 0 1 255
@sbc100
Copy link
Collaborator

sbc100 commented Nov 23, 2022

The problem seems to date back to b206b9e. We apparently override CheckTypeSize but we use the return value of the executable, which is only allowed to be in the range 0-255.

sbc100 added a commit that referenced this issue Dec 2, 2022
Update the CheckTypeSize files to v3.20.0 (mostly arbitrary version).

Local patch to CheckTypeSize is not much smaller.  Instead of executing
the program and using the return value (doesn't work for return values
greater than 255), we simply inject `-oformat=wasm` onto the link
command, and then we can use `strings` on the binary just like the
upstream check.  This is basically a single line patch against upstream
now.

Fixes: #18278 #18238 #17268 #18084 #17811
sbc100 added a commit that referenced this issue Dec 2, 2022
Update the CheckTypeSize files to v3.10.2 (mostly arbitrary version, but
this is what we use in CI).

Local patch to CheckTypeSize is not much smaller.  Instead of executing
the program and using the return value (doesn't work for return values
greater than 255), we simply inject `-oformat=wasm` onto the link
command, and then we can use `strings` on the binary just like the
upstream check.  This is basically a single line patch against upstream
now.

Fixes: #18278 #18238 #17268 #18084 #17811
sbc100 added a commit that referenced this issue Dec 5, 2022
Update the CheckTypeSize files to v3.10.2 (mostly arbitrary version, but
this is what we use in CI).

Local patch to CheckTypeSize is not much smaller.  Instead of executing
the program and using the return value (doesn't work for return values
greater than 255), we simply inject `-oformat=wasm` onto the link
command, and then we can use `strings` on the binary just like the
upstream check.  This is basically a single line patch against upstream
now.

Fixes: #18278 #18238 #17268 #18084 #17811
sbc100 added a commit that referenced this issue Dec 5, 2022
Update the CheckTypeSize files to v3.10.2 (mostly arbitrary version, but
this is what we use in CI).

Local patch to CheckTypeSize is not much smaller.  Instead of executing
the program and using the return value (doesn't work for return values
greater than 255), we simply inject `-oformat=wasm` onto the link
command, and then we can use `strings` on the binary just like the
upstream check.  This is basically a single line patch against upstream
now.

This change also avoids a second issue which is that node failures (non-zero
return codes) are indistinguishable from non-zero return codes from user
code.

Fixes: #18278 #18238 #17268 #18084 #17811
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

2 participants