#How can I specify a 32-bit pointer type a when compiling to a 64-bit target?

1 messages · Page 1 of 1 (latest)

thick jacinth
#

I have a compiler which is tested on my local 64-bit machine, but it imports some types from some zig code that is separately compiled to wasm32 as part of the compiler runtime.
Is there a way to get the layout of a type for a specific target, not the target you are compiling to?

Or would it be best for me to:

  • write my own source-of-truth logic for runtime types for my compiler's supported targets
  • do some build.zig thing where I generate importable data exposing for each runtime target platform runtime type sizes
#

How can I specify a 32-bit pointer type a when compiling to a 64-bit target?

half nebula
#

couldnt the types use usize so that they're 32bit when compiled on wasm32 and 64bits on your machine?

thick jacinth
#

I am importing the (usually) 32-bit runtime types into my 64-bit compiler code, just to inspect the runtime types

#

so when compiling my compiler which wants to know the size of runtime types, the size of pointers is different than when compiling my runtime.

#

ngl I am assuming I will just want to do option 2 that I gave, where I invoke the zig compiler for each runtime platform just to generate platform-independent type (and field) sizes for each runtime type

#

but curious if there's like a @import("builtin").sizeOfOnPlatform(MyType, .wasm32)