-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
These are encountered at the $CC -o zig2 zig2.c compiler_rt.c -std=c99 ... step, with shell command ulimit -s unlimited to workaround stack-overflow mentioned at issue #22111
Here in stage1/zig.h, cpuid.h is included on any x86-64 compiler that is not MSVC. This header may not be present if the C compiler implemented their own preprocessor, tcc, slimcc as well as pcc, cparser, currently don't provide it.
Lines 11 to 17 in aa7d138
| #if _MSC_VER | |
| #include <intrin.h> | |
| #elif defined(__i386__) || defined(__x86_64__) | |
| #include <cpuid.h> | |
| #endif | |
With #include <cpuid.h> commented out (to see what lies ahead), tcc and slimcc failed at, respectively:
The zig_import macro use the non-standard __asm convention for function aliasing on any compiler not MSVC. slimcc stopped here, as its maintainer I will implement it ASAP.
Lines 224 to 234 in aa7d138
| #if _MSC_VER | |
| #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\ | |
| __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name))); | |
| #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args) | |
| #else /* _MSC_VER */ | |
| #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name)); | |
| #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \ | |
| static inline Type fn_name sig_args { return libc_name call_args; } | |
| #endif | |
tcc stopped at this point,
Lines 1250 to 1252 in aa7d138
| typedef struct { zig_align(16) uint64_t hi; uint64_t lo; } zig_u128; | |
| typedef struct { zig_align(16) int64_t hi; uint64_t lo; } zig_i128; | |
| #endif |
since it does not advertise
__has_attribute((aligned)) and the build driver passes -std=c99, zig_align expands to zig_align_unavailable as the result of these two macro, failing the compilation.Lines 132 to 146 in aa7d138
| #if zig_has_attribute(aligned) | |
| #define zig_under_align(alignment) __attribute__((aligned(alignment))) | |
| #elif _MSC_VER | |
| #define zig_under_align(alignment) __declspec(align(alignment)) | |
| #else | |
| #define zig_under_align zig_align_unavailable | |
| #endif | |
| #if __STDC_VERSION__ >= 201112L | |
| #define zig_align(alignment) _Alignas(alignment) | |
| #else | |
| #define zig_align(alignment) zig_under_align(alignment) | |
| #endif | |