From cc7034146e2fa522d573ba88980b66599231a950 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 16:22:19 +0100 Subject: [PATCH 01/32] windows compatibility part 1, untested pulled this from: https://github.com/allyourcodebase/nasm/pull/4 --- build.zig | 75 +++++++++++++++++++++++----------------------- config/config.h.in | 3 ++ 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/build.zig b/build.zig index f85620f0..774ee567 100644 --- a/build.zig +++ b/build.zig @@ -89,17 +89,17 @@ pub fn build(b: *std.Build) void { .HAVE_DECL_STRICMP = 0, .HAVE_DECL_STRLCPY = 0, .HAVE_DECL_STRNCASECMP = 0, - .HAVE_DECL_STRNICMP = 0, - .HAVE_DECL_STRNLEN = 0, + .HAVE_DECL_STRNICMP = @as(u32, if (target.result.os.tag == .windows) 1 else 0), + .HAVE_DECL_STRNLEN = @as(u32, if (target.result.os.tag == .windows) 1 else 0), .HAVE_DECL_STRRCHRNUL = 0, .HAVE_DECL_STRSEP = 0, - .HAVE_ENDIAN_H = 1, - .HAVE_FACCESSAT = 1, + .HAVE_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_FACCESSAT = have(target.result.os.tag != .windows), .HAVE_FCNTL_H = 1, .HAVE_FILENO = 1, - .HAVE_FSEEKO = 1, - .HAVE_FSTAT = 1, - .HAVE_FTRUNCATE = 1, + .HAVE_FSEEKO = have(target.result.os.tag != .windows), + .HAVE_FSTAT = have(target.result.os.tag != .windows), + .HAVE_FTRUNCATE = have(target.result.os.tag != .windows), .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = 1, .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = null, .HAVE_FUNC_ATTRIBUTE3_FORMAT = 1, @@ -132,40 +132,40 @@ pub fn build(b: *std.Build) void { .HAVE_HTOLE64 = null, .HAVE_INTRIN_H = 1, .HAVE_INTTYPES_H = 1, - .HAVE_IO_H = null, - .HAVE_ISASCII = 1, - .HAVE_ISCNTRL = 1, - .HAVE_MACHINE_ENDIAN_H = 1, - .HAVE_MEMPCPY = 1, + .HAVE_IO_H = have(target.result.os.tag == .windows), + .HAVE_ISASCII = have(target.result.os.tag != .windows), + .HAVE_ISCNTRL = have(target.result.os.tag != .windows), + .HAVE_MACHINE_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_MEMPCPY = have(target.result.os.tag != .windows), .HAVE_MEMPSET = null, .HAVE_MINIX_CONFIG_H = null, - .HAVE_MMAP = 1, + .HAVE_MMAP = have(target.result.os.tag != .windows), .HAVE_PATHCONF = null, - .HAVE_REALPATH = 1, + .HAVE_REALPATH = have(target.result.os.tag != .windows), .HAVE_SNPRINTF = 1, - .HAVE_STAT = 1, - .HAVE_STDARG_H = 1, + .HAVE_STAT = have(target.result.os.tag != .windows), + .HAVE_STDARG_H = have(target.result.os.tag != .windows), .HAVE_STDBOOL_H = 1, - .HAVE_STDC_INLINE = 1, - .HAVE_STDINT_H = 1, - .HAVE_STDIO_H = 1, + .HAVE_STDC_INLINE = have(target.result.os.tag != .windows), + .HAVE_STDINT_H = have(target.result.os.tag != .windows), + .HAVE_STDIO_H = have(target.result.os.tag != .windows), .HAVE_STDLIB_H = 1, - .HAVE_STDNORETURN_H = 1, - .HAVE_STRCASECMP = 1, - .HAVE_STRICMP = 1, - .HAVE_STRINGS_H = 1, + .HAVE_STDNORETURN_H = have(target.result.os.tag != .windows), + .HAVE_STRCASECMP = have(target.result.os.tag != .windows), + .HAVE_STRICMP = have(target.result.os.tag != .windows), + .HAVE_STRINGS_H = have(target.result.os.tag != .windows), .HAVE_STRING_H = 1, .HAVE_STRLCPY = null, - .HAVE_STRNCASECMP = 1, - .HAVE_STRNICMP = 1, - .HAVE_STRNLEN = 1, + .HAVE_STRNCASECMP = have(target.result.os.tag != .windows), + .HAVE_STRNICMP = have(target.result.os.tag != .windows), + .HAVE_STRNLEN = have(target.result.os.tag == .windows), .HAVE_STRRCHRNUL = null, .HAVE_STRSEP = null, .HAVE_STRUCT_STAT = null, - .HAVE_STRUCT__STATI64 = null, + .HAVE_STRUCT__STATI64 = have(target.result.os.tag == .windows), .HAVE_SYSCONF = null, - .HAVE_SYS_ENDIAN_H = 1, - .HAVE_SYS_MMAN_H = 1, + .HAVE_SYS_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_SYS_MMAN_H = have(target.result.os.tag != .windows), .HAVE_SYS_PARAM_H = null, .HAVE_SYS_RESOURCE_H = null, .HAVE_SYS_STAT_H = 1, @@ -174,7 +174,7 @@ pub fn build(b: *std.Build) void { .HAVE_TYPEOF = null, .HAVE_UINTPTR_T = 1, .HAVE_UNISTD_H = null, - .HAVE_VSNPRINTF = null, + .HAVE_VSNPRINTF = have(target.result.os.tag == .windows), .HAVE_WCHAR_H = null, .HAVE__ACCESS = null, .HAVE__BITSCANREVERSE = null, @@ -183,13 +183,14 @@ pub fn build(b: *std.Build) void { .HAVE__BYTESWAP_UINT64 = null, .HAVE__BYTESWAP_ULONG = null, .HAVE__BYTESWAP_USHORT = null, - .HAVE__CHSIZE = null, - .HAVE__CHSIZE_S = null, - .HAVE__FILENO = null, - .HAVE__FSEEKI64 = null, - .HAVE__FSTATI64 = null, - .HAVE__FULLPATH = null, - .HAVE__STATI64 = null, + .HAVE__CHSIZE = have(target.result.os.tag == .windows), + .HAVE__CHSIZE_S = have(target.result.os.tag == .windows), + .HAVE__FILENO = have(target.result.os.tag == .windows), + .HAVE__FSEEKI64 = have(target.result.os.tag == .windows), + .HAVE__FSTATI64 = have(target.result.os.tag == .windows), + .HAVE__FULLPATH = have(target.result.os.tag == .windows), + .HAVE__STATI64 = have(target.result.os.tag == .windows), + .HAVE__FILELENGTHI64 = have(target.result.os.tag == .windows), .HAVE___BSWAP_16 = 1, .HAVE___BSWAP_32 = 1, .HAVE___BSWAP_64 = 1, diff --git a/config/config.h.in b/config/config.h.in index eb991906..21bac512 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -514,6 +514,9 @@ /* Define to 1 if you have the `_fullpath' function. */ #undef HAVE__FULLPATH +/* Define to 1 if you have the `_filelengthi64' function. */ +#undef HAVE__FILELENGTHI64 + /* Define to 1 if you have the `_stati64' function. */ #undef HAVE__STATI64 From aedb57e6bb826389c813416f4a6430e604923966 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 16:27:09 +0100 Subject: [PATCH 02/32] add ci --- .github/workflows/ci.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..3fa1db96 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: ci + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build: + name: build / linux / zig ${{ matrix.zig-version }} + + strategy: + fail-fast: false + matrix: + zig-version: ["master", "0.13.0"] + os: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Zig + uses: mlugg/setup-zig@v1 + with: + version: ${{ matrix.zig-version }} + + - name: Build + run: zig build --release=fast --summary all From c0822fef02d5992f28e423a56e1630a5eecc56b9 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 16:29:04 +0100 Subject: [PATCH 03/32] ci: fix step name --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3fa1db96..4162ed38 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ on: jobs: build: - name: build / linux / zig ${{ matrix.zig-version }} + name: build / ${{ matrix.os }} / zig ${{ matrix.zig-version }} strategy: fail-fast: false From 43ee326db067b6083f2cf05c6a48617e9fca054e Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 16:37:06 +0100 Subject: [PATCH 04/32] unset HAVE_ENDIAN_H for macos --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 774ee567..949a8da5 100644 --- a/build.zig +++ b/build.zig @@ -93,7 +93,7 @@ pub fn build(b: *std.Build) void { .HAVE_DECL_STRNLEN = @as(u32, if (target.result.os.tag == .windows) 1 else 0), .HAVE_DECL_STRRCHRNUL = 0, .HAVE_DECL_STRSEP = 0, - .HAVE_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_ENDIAN_H = have(target.result.os.tag == .linux), .HAVE_FACCESSAT = have(target.result.os.tag != .windows), .HAVE_FCNTL_H = 1, .HAVE_FILENO = 1, @@ -135,7 +135,7 @@ pub fn build(b: *std.Build) void { .HAVE_IO_H = have(target.result.os.tag == .windows), .HAVE_ISASCII = have(target.result.os.tag != .windows), .HAVE_ISCNTRL = have(target.result.os.tag != .windows), - .HAVE_MACHINE_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_MACHINE_ENDIAN_H = have(target.result.os.tag == .macos), .HAVE_MEMPCPY = have(target.result.os.tag != .windows), .HAVE_MEMPSET = null, .HAVE_MINIX_CONFIG_H = null, @@ -164,7 +164,7 @@ pub fn build(b: *std.Build) void { .HAVE_STRUCT_STAT = null, .HAVE_STRUCT__STATI64 = have(target.result.os.tag == .windows), .HAVE_SYSCONF = null, - .HAVE_SYS_ENDIAN_H = have(target.result.os.tag != .windows), + .HAVE_SYS_ENDIAN_H = null, .HAVE_SYS_MMAN_H = have(target.result.os.tag != .windows), .HAVE_SYS_PARAM_H = null, .HAVE_SYS_RESOURCE_H = null, From fffd153173610ab40f2018f21e54dcaf2bd53f8c Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 16:45:52 +0100 Subject: [PATCH 05/32] todo to fix this multiplatform issue --- build.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.zig b/build.zig index 949a8da5..8023eb36 100644 --- a/build.zig +++ b/build.zig @@ -27,6 +27,9 @@ pub fn build(b: *std.Build) void { .NASM_VERSION_ID = 0x02100100, .NASM_VER = "2.16.01", })); + // TODO: Instead of manually going through all of these better just build + // nasm on linux, macos and windows, then intercept the config.h.in + // generated by autoheader and put them here. exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, .include_path = "config/config.h", From 7d9ebfe41bade006475d4f11253ebcfe8ac037f9 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 21:40:13 +0100 Subject: [PATCH 06/32] adding macos (untested) --- build.zig | 515 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 479 insertions(+), 36 deletions(-) diff --git a/build.zig b/build.zig index 8023eb36..06a28360 100644 --- a/build.zig +++ b/build.zig @@ -92,17 +92,17 @@ pub fn build(b: *std.Build) void { .HAVE_DECL_STRICMP = 0, .HAVE_DECL_STRLCPY = 0, .HAVE_DECL_STRNCASECMP = 0, - .HAVE_DECL_STRNICMP = @as(u32, if (target.result.os.tag == .windows) 1 else 0), - .HAVE_DECL_STRNLEN = @as(u32, if (target.result.os.tag == .windows) 1 else 0), + .HAVE_DECL_STRNICMP = 0, + .HAVE_DECL_STRNLEN = 0, .HAVE_DECL_STRRCHRNUL = 0, .HAVE_DECL_STRSEP = 0, .HAVE_ENDIAN_H = have(target.result.os.tag == .linux), - .HAVE_FACCESSAT = have(target.result.os.tag != .windows), + .HAVE_FACCESSAT = 1, .HAVE_FCNTL_H = 1, .HAVE_FILENO = 1, - .HAVE_FSEEKO = have(target.result.os.tag != .windows), - .HAVE_FSTAT = have(target.result.os.tag != .windows), - .HAVE_FTRUNCATE = have(target.result.os.tag != .windows), + .HAVE_FSEEKO = 1, + .HAVE_FSTAT = 1, + .HAVE_FTRUNCATE = 1, .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = 1, .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = null, .HAVE_FUNC_ATTRIBUTE3_FORMAT = 1, @@ -135,40 +135,40 @@ pub fn build(b: *std.Build) void { .HAVE_HTOLE64 = null, .HAVE_INTRIN_H = 1, .HAVE_INTTYPES_H = 1, - .HAVE_IO_H = have(target.result.os.tag == .windows), - .HAVE_ISASCII = have(target.result.os.tag != .windows), - .HAVE_ISCNTRL = have(target.result.os.tag != .windows), + .HAVE_IO_H = null, + .HAVE_ISASCII = 1, + .HAVE_ISCNTRL = 1, .HAVE_MACHINE_ENDIAN_H = have(target.result.os.tag == .macos), - .HAVE_MEMPCPY = have(target.result.os.tag != .windows), + .HAVE_MEMPCPY = 1, .HAVE_MEMPSET = null, .HAVE_MINIX_CONFIG_H = null, - .HAVE_MMAP = have(target.result.os.tag != .windows), + .HAVE_MMAP = 1, .HAVE_PATHCONF = null, - .HAVE_REALPATH = have(target.result.os.tag != .windows), + .HAVE_REALPATH = 1, .HAVE_SNPRINTF = 1, - .HAVE_STAT = have(target.result.os.tag != .windows), - .HAVE_STDARG_H = have(target.result.os.tag != .windows), + .HAVE_STAT = 1, + .HAVE_STDARG_H = 1, .HAVE_STDBOOL_H = 1, - .HAVE_STDC_INLINE = have(target.result.os.tag != .windows), - .HAVE_STDINT_H = have(target.result.os.tag != .windows), - .HAVE_STDIO_H = have(target.result.os.tag != .windows), + .HAVE_STDC_INLINE = 1, + .HAVE_STDINT_H = 1, + .HAVE_STDIO_H = 1, .HAVE_STDLIB_H = 1, - .HAVE_STDNORETURN_H = have(target.result.os.tag != .windows), - .HAVE_STRCASECMP = have(target.result.os.tag != .windows), - .HAVE_STRICMP = have(target.result.os.tag != .windows), - .HAVE_STRINGS_H = have(target.result.os.tag != .windows), + .HAVE_STDNORETURN_H = 1, + .HAVE_STRCASECMP = 1, + .HAVE_STRICMP = 1, + .HAVE_STRINGS_H = 1, .HAVE_STRING_H = 1, .HAVE_STRLCPY = null, - .HAVE_STRNCASECMP = have(target.result.os.tag != .windows), - .HAVE_STRNICMP = have(target.result.os.tag != .windows), - .HAVE_STRNLEN = have(target.result.os.tag == .windows), + .HAVE_STRNCASECMP = 1, + .HAVE_STRNICMP = 1, + .HAVE_STRNLEN = null, .HAVE_STRRCHRNUL = null, .HAVE_STRSEP = null, .HAVE_STRUCT_STAT = null, - .HAVE_STRUCT__STATI64 = have(target.result.os.tag == .windows), + .HAVE_STRUCT__STATI64 = null, .HAVE_SYSCONF = null, .HAVE_SYS_ENDIAN_H = null, - .HAVE_SYS_MMAN_H = have(target.result.os.tag != .windows), + .HAVE_SYS_MMAN_H = 1, .HAVE_SYS_PARAM_H = null, .HAVE_SYS_RESOURCE_H = null, .HAVE_SYS_STAT_H = 1, @@ -177,7 +177,7 @@ pub fn build(b: *std.Build) void { .HAVE_TYPEOF = null, .HAVE_UINTPTR_T = 1, .HAVE_UNISTD_H = null, - .HAVE_VSNPRINTF = have(target.result.os.tag == .windows), + .HAVE_VSNPRINTF = null, .HAVE_WCHAR_H = null, .HAVE__ACCESS = null, .HAVE__BITSCANREVERSE = null, @@ -186,14 +186,14 @@ pub fn build(b: *std.Build) void { .HAVE__BYTESWAP_UINT64 = null, .HAVE__BYTESWAP_ULONG = null, .HAVE__BYTESWAP_USHORT = null, - .HAVE__CHSIZE = have(target.result.os.tag == .windows), - .HAVE__CHSIZE_S = have(target.result.os.tag == .windows), - .HAVE__FILENO = have(target.result.os.tag == .windows), - .HAVE__FSEEKI64 = have(target.result.os.tag == .windows), - .HAVE__FSTATI64 = have(target.result.os.tag == .windows), - .HAVE__FULLPATH = have(target.result.os.tag == .windows), - .HAVE__STATI64 = have(target.result.os.tag == .windows), - .HAVE__FILELENGTHI64 = have(target.result.os.tag == .windows), + .HAVE__CHSIZE = null, + .HAVE__CHSIZE_S = null, + .HAVE__FILENO = null, + .HAVE__FSEEKI64 = null, + .HAVE__FSTATI64 = null, + .HAVE__FULLPATH = null, + .HAVE__STATI64 = null, + .HAVE__FILELENGTHI64 = null, .HAVE___BSWAP_16 = 1, .HAVE___BSWAP_32 = 1, .HAVE___BSWAP_64 = 1, @@ -351,6 +351,449 @@ pub fn build(b: *std.Build) void { b.installArtifact(exe); } +fn config_flags() anytype { + return switch (target.os.tag) { + .linux => .{ + .ABORT_ON_PANIC = have(optimize == .Debug), + .AC_APPLE_UNIVERSAL_BUILD = null, + .CFLAGS_FDATA_SECTIONS = null, + .CFLAGS_FFUNCTION_SECTIONS = null, + .CFLAGS_FGNU89_INLINE = null, + .CFLAGS_FLTO = null, + .CFLAGS_FNO_COMMON = null, + .CFLAGS_FNO_OMIT_FRAME_POINTER = null, + .CFLAGS_FSANITIZE_ADDRESS = null, + .CFLAGS_FSANITIZE_UNDEFINED = null, + .CFLAGS_FTRIVIAL_AUTO_VAR_INIT_ZERO = null, + .CFLAGS_FVISIBILITY_HIDDEN = null, + .CFLAGS_FWRAPV = null, + .CFLAGS_GGDB3 = null, + .CFLAGS_O0 = have(optimize == .Debug), + .CFLAGS_PEDANTIC = null, + .CFLAGS_PG = null, + .CFLAGS_STD_C11 = null, + .CFLAGS_STD_C17 = 1, + .CFLAGS_STD_C99 = null, + .CFLAGS_U_STRICT_ANSI = null, + .CFLAGS_W = null, + .CFLAGS_WALL = null, + .CFLAGS_WC90_C99_COMPAT = null, + .CFLAGS_WC99_COMPAT = null, + .CFLAGS_WC99_EXTENSIONS = null, + .CFLAGS_WERROR = null, + .CFLAGS_WERROR_ATTRIBUTES = null, + .CFLAGS_WERROR_COMMENT = null, + .CFLAGS_WERROR_IMPLICIT = null, + .CFLAGS_WERROR_MISSING_BRACES = null, + .CFLAGS_WERROR_MISSING_DECLARATIONS = null, + .CFLAGS_WERROR_MISSING_PROTOTYPES = null, + .CFLAGS_WERROR_POINTER_ARITH = null, + .CFLAGS_WERROR_RETURN_TYPE = null, + .CFLAGS_WERROR_STRICT_PROTOTYPES = null, + .CFLAGS_WERROR_TRIGRAPHS = null, + .CFLAGS_WERROR_UNKNOWN_WARNING_OPTION = null, + .CFLAGS_WERROR_VLA = null, + .CFLAGS_WLONG_LONG = null, + .CFLAGS_WPEDANTIC_MS_FORMAT = null, + .CFLAGS_WSHIFT_NEGATIVE_VALUE = null, + .CFLAGS_WSTRINGOP_TRUNCATION = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_COLD = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_CONST = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_FORMAT = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_MALLOC = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_NORETURN = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_PURE = null, + .HAVE_ACCESS = 1, + .HAVE_CANONICALIZE_FILE_NAME = null, + .HAVE_CPU_TO_LE16 = null, + .HAVE_CPU_TO_LE32 = null, + .HAVE_CPU_TO_LE64 = null, + .HAVE_DECL_STRCASECMP = 0, + .HAVE_DECL_STRICMP = 0, + .HAVE_DECL_STRLCPY = 0, + .HAVE_DECL_STRNCASECMP = 0, + .HAVE_DECL_STRNICMP = 0, + .HAVE_DECL_STRNLEN = 0, + .HAVE_DECL_STRRCHRNUL = 0, + .HAVE_DECL_STRSEP = 0, + .HAVE_ENDIAN_H = 1, + .HAVE_FACCESSAT = 1, + .HAVE_FCNTL_H = 1, + .HAVE_FILENO = 1, + .HAVE_FSEEKO = 1, + .HAVE_FSTAT = 1, + .HAVE_FTRUNCATE = 1, + .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = 1, + .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = null, + .HAVE_FUNC_ATTRIBUTE3_FORMAT = 1, + .HAVE_FUNC_ATTRIBUTE_COLD = 1, + .HAVE_FUNC_ATTRIBUTE_CONST = 1, + .HAVE_FUNC_ATTRIBUTE_ERROR = 1, + .HAVE_FUNC_ATTRIBUTE_MALLOC = 1, + .HAVE_FUNC_ATTRIBUTE_NORETURN = 1, + .HAVE_FUNC_ATTRIBUTE_PURE = 1, + .HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL = 1, + .HAVE_FUNC_ATTRIBUTE_SENTINEL = 1, + .HAVE_FUNC_ATTRIBUTE_UNUSED = 1, + .HAVE_FUNC_PTR_ATTRIBUTE1_ALLOC_SIZE = 1, + .HAVE_FUNC_PTR_ATTRIBUTE2_ALLOC_SIZE = null, + .HAVE_FUNC_PTR_ATTRIBUTE3_FORMAT = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_COLD = null, + .HAVE_FUNC_PTR_ATTRIBUTE_CONST = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_MALLOC = null, + .HAVE_FUNC_PTR_ATTRIBUTE_NORETURN = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_PURE = null, + .HAVE_FUNC_PTR_ATTRIBUTE_RETURNS_NONNULL = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_SENTINEL = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_UNUSED = 1, + .HAVE_GETGID = null, + .HAVE_GETPAGESIZE = null, + .HAVE_GETRLIMIT = null, + .HAVE_GETUID = null, + .HAVE_HTOLE16 = null, + .HAVE_HTOLE32 = null, + .HAVE_HTOLE64 = null, + .HAVE_INTRIN_H = 1, + .HAVE_INTTYPES_H = 1, + .HAVE_IO_H = null, + .HAVE_ISASCII = 1, + .HAVE_ISCNTRL = 1, + .HAVE_MACHINE_ENDIAN_H = 0, + .HAVE_MEMPCPY = 1, + .HAVE_MEMPSET = null, + .HAVE_MINIX_CONFIG_H = null, + .HAVE_MMAP = 1, + .HAVE_PATHCONF = null, + .HAVE_REALPATH = 1, + .HAVE_SNPRINTF = 1, + .HAVE_STAT = 1, + .HAVE_STDARG_H = 1, + .HAVE_STDBOOL_H = 1, + .HAVE_STDC_INLINE = 1, + .HAVE_STDINT_H = 1, + .HAVE_STDIO_H = 1, + .HAVE_STDLIB_H = 1, + .HAVE_STDNORETURN_H = 1, + .HAVE_STRCASECMP = 1, + .HAVE_STRICMP = 1, + .HAVE_STRINGS_H = 1, + .HAVE_STRING_H = 1, + .HAVE_STRLCPY = null, + .HAVE_STRNCASECMP = 1, + .HAVE_STRNICMP = 1, + .HAVE_STRNLEN = null, + .HAVE_STRRCHRNUL = null, + .HAVE_STRSEP = null, + .HAVE_STRUCT_STAT = null, + .HAVE_STRUCT__STATI64 = null, + .HAVE_SYSCONF = null, + .HAVE_SYS_ENDIAN_H = null, + .HAVE_SYS_MMAN_H = 1, + .HAVE_SYS_PARAM_H = null, + .HAVE_SYS_RESOURCE_H = null, + .HAVE_SYS_STAT_H = 1, + .HAVE_SYS_TYPES_H = 1, + .HAVE_S_ISREG = null, + .HAVE_TYPEOF = null, + .HAVE_UINTPTR_T = 1, + .HAVE_UNISTD_H = null, + .HAVE_VSNPRINTF = null, + .HAVE_WCHAR_H = null, + .HAVE__ACCESS = null, + .HAVE__BITSCANREVERSE = null, + .HAVE__BITSCANREVERSE64 = null, + .HAVE__BOOL = 1, + .HAVE__BYTESWAP_UINT64 = null, + .HAVE__BYTESWAP_ULONG = null, + .HAVE__BYTESWAP_USHORT = null, + .HAVE__CHSIZE = null, + .HAVE__CHSIZE_S = null, + .HAVE__FILENO = null, + .HAVE__FSEEKI64 = null, + .HAVE__FSTATI64 = null, + .HAVE__FULLPATH = null, + .HAVE__STATI64 = null, + .HAVE__FILELENGTHI64 = null, + .HAVE___BSWAP_16 = 1, + .HAVE___BSWAP_32 = 1, + .HAVE___BSWAP_64 = 1, + .HAVE___BUILTIN_BSWAP16 = 1, + .HAVE___BUILTIN_BSWAP32 = 1, + .HAVE___BUILTIN_BSWAP64 = 1, + .HAVE___BUILTIN_CHOOSE_EXPR = 1, + .HAVE___BUILTIN_CLZ = 1, + .HAVE___BUILTIN_CLZL = 1, + .HAVE___BUILTIN_CLZLL = 1, + .HAVE___BUILTIN_CONSTANT_P = 1, + .HAVE___BUILTIN_EXPECT = 1, + .HAVE___CPU_TO_LE16 = null, + .HAVE___CPU_TO_LE32 = null, + .HAVE___CPU_TO_LE64 = null, + .LDFLAGS_WL_GC_SECTIONS = null, + .PACKAGE_BUGREPORT = "", + .PACKAGE_NAME = "", + .PACKAGE_STRING = "", + .PACKAGE_TARNAME = "", + .PACKAGE_URL = "", + .PACKAGE_VERSION = "", + .STDC_HEADERS = 1, + ._ALL_SOURCE = 1, + ._DARWIN_C_SOURCE = 1, + .__EXTENSIONS__ = 1, + ._GNU_SOURCE = 1, + ._HPUX_ALT_XOPEN_SOCKET_API = 1, + ._MINIX = null, + ._NETBSD_SOURCE = 1, + ._OPENBSD_SOURCE = 1, + ._POSIX_SOURCE = null, + ._POSIX_1_SOURCE = null, + ._POSIX_PTHREAD_SEMANTICS = 1, + .__STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1, + .__STDC_WANT_IEC_60559_BFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_DFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_FUNCS_EXT__ = 1, + .__STDC_WANT_IEC_60559_TYPES_EXT__ = 1, + .__STDC_WANT_LIB_EXT2__ = 1, + .__STDC_WANT_MATH_SPEC_FUNCS__ = 1, + ._TANDEM_SOURCE = 1, + ._XOPEN_SOURCE = null, + .WORDS_BIGENDIAN = have(t.cpu.arch.endian() == .big), + .WORDS_LITTLEENDIAN = have(t.cpu.arch.endian() != .big), + ._FILE_OFFSET_BITS = null, + ._LARGEFILE_SOURCE = null, + ._LARGE_FILES = null, + .@"const" = .@"const", + .@"inline" = .@"inline", + .restrict = .restrict, + .size_t = null, + .snprintf = null, + .typeof = .__typeof, + .uintptr_t = null, + .vsnprintf = null, + }, + .macos => .{ + .ABORT_ON_PANIC = have(optimize == .Debug), + .AC_APPLE_UNIVERSAL_BUILD = null, + .CFLAGS_FDATA_SECTIONS = null, + .CFLAGS_FFUNCTION_SECTIONS = null, + .CFLAGS_FGNU89_INLINE = null, + .CFLAGS_FLTO = null, + .CFLAGS_FNO_COMMON = null, + .CFLAGS_FNO_OMIT_FRAME_POINTER = null, + .CFLAGS_FSANITIZE_ADDRESS = null, + .CFLAGS_FSANITIZE_UNDEFINED = null, + .CFLAGS_FTRIVIAL_AUTO_VAR_INIT_ZERO = null, + .CFLAGS_FVISIBILITY_HIDDEN = null, + .CFLAGS_FWRAPV = null, + .CFLAGS_GGDB3 = null, + .CFLAGS_O0 = have(optimize == .Debug), + .CFLAGS_PEDANTIC = null, + .CFLAGS_PG = null, + .CFLAGS_STD_C11 = null, + .CFLAGS_STD_C17 = 1, + .CFLAGS_STD_C99 = null, + .CFLAGS_U_STRICT_ANSI = null, + .CFLAGS_W = null, + .CFLAGS_WALL = null, + .CFLAGS_WC90_C99_COMPAT = null, + .CFLAGS_WC99_COMPAT = null, + .CFLAGS_WC99_EXTENSIONS = null, + .CFLAGS_WERROR = null, + .CFLAGS_WERROR_ATTRIBUTES = null, + .CFLAGS_WERROR_COMMENT = null, + .CFLAGS_WERROR_IMPLICIT = null, + .CFLAGS_WERROR_MISSING_BRACES = null, + .CFLAGS_WERROR_MISSING_DECLARATIONS = null, + .CFLAGS_WERROR_MISSING_PROTOTYPES = null, + .CFLAGS_WERROR_POINTER_ARITH = null, + .CFLAGS_WERROR_RETURN_TYPE = null, + .CFLAGS_WERROR_STRICT_PROTOTYPES = null, + .CFLAGS_WERROR_TRIGRAPHS = null, + .CFLAGS_WERROR_UNKNOWN_WARNING_OPTION = null, + .CFLAGS_WERROR_VLA = null, + .CFLAGS_WLONG_LONG = null, + .CFLAGS_WPEDANTIC_MS_FORMAT = null, + .CFLAGS_WSHIFT_NEGATIVE_VALUE = null, + .CFLAGS_WSTRINGOP_TRUNCATION = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_COLD = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_CONST = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_FORMAT = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_MALLOC = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_NORETURN = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_PURE = null, + .HAVE_ACCESS = 1, + .HAVE_CANONICALIZE_FILE_NAME = null, + .HAVE_CPU_TO_LE16 = null, + .HAVE_CPU_TO_LE32 = null, + .HAVE_CPU_TO_LE64 = null, + .HAVE_DECL_STRCASECMP = 1, + .HAVE_DECL_STRICMP = 0, + .HAVE_DECL_STRLCPY = 1, + .HAVE_DECL_STRNCASECMP = 1, + .HAVE_DECL_STRNICMP = 0, + .HAVE_DECL_STRNLEN = 1, + .HAVE_DECL_STRRCHRNUL = 0, + .HAVE_DECL_STRSEP = 1, + .HAVE_ENDIAN_H = null, + .HAVE_FACCESSAT = 1, + .HAVE_FCNTL_H = 1, + .HAVE_FILENO = 1, + .HAVE_FSEEKO = 1, + .HAVE_FSTAT = 1, + .HAVE_FTRUNCATE = 1, + .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = 1, + .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = 1, + .HAVE_FUNC_ATTRIBUTE3_FORMAT = 1, + .HAVE_FUNC_ATTRIBUTE_COLD = 1, + .HAVE_FUNC_ATTRIBUTE_CONST = 1, + .HAVE_FUNC_ATTRIBUTE_ERROR = 1, + .HAVE_FUNC_ATTRIBUTE_MALLOC = 1, + .HAVE_FUNC_ATTRIBUTE_NORETURN = 1, + .HAVE_FUNC_ATTRIBUTE_PURE = 1, + .HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL = 1, + .HAVE_FUNC_ATTRIBUTE_SENTINEL = 1, + .HAVE_FUNC_ATTRIBUTE_UNUSED = 1, + .HAVE_FUNC_PTR_ATTRIBUTE1_ALLOC_SIZE = 1, + .HAVE_FUNC_PTR_ATTRIBUTE2_ALLOC_SIZE = 1, + .HAVE_FUNC_PTR_ATTRIBUTE3_FORMAT = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_COLD = null, + .HAVE_FUNC_PTR_ATTRIBUTE_CONST = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_MALLOC = null, + .HAVE_FUNC_PTR_ATTRIBUTE_NORETURN = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_PURE = 1, + .HAVE_FUNC_PTR_ATTRIBUTE_RETURNS_NONNULL = null, + .HAVE_FUNC_PTR_ATTRIBUTE_SENTINEL = null, + .HAVE_FUNC_PTR_ATTRIBUTE_UNUSED = 1, + .HAVE_GETGID = 1, + .HAVE_GETPAGESIZE = 1, + .HAVE_GETRLIMIT = 1, + .HAVE_GETUID = 1, + .HAVE_HTOLE16 = null, + .HAVE_HTOLE32 = null, + .HAVE_HTOLE64 = null, + .HAVE_INTRIN_H = null, + .HAVE_INTTYPES_H = 1, + .HAVE_IO_H = null, + .HAVE_ISASCII = 1, + .HAVE_ISCNTRL = 1, + .HAVE_MACHINE_ENDIAN_H = 1, + .HAVE_MEMPCPY = null, + .HAVE_MEMPSET = null, + .HAVE_MINIX_CONFIG_H = null, + .HAVE_MMAP = 1, + .HAVE_PATHCONF = 1, + .HAVE_REALPATH = 1, + .HAVE_SNPRINTF = 1, + .HAVE_STAT = 1, + .HAVE_STDARG_H = 1, + .HAVE_STDBOOL_H = 1, + .HAVE_STDC_INLINE = 1, + .HAVE_STDINT_H = 1, + .HAVE_STDIO_H = 1, + .HAVE_STDLIB_H = 1, + .HAVE_STDNORETURN_H = 1, + .HAVE_STRCASECMP = 1, + .HAVE_STRICMP = null, + .HAVE_STRINGS_H = 1, + .HAVE_STRING_H = 1, + .HAVE_STRLCPY = 1, + .HAVE_STRNCASECMP = 1, + .HAVE_STRNICMP = null, + .HAVE_STRNLEN = 1, + .HAVE_STRRCHRNUL = null, + .HAVE_STRSEP = 1, + .HAVE_STRUCT_STAT = 1, + .HAVE_STRUCT__STATI64 = null, + .HAVE_SYSCONF = 1, + .HAVE_SYS_ENDIAN_H = null, + .HAVE_SYS_MMAN_H = 1, + .HAVE_SYS_PARAM_H = 1, + .HAVE_SYS_RESOURCE_H = 1, + .HAVE_SYS_STAT_H = 1, + .HAVE_SYS_TYPES_H = 1, + .HAVE_S_ISREG = null, + .HAVE_TYPEOF = 1, + .HAVE_UINTPTR_T = 1, + .HAVE_UNISTD_H = 1, + .HAVE_VSNPRINTF = 1, + .HAVE_WCHAR_H = 1, + .HAVE__ACCESS = null, + .HAVE__BITSCANREVERSE = null, + .HAVE__BITSCANREVERSE64 = null, + .HAVE__BOOL = 1, + .HAVE__BYTESWAP_UINT64 = null, + .HAVE__BYTESWAP_ULONG = null, + .HAVE__BYTESWAP_USHORT = null, + .HAVE__CHSIZE = null, + .HAVE__CHSIZE_S = null, + .HAVE__FILENO = null, + .HAVE__FSEEKI64 = null, + .HAVE__FSTATI64 = null, + .HAVE__FULLPATH = null, + .HAVE__STATI64 = null, + .HAVE__FILELENGTHI64 = null, + .HAVE___BSWAP_16 = null, + .HAVE___BSWAP_32 = null, + .HAVE___BSWAP_64 = null, + .HAVE___BUILTIN_BSWAP16 = 1, + .HAVE___BUILTIN_BSWAP32 = 1, + .HAVE___BUILTIN_BSWAP64 = 1, + .HAVE___BUILTIN_CHOOSE_EXPR = 1, + .HAVE___BUILTIN_CLZ = 1, + .HAVE___BUILTIN_CLZL = 1, + .HAVE___BUILTIN_CLZLL = 1, + .HAVE___BUILTIN_CONSTANT_P = 1, + .HAVE___BUILTIN_EXPECT = 1, + .HAVE___CPU_TO_LE16 = null, + .HAVE___CPU_TO_LE32 = null, + .HAVE___CPU_TO_LE64 = null, + .LDFLAGS_WL_GC_SECTIONS = null, + .PACKAGE_BUGREPORT = "", + .PACKAGE_NAME = "", + .PACKAGE_STRING = "", + .PACKAGE_TARNAME = "", + .PACKAGE_URL = "", + .PACKAGE_VERSION = "", + .STDC_HEADERS = 1, + ._ALL_SOURCE = 1, + ._DARWIN_C_SOURCE = 1, + .__EXTENSIONS__ = 1, + ._GNU_SOURCE = 1, + ._HPUX_ALT_XOPEN_SOCKET_API = 1, + ._MINIX = null, + ._NETBSD_SOURCE = 1, + ._OPENBSD_SOURCE = 1, + ._POSIX_SOURCE = null, + ._POSIX_1_SOURCE = null, + ._POSIX_PTHREAD_SEMANTICS = 1, + .__STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1, + .__STDC_WANT_IEC_60559_BFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_DFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_FUNCS_EXT__ = 1, + .__STDC_WANT_IEC_60559_TYPES_EXT__ = 1, + .__STDC_WANT_LIB_EXT2__ = 1, + .__STDC_WANT_MATH_SPEC_FUNCS__ = 1, + ._TANDEM_SOURCE = 1, + ._XOPEN_SOURCE = null, + .WORDS_BIGENDIAN = have(t.cpu.arch.endian() == .big), + .WORDS_LITTLEENDIAN = have(t.cpu.arch.endian() != .big), + ._FILE_OFFSET_BITS = null, + ._LARGEFILE_SOURCE = null, + ._LARGE_FILES = null, + .@"const" = .@"const", + .@"inline" = .@"inline", + .restrict = .restrict, + .size_t = null, + .snprintf = null, + .typeof = .__typeof, + .uintptr_t = null, + .vsnprintf = null, + }, + .windows => unreachable, // TODO + else => @panic("os not supported"), + } +} + fn have(c: bool) ?c_int { return if (c) 1 else null; -} +} \ No newline at end of file From 8909585fbc66e90874ee77627c736e8151ca3907 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 7 Jan 2025 21:42:21 +0100 Subject: [PATCH 07/32] add python script to generater config flags --- build.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 06a28360..20eeb23a 100644 --- a/build.zig +++ b/build.zig @@ -796,4 +796,19 @@ fn config_flags() anytype { fn have(c: bool) ?c_int { return if (c) 1 else null; -} \ No newline at end of file +} + +//import os +//HAVE = """HAVE IN HERE""" +//configh = open('config/config.h').read() +//for have in HAVE.splitlines(): + //constant = have.strip()[1:].split('=')[0].strip() + //def1 = f'#define {constant} 1\n' in configh + //def0 = f'#define {constant} 0\n' in configh + //undef = f'/* #undef {constant} */\n' in configh + //if def1: + // print(f" .{constant} = 1,") + //elif def0: + // print(f" .{constant} = 0,") + //elif undef: + // print(f" .{constant} = null,") From 6fef78992a3e6b8e85259832a3243b89908ea6f3 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 14:08:34 +0100 Subject: [PATCH 08/32] fixed issues in build.zig (macos build should work) --- build.zig | 444 ++++++++++++++---------------------------------------- 1 file changed, 110 insertions(+), 334 deletions(-) diff --git a/build.zig b/build.zig index 20eeb23a..d7f6a0bf 100644 --- a/build.zig +++ b/build.zig @@ -27,332 +27,10 @@ pub fn build(b: *std.Build) void { .NASM_VERSION_ID = 0x02100100, .NASM_VER = "2.16.01", })); - // TODO: Instead of manually going through all of these better just build - // nasm on linux, macos and windows, then intercept the config.h.in - // generated by autoheader and put them here. exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, .include_path = "config/config.h", - }, .{ - .ABORT_ON_PANIC = have(optimize == .Debug), - .AC_APPLE_UNIVERSAL_BUILD = null, - .CFLAGS_FDATA_SECTIONS = null, - .CFLAGS_FFUNCTION_SECTIONS = null, - .CFLAGS_FGNU89_INLINE = null, - .CFLAGS_FLTO = null, - .CFLAGS_FNO_COMMON = null, - .CFLAGS_FNO_OMIT_FRAME_POINTER = null, - .CFLAGS_FSANITIZE_ADDRESS = null, - .CFLAGS_FSANITIZE_UNDEFINED = null, - .CFLAGS_FTRIVIAL_AUTO_VAR_INIT_ZERO = null, - .CFLAGS_FVISIBILITY_HIDDEN = null, - .CFLAGS_FWRAPV = null, - .CFLAGS_GGDB3 = null, - .CFLAGS_O0 = have(optimize == .Debug), - .CFLAGS_PEDANTIC = null, - .CFLAGS_PG = null, - .CFLAGS_STD_C11 = null, - .CFLAGS_STD_C17 = 1, - .CFLAGS_STD_C99 = null, - .CFLAGS_U_STRICT_ANSI = null, - .CFLAGS_W = null, - .CFLAGS_WALL = null, - .CFLAGS_WC90_C99_COMPAT = null, - .CFLAGS_WC99_COMPAT = null, - .CFLAGS_WC99_EXTENSIONS = null, - .CFLAGS_WERROR = null, - .CFLAGS_WERROR_ATTRIBUTES = null, - .CFLAGS_WERROR_COMMENT = null, - .CFLAGS_WERROR_IMPLICIT = null, - .CFLAGS_WERROR_MISSING_BRACES = null, - .CFLAGS_WERROR_MISSING_DECLARATIONS = null, - .CFLAGS_WERROR_MISSING_PROTOTYPES = null, - .CFLAGS_WERROR_POINTER_ARITH = null, - .CFLAGS_WERROR_RETURN_TYPE = null, - .CFLAGS_WERROR_STRICT_PROTOTYPES = null, - .CFLAGS_WERROR_TRIGRAPHS = null, - .CFLAGS_WERROR_UNKNOWN_WARNING_OPTION = null, - .CFLAGS_WERROR_VLA = null, - .CFLAGS_WLONG_LONG = null, - .CFLAGS_WPEDANTIC_MS_FORMAT = null, - .CFLAGS_WSHIFT_NEGATIVE_VALUE = null, - .CFLAGS_WSTRINGOP_TRUNCATION = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_COLD = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_CONST = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_FORMAT = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_MALLOC = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_NORETURN = null, - .CFLAGS_WSUGGEST_ATTRIBUTE_PURE = null, - .HAVE_ACCESS = 1, - .HAVE_CANONICALIZE_FILE_NAME = null, - .HAVE_CPU_TO_LE16 = null, - .HAVE_CPU_TO_LE32 = null, - .HAVE_CPU_TO_LE64 = null, - .HAVE_DECL_STRCASECMP = 0, - .HAVE_DECL_STRICMP = 0, - .HAVE_DECL_STRLCPY = 0, - .HAVE_DECL_STRNCASECMP = 0, - .HAVE_DECL_STRNICMP = 0, - .HAVE_DECL_STRNLEN = 0, - .HAVE_DECL_STRRCHRNUL = 0, - .HAVE_DECL_STRSEP = 0, - .HAVE_ENDIAN_H = have(target.result.os.tag == .linux), - .HAVE_FACCESSAT = 1, - .HAVE_FCNTL_H = 1, - .HAVE_FILENO = 1, - .HAVE_FSEEKO = 1, - .HAVE_FSTAT = 1, - .HAVE_FTRUNCATE = 1, - .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = 1, - .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = null, - .HAVE_FUNC_ATTRIBUTE3_FORMAT = 1, - .HAVE_FUNC_ATTRIBUTE_COLD = 1, - .HAVE_FUNC_ATTRIBUTE_CONST = 1, - .HAVE_FUNC_ATTRIBUTE_ERROR = 1, - .HAVE_FUNC_ATTRIBUTE_MALLOC = 1, - .HAVE_FUNC_ATTRIBUTE_NORETURN = 1, - .HAVE_FUNC_ATTRIBUTE_PURE = 1, - .HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL = 1, - .HAVE_FUNC_ATTRIBUTE_SENTINEL = 1, - .HAVE_FUNC_ATTRIBUTE_UNUSED = 1, - .HAVE_FUNC_PTR_ATTRIBUTE1_ALLOC_SIZE = 1, - .HAVE_FUNC_PTR_ATTRIBUTE2_ALLOC_SIZE = null, - .HAVE_FUNC_PTR_ATTRIBUTE3_FORMAT = 1, - .HAVE_FUNC_PTR_ATTRIBUTE_COLD = null, - .HAVE_FUNC_PTR_ATTRIBUTE_CONST = 1, - .HAVE_FUNC_PTR_ATTRIBUTE_MALLOC = null, - .HAVE_FUNC_PTR_ATTRIBUTE_NORETURN = 1, - .HAVE_FUNC_PTR_ATTRIBUTE_PURE = null, - .HAVE_FUNC_PTR_ATTRIBUTE_RETURNS_NONNULL = 1, - .HAVE_FUNC_PTR_ATTRIBUTE_SENTINEL = 1, - .HAVE_FUNC_PTR_ATTRIBUTE_UNUSED = 1, - .HAVE_GETGID = null, - .HAVE_GETPAGESIZE = null, - .HAVE_GETRLIMIT = null, - .HAVE_GETUID = null, - .HAVE_HTOLE16 = null, - .HAVE_HTOLE32 = null, - .HAVE_HTOLE64 = null, - .HAVE_INTRIN_H = 1, - .HAVE_INTTYPES_H = 1, - .HAVE_IO_H = null, - .HAVE_ISASCII = 1, - .HAVE_ISCNTRL = 1, - .HAVE_MACHINE_ENDIAN_H = have(target.result.os.tag == .macos), - .HAVE_MEMPCPY = 1, - .HAVE_MEMPSET = null, - .HAVE_MINIX_CONFIG_H = null, - .HAVE_MMAP = 1, - .HAVE_PATHCONF = null, - .HAVE_REALPATH = 1, - .HAVE_SNPRINTF = 1, - .HAVE_STAT = 1, - .HAVE_STDARG_H = 1, - .HAVE_STDBOOL_H = 1, - .HAVE_STDC_INLINE = 1, - .HAVE_STDINT_H = 1, - .HAVE_STDIO_H = 1, - .HAVE_STDLIB_H = 1, - .HAVE_STDNORETURN_H = 1, - .HAVE_STRCASECMP = 1, - .HAVE_STRICMP = 1, - .HAVE_STRINGS_H = 1, - .HAVE_STRING_H = 1, - .HAVE_STRLCPY = null, - .HAVE_STRNCASECMP = 1, - .HAVE_STRNICMP = 1, - .HAVE_STRNLEN = null, - .HAVE_STRRCHRNUL = null, - .HAVE_STRSEP = null, - .HAVE_STRUCT_STAT = null, - .HAVE_STRUCT__STATI64 = null, - .HAVE_SYSCONF = null, - .HAVE_SYS_ENDIAN_H = null, - .HAVE_SYS_MMAN_H = 1, - .HAVE_SYS_PARAM_H = null, - .HAVE_SYS_RESOURCE_H = null, - .HAVE_SYS_STAT_H = 1, - .HAVE_SYS_TYPES_H = 1, - .HAVE_S_ISREG = null, - .HAVE_TYPEOF = null, - .HAVE_UINTPTR_T = 1, - .HAVE_UNISTD_H = null, - .HAVE_VSNPRINTF = null, - .HAVE_WCHAR_H = null, - .HAVE__ACCESS = null, - .HAVE__BITSCANREVERSE = null, - .HAVE__BITSCANREVERSE64 = null, - .HAVE__BOOL = 1, - .HAVE__BYTESWAP_UINT64 = null, - .HAVE__BYTESWAP_ULONG = null, - .HAVE__BYTESWAP_USHORT = null, - .HAVE__CHSIZE = null, - .HAVE__CHSIZE_S = null, - .HAVE__FILENO = null, - .HAVE__FSEEKI64 = null, - .HAVE__FSTATI64 = null, - .HAVE__FULLPATH = null, - .HAVE__STATI64 = null, - .HAVE__FILELENGTHI64 = null, - .HAVE___BSWAP_16 = 1, - .HAVE___BSWAP_32 = 1, - .HAVE___BSWAP_64 = 1, - .HAVE___BUILTIN_BSWAP16 = 1, - .HAVE___BUILTIN_BSWAP32 = 1, - .HAVE___BUILTIN_BSWAP64 = 1, - .HAVE___BUILTIN_CHOOSE_EXPR = 1, - .HAVE___BUILTIN_CLZ = 1, - .HAVE___BUILTIN_CLZL = 1, - .HAVE___BUILTIN_CLZLL = 1, - .HAVE___BUILTIN_CONSTANT_P = 1, - .HAVE___BUILTIN_EXPECT = 1, - .HAVE___CPU_TO_LE16 = null, - .HAVE___CPU_TO_LE32 = null, - .HAVE___CPU_TO_LE64 = null, - .LDFLAGS_WL_GC_SECTIONS = null, - .PACKAGE_BUGREPORT = "", - .PACKAGE_NAME = "", - .PACKAGE_STRING = "", - .PACKAGE_TARNAME = "", - .PACKAGE_URL = "", - .PACKAGE_VERSION = "", - .STDC_HEADERS = 1, - ._ALL_SOURCE = 1, - ._DARWIN_C_SOURCE = 1, - .__EXTENSIONS__ = 1, - ._GNU_SOURCE = 1, - ._HPUX_ALT_XOPEN_SOCKET_API = 1, - ._MINIX = null, - ._NETBSD_SOURCE = 1, - ._OPENBSD_SOURCE = 1, - ._POSIX_SOURCE = null, - ._POSIX_1_SOURCE = null, - ._POSIX_PTHREAD_SEMANTICS = 1, - .__STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1, - .__STDC_WANT_IEC_60559_BFP_EXT__ = 1, - .__STDC_WANT_IEC_60559_DFP_EXT__ = 1, - .__STDC_WANT_IEC_60559_FUNCS_EXT__ = 1, - .__STDC_WANT_IEC_60559_TYPES_EXT__ = 1, - .__STDC_WANT_LIB_EXT2__ = 1, - .__STDC_WANT_MATH_SPEC_FUNCS__ = 1, - ._TANDEM_SOURCE = 1, - ._XOPEN_SOURCE = null, - .WORDS_BIGENDIAN = have(t.cpu.arch.endian() == .big), - .WORDS_LITTLEENDIAN = have(t.cpu.arch.endian() != .big), - ._FILE_OFFSET_BITS = null, - ._LARGEFILE_SOURCE = null, - ._LARGE_FILES = null, - .@"const" = .@"const", - .@"inline" = .@"inline", - .restrict = .restrict, - .size_t = null, - .snprintf = null, - .typeof = .__typeof, - .uintptr_t = null, - .vsnprintf = null, - })); - const files = [_][]const u8{ - "nasmlib/alloc.c", - "nasmlib/asprintf.c", - "nasmlib/badenum.c", - "nasmlib/bsi.c", - "nasmlib/crc32.c", - "nasmlib/crc64.c", - "nasmlib/file.c", - "nasmlib/filename.c", - "nasmlib/hashtbl.c", - "nasmlib/ilog2.c", - "nasmlib/md5c.c", - "nasmlib/mmap.c", - "nasmlib/nctype.c", - "nasmlib/path.c", - "nasmlib/perfhash.c", - "nasmlib/raa.c", - "nasmlib/rbtree.c", - "nasmlib/readnum.c", - "nasmlib/realpath.c", - "nasmlib/rlimit.c", - "nasmlib/saa.c", - "nasmlib/string.c", - "nasmlib/strlist.c", - "nasmlib/ver.c", - "nasmlib/zerobuf.c", - - "asm/assemble.c", - "asm/directbl.c", - "asm/directiv.c", - "asm/error.c", - "asm/eval.c", - "asm/exprdump.c", - "asm/exprlib.c", - "asm/floats.c", - "asm/labels.c", - "asm/listing.c", - "asm/nasm.c", - "asm/parser.c", - "asm/pptok.c", - "asm/pragma.c", - "asm/preproc.c", - "asm/quote.c", - "asm/rdstrnum.c", - "asm/segalloc.c", - "asm/srcfile.c", - "asm/stdscan.c", - "asm/strfunc.c", - "asm/tokhash.c", - "asm/warnings.c", - - "stdlib/snprintf.c", - "stdlib/strlcpy.c", - "stdlib/strnlen.c", - "stdlib/strrchrnul.c", - "stdlib/vsnprintf.c", - - "x86/disp8.c", - "x86/iflag.c", - "x86/insnsa.c", - "x86/insnsb.c", - "x86/insnsd.c", - "x86/insnsn.c", - "x86/regflags.c", - "x86/regs.c", - "x86/regvals.c", - - "common/common.c", - - "macros/macros.c", - - "output/codeview.c", - "output/legacy.c", - "output/nulldbg.c", - "output/nullout.c", - "output/outaout.c", - "output/outas86.c", - "output/outbin.c", - "output/outcoff.c", - "output/outdbg.c", - "output/outelf.c", - "output/outform.c", - "output/outieee.c", - "output/outlib.c", - "output/outmacho.c", - "output/outobj.c", - }; - const flags = [_][]const u8{ - "-DHAVE_CONFIG_H", - "-std=c17", - "-Wno-implicit-function-declaration", - }; - exe.addCSourceFiles(.{ - .files = &files, - .flags = &flags, - }); - exe.linkLibC(); - b.installArtifact(exe); -} - -fn config_flags() anytype { - return switch (target.os.tag) { + }, switch (target.os.tag) { .linux => .{ .ABORT_ON_PANIC = have(optimize == .Debug), .AC_APPLE_UNIVERSAL_BUILD = null, @@ -791,7 +469,105 @@ fn config_flags() anytype { }, .windows => unreachable, // TODO else => @panic("os not supported"), - } + })); + const files = [_][]const u8{ + "nasmlib/alloc.c", + "nasmlib/asprintf.c", + "nasmlib/badenum.c", + "nasmlib/bsi.c", + "nasmlib/crc32.c", + "nasmlib/crc64.c", + "nasmlib/file.c", + "nasmlib/filename.c", + "nasmlib/hashtbl.c", + "nasmlib/ilog2.c", + "nasmlib/md5c.c", + "nasmlib/mmap.c", + "nasmlib/nctype.c", + "nasmlib/path.c", + "nasmlib/perfhash.c", + "nasmlib/raa.c", + "nasmlib/rbtree.c", + "nasmlib/readnum.c", + "nasmlib/realpath.c", + "nasmlib/rlimit.c", + "nasmlib/saa.c", + "nasmlib/string.c", + "nasmlib/strlist.c", + "nasmlib/ver.c", + "nasmlib/zerobuf.c", + + "asm/assemble.c", + "asm/directbl.c", + "asm/directiv.c", + "asm/error.c", + "asm/eval.c", + "asm/exprdump.c", + "asm/exprlib.c", + "asm/floats.c", + "asm/labels.c", + "asm/listing.c", + "asm/nasm.c", + "asm/parser.c", + "asm/pptok.c", + "asm/pragma.c", + "asm/preproc.c", + "asm/quote.c", + "asm/rdstrnum.c", + "asm/segalloc.c", + "asm/srcfile.c", + "asm/stdscan.c", + "asm/strfunc.c", + "asm/tokhash.c", + "asm/warnings.c", + + "stdlib/snprintf.c", + "stdlib/strlcpy.c", + "stdlib/strnlen.c", + "stdlib/strrchrnul.c", + "stdlib/vsnprintf.c", + + "x86/disp8.c", + "x86/iflag.c", + "x86/insnsa.c", + "x86/insnsb.c", + "x86/insnsd.c", + "x86/insnsn.c", + "x86/regflags.c", + "x86/regs.c", + "x86/regvals.c", + + "common/common.c", + + "macros/macros.c", + + "output/codeview.c", + "output/legacy.c", + "output/nulldbg.c", + "output/nullout.c", + "output/outaout.c", + "output/outas86.c", + "output/outbin.c", + "output/outcoff.c", + "output/outdbg.c", + "output/outelf.c", + "output/outform.c", + "output/outieee.c", + "output/outlib.c", + "output/outmacho.c", + "output/outobj.c", + }; + const flags = [_][]const u8{ + "-DHAVE_CONFIG_H", + "-std=c17", + "-Wno-implicit-function-declaration", + }; + exe.addCSourceFiles(.{ + .files = &files, + .flags = &flags, + }); + exe.linkLibC(); + b.installArtifact(exe); } fn have(c: bool) ?c_int { @@ -802,13 +578,13 @@ fn have(c: bool) ?c_int { //HAVE = """HAVE IN HERE""" //configh = open('config/config.h').read() //for have in HAVE.splitlines(): - //constant = have.strip()[1:].split('=')[0].strip() - //def1 = f'#define {constant} 1\n' in configh - //def0 = f'#define {constant} 0\n' in configh - //undef = f'/* #undef {constant} */\n' in configh - //if def1: - // print(f" .{constant} = 1,") - //elif def0: - // print(f" .{constant} = 0,") - //elif undef: - // print(f" .{constant} = null,") +//constant = have.strip()[1:].split('=')[0].strip() +//def1 = f'#define {constant} 1\n' in configh +//def0 = f'#define {constant} 0\n' in configh +//undef = f'/* #undef {constant} */\n' in configh +//if def1: +// print(f" .{constant} = 1,") +//elif def0: +// print(f" .{constant} = 0,") +//elif undef: +// print(f" .{constant} = null,") From b82a3ebf1177c7111e7c61357ce53bb2281722b7 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 14:29:52 +0100 Subject: [PATCH 09/32] switch on os in outer call to satisfy comptime --- build.zig | 64 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/build.zig b/build.zig index d7f6a0bf..62b16d24 100644 --- a/build.zig +++ b/build.zig @@ -27,11 +27,12 @@ pub fn build(b: *std.Build) void { .NASM_VERSION_ID = 0x02100100, .NASM_VER = "2.16.01", })); - exe.addConfigHeader(b.addConfigHeader(.{ - .style = .{ .autoconf = b.path("config/config.h.in") }, - .include_path = "config/config.h", - }, switch (target.os.tag) { - .linux => .{ + + switch (target.result.os.tag) { + .linux => exe.addConfigHeader(b.addConfigHeader(.{ + .style = .{ .autoconf = b.path("config/config.h.in") }, + .include_path = "config/config.h", + }, .{ .ABORT_ON_PANIC = have(optimize == .Debug), .AC_APPLE_UNIVERSAL_BUILD = null, .CFLAGS_FDATA_SECTIONS = null, @@ -248,8 +249,11 @@ pub fn build(b: *std.Build) void { .typeof = .__typeof, .uintptr_t = null, .vsnprintf = null, - }, - .macos => .{ + })), + .macos => exe.addConfigHeader(b.addConfigHeader(.{ + .style = .{ .autoconf = b.path("config/config.h.in") }, + .include_path = "config/config.h", + }, .{ .ABORT_ON_PANIC = have(optimize == .Debug), .AC_APPLE_UNIVERSAL_BUILD = null, .CFLAGS_FDATA_SECTIONS = null, @@ -466,10 +470,35 @@ pub fn build(b: *std.Build) void { .typeof = .__typeof, .uintptr_t = null, .vsnprintf = null, - }, - .windows => unreachable, // TODO + })), + // TODO: Windows support: + // + // Use the following script to get a Windows-compatible version (on Windows ofc): + // + // ```python + // import os + // HAVE = """TODO PUT INNER OF THE CONFIG ANON STRUCT IN HERE""" + // configh = open('config/config.h').read() + // for have in HAVE.splitlines(): + // constant = have.strip()[1:].split('=')[0].strip() + // def1 = f'#define {constant} 1\n' in configh + // def0 = f'#define {constant} 0\n' in configh + // undef = f'/* #undef {constant} */\n' in configh + // if def1: + // print(f" .{constant} = 1,") + // elif def0: + // print(f" .{constant} = 0,") + // elif undef: + // print(f" .{constant} = null,") + // ``` + // + // Result can be pasted into the .{} + .windows => exe.addConfigHeader(b.addConfigHeader(.{ + .style = .{ .autoconf = b.path("config/config.h.in") }, + .include_path = "config/config.h", + }, .{})), // TODO else => @panic("os not supported"), - })); + } const files = [_][]const u8{ "nasmlib/alloc.c", "nasmlib/asprintf.c", @@ -573,18 +602,3 @@ pub fn build(b: *std.Build) void { fn have(c: bool) ?c_int { return if (c) 1 else null; } - -//import os -//HAVE = """HAVE IN HERE""" -//configh = open('config/config.h').read() -//for have in HAVE.splitlines(): -//constant = have.strip()[1:].split('=')[0].strip() -//def1 = f'#define {constant} 1\n' in configh -//def0 = f'#define {constant} 0\n' in configh -//undef = f'/* #undef {constant} */\n' in configh -//if def1: -// print(f" .{constant} = 1,") -//elif def0: -// print(f" .{constant} = 0,") -//elif undef: -// print(f" .{constant} = null,") From c1ffe88d2d6cf2ad2f400774ebb668d3b0da3c8a Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 14:33:03 +0100 Subject: [PATCH 10/32] remove Zig mainline from ci (it is unstable) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4162ed38..f5d7d64f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - zig-version: ["master", "0.13.0"] + zig-version: ["0.12.0", 0.12.1", "0.13.0"] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} From e97188e7ebdc6932f93a9575f790f127915aadad Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 14:44:53 +0100 Subject: [PATCH 11/32] ci: fix typo in zig version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f5d7d64f..26ff3acb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - zig-version: ["0.12.0", 0.12.1", "0.13.0"] + zig-version: ["0.12.0", "0.12.1", "0.13.0"] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} From 16b72582bcc73b0d75d993cfe8b87ef481dbce02 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 14:57:31 +0100 Subject: [PATCH 12/32] zig.build now includes windows --- build.zig | 243 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 220 insertions(+), 23 deletions(-) diff --git a/build.zig b/build.zig index 62b16d24..2a056b8f 100644 --- a/build.zig +++ b/build.zig @@ -471,32 +471,229 @@ pub fn build(b: *std.Build) void { .uintptr_t = null, .vsnprintf = null, })), - // TODO: Windows support: - // - // Use the following script to get a Windows-compatible version (on Windows ofc): - // - // ```python - // import os - // HAVE = """TODO PUT INNER OF THE CONFIG ANON STRUCT IN HERE""" - // configh = open('config/config.h').read() - // for have in HAVE.splitlines(): - // constant = have.strip()[1:].split('=')[0].strip() - // def1 = f'#define {constant} 1\n' in configh - // def0 = f'#define {constant} 0\n' in configh - // undef = f'/* #undef {constant} */\n' in configh - // if def1: - // print(f" .{constant} = 1,") - // elif def0: - // print(f" .{constant} = 0,") - // elif undef: - // print(f" .{constant} = null,") - // ``` - // - // Result can be pasted into the .{} + // these were taken from msvc.h + // NOTE: Only works for Visual Studio 2015 and upwards. .windows => exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, .include_path = "config/config.h", - }, .{})), // TODO + }, .{ + .ABORT_ON_PANIC = have(optimize == .Debug), + .AC_APPLE_UNIVERSAL_BUILD = null, + .CFLAGS_FDATA_SECTIONS = null, + .CFLAGS_FFUNCTION_SECTIONS = null, + .CFLAGS_FGNU89_INLINE = null, + .CFLAGS_FLTO = null, + .CFLAGS_FNO_COMMON = null, + .CFLAGS_FNO_OMIT_FRAME_POINTER = null, + .CFLAGS_FSANITIZE_ADDRESS = null, + .CFLAGS_FSANITIZE_UNDEFINED = null, + .CFLAGS_FTRIVIAL_AUTO_VAR_INIT_ZERO = null, + .CFLAGS_FVISIBILITY_HIDDEN = null, + .CFLAGS_FWRAPV = null, + .CFLAGS_GGDB3 = null, + .CFLAGS_O0 = have(optimize == .Debug), + .CFLAGS_PEDANTIC = null, + .CFLAGS_PG = null, + .CFLAGS_STD_C11 = null, + .CFLAGS_STD_C17 = 1, + .CFLAGS_STD_C99 = null, + .CFLAGS_U_STRICT_ANSI = null, + .CFLAGS_W = null, + .CFLAGS_WALL = null, + .CFLAGS_WC90_C99_COMPAT = null, + .CFLAGS_WC99_COMPAT = null, + .CFLAGS_WC99_EXTENSIONS = null, + .CFLAGS_WERROR = null, + .CFLAGS_WERROR_ATTRIBUTES = null, + .CFLAGS_WERROR_COMMENT = null, + .CFLAGS_WERROR_IMPLICIT = null, + .CFLAGS_WERROR_MISSING_BRACES = null, + .CFLAGS_WERROR_MISSING_DECLARATIONS = null, + .CFLAGS_WERROR_MISSING_PROTOTYPES = null, + .CFLAGS_WERROR_POINTER_ARITH = null, + .CFLAGS_WERROR_RETURN_TYPE = null, + .CFLAGS_WERROR_STRICT_PROTOTYPES = null, + .CFLAGS_WERROR_TRIGRAPHS = null, + .CFLAGS_WERROR_UNKNOWN_WARNING_OPTION = null, + .CFLAGS_WERROR_VLA = null, + .CFLAGS_WLONG_LONG = null, + .CFLAGS_WPEDANTIC_MS_FORMAT = null, + .CFLAGS_WSHIFT_NEGATIVE_VALUE = null, + .CFLAGS_WSTRINGOP_TRUNCATION = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_COLD = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_CONST = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_FORMAT = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_MALLOC = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_NORETURN = null, + .CFLAGS_WSUGGEST_ATTRIBUTE_PURE = null, + .HAVE_ACCESS = 1, + .HAVE_CANONICALIZE_FILE_NAME = null, + .HAVE_CPU_TO_LE16 = null, + .HAVE_CPU_TO_LE32 = null, + .HAVE_CPU_TO_LE64 = null, + .HAVE_DECL_STRCASECMP = null, + .HAVE_DECL_STRICMP = 1, + .HAVE_DECL_STRLCPY = null, + .HAVE_DECL_STRNCASECMP = null, + .HAVE_DECL_STRNICMP = 1, + .HAVE_DECL_STRNLEN = null, + .HAVE_DECL_STRRCHRNUL = null, + .HAVE_DECL_STRSEP = null, + .HAVE_ENDIAN_H = null, + .HAVE_FACCESSAT = null, + .HAVE_FCNTL_H = 1, + .HAVE_FILENO = 1, + .HAVE_FSEEKO = null, + .HAVE_FSTAT = null, + .HAVE_FTRUNCATE = null, + .HAVE_FUNC_ATTRIBUTE1_ALLOC_SIZE = null, + .HAVE_FUNC_ATTRIBUTE2_ALLOC_SIZE = null, + .HAVE_FUNC_ATTRIBUTE3_FORMAT = null, + .HAVE_FUNC_ATTRIBUTE_COLD = null, + .HAVE_FUNC_ATTRIBUTE_CONST = null, + .HAVE_FUNC_ATTRIBUTE_ERROR = null, + .HAVE_FUNC_ATTRIBUTE_MALLOC = null, + .HAVE_FUNC_ATTRIBUTE_NORETURN = null, + .HAVE_FUNC_ATTRIBUTE_PURE = null, + .HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL = null, + .HAVE_FUNC_ATTRIBUTE_SENTINEL = null, + .HAVE_FUNC_ATTRIBUTE_UNUSED = null, + .HAVE_FUNC_PTR_ATTRIBUTE1_ALLOC_SIZE = null, + .HAVE_FUNC_PTR_ATTRIBUTE2_ALLOC_SIZE = null, + .HAVE_FUNC_PTR_ATTRIBUTE3_FORMAT = null, + .HAVE_FUNC_PTR_ATTRIBUTE_COLD = null, + .HAVE_FUNC_PTR_ATTRIBUTE_CONST = null, + .HAVE_FUNC_PTR_ATTRIBUTE_MALLOC = null, + .HAVE_FUNC_PTR_ATTRIBUTE_NORETURN = null, + .HAVE_FUNC_PTR_ATTRIBUTE_PURE = null, + .HAVE_FUNC_PTR_ATTRIBUTE_RETURNS_NONNULL = null, + .HAVE_FUNC_PTR_ATTRIBUTE_SENTINEL = null, + .HAVE_FUNC_PTR_ATTRIBUTE_UNUSED = null, + .HAVE_GETGID = null, + .HAVE_GETPAGESIZE = null, + .HAVE_GETRLIMIT = null, + .HAVE_GETUID = null, + .HAVE_HTOLE16 = null, + .HAVE_HTOLE32 = null, + .HAVE_HTOLE64 = null, + .HAVE_INTRIN_H = null, + .HAVE_INTTYPES_H = null, + .HAVE_IO_H = 1, + .HAVE_ISASCII = null, + .HAVE_ISCNTRL = null, + .HAVE_MACHINE_ENDIAN_H = null, + .HAVE_MEMPCPY = null, + .HAVE_MEMPSET = null, + .HAVE_MINIX_CONFIG_H = null, + .HAVE_MMAP = null, + .HAVE_PATHCONF = null, + .HAVE_REALPATH = null, + .HAVE_SNPRINTF = 1, + .HAVE_STAT = null, + .HAVE_STDARG_H = null, + .HAVE_STDBOOL_H = null, + .HAVE_STDC_INLINE = null, + .HAVE_STDINT_H = null, + .HAVE_STDIO_H = null, + .HAVE_STDLIB_H = 1, + .HAVE_STDNORETURN_H = null, + .HAVE_STRCASECMP = null, + .HAVE_STRICMP = 1, + .HAVE_STRINGS_H = null, + .HAVE_STRING_H = 1, + .HAVE_STRLCPY = null, + .HAVE_STRNCASECMP = null, + .HAVE_STRNICMP = 1, + .HAVE_STRNLEN = null, + .HAVE_STRRCHRNUL = null, + .HAVE_STRSEP = null, + .HAVE_STRUCT_STAT = null, + .HAVE_STRUCT__STATI64 = null, + .HAVE_SYSCONF = null, + .HAVE_SYS_ENDIAN_H = null, + .HAVE_SYS_MMAN_H = null, + .HAVE_SYS_PARAM_H = null, + .HAVE_SYS_RESOURCE_H = null, + .HAVE_SYS_STAT_H = 1, + .HAVE_SYS_TYPES_H = 1, + .HAVE_S_ISREG = null, + .HAVE_TYPEOF = null, + .HAVE_UINTPTR_T = null, + .HAVE_UNISTD_H = null, + .HAVE_VSNPRINTF = 1, + .HAVE_WCHAR_H = null, + .HAVE__ACCESS = null, + .HAVE__BITSCANREVERSE = null, + .HAVE__BITSCANREVERSE64 = null, + .HAVE__BOOL = null, + .HAVE__BYTESWAP_UINT64 = null, + .HAVE__BYTESWAP_ULONG = null, + .HAVE__BYTESWAP_USHORT = null, + .HAVE__CHSIZE = 1, + .HAVE__CHSIZE_S = null, + .HAVE__FILENO = null, + .HAVE__FSEEKI64 = 1, + .HAVE__FSTATI64 = 1, + .HAVE__FULLPATH = 1, + .HAVE__STATI64 = 1, + .HAVE__FILELENGTHI64 = 1, + .HAVE___BSWAP_16 = null, + .HAVE___BSWAP_32 = null, + .HAVE___BSWAP_64 = null, + .HAVE___BUILTIN_BSWAP16 = null, + .HAVE___BUILTIN_BSWAP32 = null, + .HAVE___BUILTIN_BSWAP64 = null, + .HAVE___BUILTIN_CHOOSE_EXPR = null, + .HAVE___BUILTIN_CLZ = null, + .HAVE___BUILTIN_CLZL = null, + .HAVE___BUILTIN_CLZLL = null, + .HAVE___BUILTIN_CONSTANT_P = null, + .HAVE___BUILTIN_EXPECT = null, + .HAVE___CPU_TO_LE16 = null, + .HAVE___CPU_TO_LE32 = null, + .HAVE___CPU_TO_LE64 = null, + .LDFLAGS_WL_GC_SECTIONS = null, + .PACKAGE_BUGREPORT = "", + .PACKAGE_NAME = "", + .PACKAGE_STRING = "", + .PACKAGE_TARNAME = "", + .PACKAGE_URL = "", + .PACKAGE_VERSION = "", + .STDC_HEADERS = 1, + ._ALL_SOURCE = 1, + ._DARWIN_C_SOURCE = 1, + .__EXTENSIONS__ = 1, + ._GNU_SOURCE = 1, + ._HPUX_ALT_XOPEN_SOCKET_API = 1, + ._MINIX = null, + ._NETBSD_SOURCE = 1, + ._OPENBSD_SOURCE = 1, + ._POSIX_SOURCE = null, + ._POSIX_1_SOURCE = null, + ._POSIX_PTHREAD_SEMANTICS = 1, + .__STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1, + .__STDC_WANT_IEC_60559_BFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_DFP_EXT__ = 1, + .__STDC_WANT_IEC_60559_FUNCS_EXT__ = 1, + .__STDC_WANT_IEC_60559_TYPES_EXT__ = 1, + .__STDC_WANT_LIB_EXT2__ = 1, + .__STDC_WANT_MATH_SPEC_FUNCS__ = 1, + ._TANDEM_SOURCE = 1, + ._XOPEN_SOURCE = null, + .WORDS_BIGENDIAN = have(t.cpu.arch.endian() == .big), + .WORDS_LITTLEENDIAN = have(t.cpu.arch.endian() != .big), + ._FILE_OFFSET_BITS = null, + ._LARGEFILE_SOURCE = null, + ._LARGE_FILES = null, + .@"const" = .@"const", + .@"inline" = .@"inline", + .restrict = .__restrict, + .size_t = null, + .snprintf = null, + .typeof = .__typeof, + .uintptr_t = null, + .vsnprintf = null, + })), else => @panic("os not supported"), } const files = [_][]const u8{ From 0debb013c2b3a91b0f0b993f0a59469429cddd3f Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 15:14:20 +0100 Subject: [PATCH 13/32] disable autocrlf on windows since it breaks build --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index d94c5fb3..a4860439 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +* -text /version -merge From 2b7ef7b0e3bcd516626121225133a1a609d61966 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 15:51:01 +0100 Subject: [PATCH 14/32] windows fixes --- build.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 2a056b8f..8f27b772 100644 --- a/build.zig +++ b/build.zig @@ -28,6 +28,7 @@ pub fn build(b: *std.Build) void { .NASM_VER = "2.16.01", })); + // TODO:: ABI must be MSVC on Windows switch (target.result.os.tag) { .linux => exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, @@ -706,7 +707,6 @@ pub fn build(b: *std.Build) void { "nasmlib/file.c", "nasmlib/filename.c", "nasmlib/hashtbl.c", - "nasmlib/ilog2.c", "nasmlib/md5c.c", "nasmlib/mmap.c", "nasmlib/nctype.c", @@ -782,7 +782,7 @@ pub fn build(b: *std.Build) void { "output/outlib.c", "output/outmacho.c", "output/outobj.c", - }; + } ++ if (target.result.os.tag != .windows) .{"nasmlib/ilog2.c"} else .{}; const flags = [_][]const u8{ "-DHAVE_CONFIG_H", "-std=c17", From 792783041f1a5b0ff5c0a3bb9c825a70c9f9204e Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 15:53:16 +0100 Subject: [PATCH 15/32] fix windows ilog2.c exception --- build.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 8f27b772..6b418860 100644 --- a/build.zig +++ b/build.zig @@ -782,16 +782,27 @@ pub fn build(b: *std.Build) void { "output/outlib.c", "output/outmacho.c", "output/outobj.c", - } ++ if (target.result.os.tag != .windows) .{"nasmlib/ilog2.c"} else .{}; + }; + const flags = [_][]const u8{ "-DHAVE_CONFIG_H", "-std=c17", "-Wno-implicit-function-declaration", }; + exe.addCSourceFiles(.{ .files = &files, .flags = &flags, }); + if (target.result.os.tag != .windows) { + // ilog2.c is not included on Windows since it causes + // duplicate symbol errors + exe.addCSourceFiles(.{ + .files = &.{"nasmlib/ilog2.c"}, + .flags = &flags, + }); + } + exe.linkLibC(); b.installArtifact(exe); } From 97d501846a00a411e85f6bf83c1ac6f104419d9e Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 15:55:06 +0100 Subject: [PATCH 16/32] set HAVE_STRNLEN=1 on windows --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 6b418860..001b69fb 100644 --- a/build.zig +++ b/build.zig @@ -605,7 +605,7 @@ pub fn build(b: *std.Build) void { .HAVE_STRLCPY = null, .HAVE_STRNCASECMP = null, .HAVE_STRNICMP = 1, - .HAVE_STRNLEN = null, + .HAVE_STRNLEN = 1, .HAVE_STRRCHRNUL = null, .HAVE_STRSEP = null, .HAVE_STRUCT_STAT = null, From a7bcc1d3a4f67558e190a57db61ac58fd451b986 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 15:56:17 +0100 Subject: [PATCH 17/32] build.zig: windows fix some symbols msvc does not have --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 001b69fb..9bb00240 100644 --- a/build.zig +++ b/build.zig @@ -599,12 +599,12 @@ pub fn build(b: *std.Build) void { .HAVE_STDLIB_H = 1, .HAVE_STDNORETURN_H = null, .HAVE_STRCASECMP = null, - .HAVE_STRICMP = 1, + .HAVE_STRICMP = 0, .HAVE_STRINGS_H = null, .HAVE_STRING_H = 1, .HAVE_STRLCPY = null, .HAVE_STRNCASECMP = null, - .HAVE_STRNICMP = 1, + .HAVE_STRNICMP = 0, .HAVE_STRNLEN = 1, .HAVE_STRRCHRNUL = null, .HAVE_STRSEP = null, @@ -632,7 +632,7 @@ pub fn build(b: *std.Build) void { .HAVE__BYTESWAP_USHORT = null, .HAVE__CHSIZE = 1, .HAVE__CHSIZE_S = null, - .HAVE__FILENO = null, + .HAVE__FILENO = 0, .HAVE__FSEEKI64 = 1, .HAVE__FSTATI64 = 1, .HAVE__FULLPATH = 1, From c7708a6d5316029d9ffc1f819f0844f965a4fe2a Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:00:12 +0100 Subject: [PATCH 18/32] build.zig: windows fixes --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 9bb00240..aa41b4a2 100644 --- a/build.zig +++ b/build.zig @@ -533,17 +533,17 @@ pub fn build(b: *std.Build) void { .HAVE_CPU_TO_LE32 = null, .HAVE_CPU_TO_LE64 = null, .HAVE_DECL_STRCASECMP = null, - .HAVE_DECL_STRICMP = 1, + .HAVE_DECL_STRICMP = 0, .HAVE_DECL_STRLCPY = null, .HAVE_DECL_STRNCASECMP = null, - .HAVE_DECL_STRNICMP = 1, + .HAVE_DECL_STRNICMP = 0, .HAVE_DECL_STRNLEN = null, .HAVE_DECL_STRRCHRNUL = null, .HAVE_DECL_STRSEP = null, .HAVE_ENDIAN_H = null, .HAVE_FACCESSAT = null, .HAVE_FCNTL_H = 1, - .HAVE_FILENO = 1, + .HAVE_FILENO = 0, .HAVE_FSEEKO = null, .HAVE_FSTAT = null, .HAVE_FTRUNCATE = null, From 4b92aaaa09c2ae5dbf69b923597142917374848f Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:14:56 +0100 Subject: [PATCH 19/32] Revert "build.zig: windows fix some symbols msvc does not have" This reverts commit a7bcc1d3a4f67558e190a57db61ac58fd451b986. --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index aa41b4a2..706c5a2d 100644 --- a/build.zig +++ b/build.zig @@ -599,12 +599,12 @@ pub fn build(b: *std.Build) void { .HAVE_STDLIB_H = 1, .HAVE_STDNORETURN_H = null, .HAVE_STRCASECMP = null, - .HAVE_STRICMP = 0, + .HAVE_STRICMP = 1, .HAVE_STRINGS_H = null, .HAVE_STRING_H = 1, .HAVE_STRLCPY = null, .HAVE_STRNCASECMP = null, - .HAVE_STRNICMP = 0, + .HAVE_STRNICMP = 1, .HAVE_STRNLEN = 1, .HAVE_STRRCHRNUL = null, .HAVE_STRSEP = null, @@ -632,7 +632,7 @@ pub fn build(b: *std.Build) void { .HAVE__BYTESWAP_USHORT = null, .HAVE__CHSIZE = 1, .HAVE__CHSIZE_S = null, - .HAVE__FILENO = 0, + .HAVE__FILENO = null, .HAVE__FSEEKI64 = 1, .HAVE__FSTATI64 = 1, .HAVE__FULLPATH = 1, From d226c53d6c19db10e39df45ebc3704b52f452564 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:15:19 +0100 Subject: [PATCH 20/32] Revert "build.zig: windows fixes" This reverts commit c7708a6d5316029d9ffc1f819f0844f965a4fe2a. --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 706c5a2d..001b69fb 100644 --- a/build.zig +++ b/build.zig @@ -533,17 +533,17 @@ pub fn build(b: *std.Build) void { .HAVE_CPU_TO_LE32 = null, .HAVE_CPU_TO_LE64 = null, .HAVE_DECL_STRCASECMP = null, - .HAVE_DECL_STRICMP = 0, + .HAVE_DECL_STRICMP = 1, .HAVE_DECL_STRLCPY = null, .HAVE_DECL_STRNCASECMP = null, - .HAVE_DECL_STRNICMP = 0, + .HAVE_DECL_STRNICMP = 1, .HAVE_DECL_STRNLEN = null, .HAVE_DECL_STRRCHRNUL = null, .HAVE_DECL_STRSEP = null, .HAVE_ENDIAN_H = null, .HAVE_FACCESSAT = null, .HAVE_FCNTL_H = 1, - .HAVE_FILENO = 0, + .HAVE_FILENO = 1, .HAVE_FSEEKO = null, .HAVE_FSTAT = null, .HAVE_FTRUNCATE = null, From 02ae5dfc4d43c6a955a81fe2183eb425aec87379 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:48:24 +0100 Subject: [PATCH 21/32] force ABI msvc on windows --- .github/workflows/ci.yaml | 5 ++++- build.zig | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26ff3acb..6ec22689 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,9 @@ jobs: matrix: zig-version: ["0.12.0", "0.12.1", "0.13.0"] os: [ubuntu-latest, macos-latest, windows-latest] + includes: + - os: windows-latest + options: "-Dabi=msvc" runs-on: ${{ matrix.os }} steps: @@ -30,4 +33,4 @@ jobs: version: ${{ matrix.zig-version }} - name: Build - run: zig build --release=fast --summary all + run: zig build ${{ matrix.options }} --release=fast --summary all diff --git a/build.zig b/build.zig index 001b69fb..4ca81bc2 100644 --- a/build.zig +++ b/build.zig @@ -6,6 +6,9 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const t = target.result; + if (t.os.tag == .windows and t.abi != .msvc) + @panic("on windows only abi msvc is supported"); + const exe = b.addExecutable(.{ .name = "nasm", .target = target, @@ -28,8 +31,7 @@ pub fn build(b: *std.Build) void { .NASM_VER = "2.16.01", })); - // TODO:: ABI must be MSVC on Windows - switch (target.result.os.tag) { + switch (t.os.tag) { .linux => exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, .include_path = "config/config.h", @@ -794,7 +796,7 @@ pub fn build(b: *std.Build) void { .files = &files, .flags = &flags, }); - if (target.result.os.tag != .windows) { + if (t.os.tag != .windows) { // ilog2.c is not included on Windows since it causes // duplicate symbol errors exe.addCSourceFiles(.{ @@ -804,6 +806,7 @@ pub fn build(b: *std.Build) void { } exe.linkLibC(); + b.installArtifact(exe); } From 191358c9f67c986873d50cd30e44fa0430296f91 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:52:05 +0100 Subject: [PATCH 22/32] ci.yaml: fix zig msvc abi for windows target --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6ec22689..49368c6a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] includes: - os: windows-latest - options: "-Dabi=msvc" + options: "-Dtarget=native-native-msvc" runs-on: ${{ matrix.os }} steps: From 055507059c00e355f7687008e208daf732deaa8d Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 16:54:53 +0100 Subject: [PATCH 23/32] ci.yaml: fix type includes -> include --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49368c6a..667fc9de 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: matrix: zig-version: ["0.12.0", "0.12.1", "0.13.0"] os: [ubuntu-latest, macos-latest, windows-latest] - includes: + include: - os: windows-latest options: "-Dtarget=native-native-msvc" From 67b555d2e445cdbe06abb424072ab9b448476e8a Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 18:41:50 +0100 Subject: [PATCH 24/32] build.zig: try dynamic linking on mscv --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index 4ca81bc2..74b769c8 100644 --- a/build.zig +++ b/build.zig @@ -13,6 +13,7 @@ pub fn build(b: *std.Build) void { .name = "nasm", .target = target, .optimize = optimize, + .linkage = if (t.os.tag == .windows) .dynamic else .static, }); exe.addIncludePath(b.path("include")); From f2356d2dfd617b3407e373eb68b62f5137cad105 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Wed, 8 Jan 2025 19:54:37 +0100 Subject: [PATCH 25/32] remove dynamic linkage since it is already the case --- build.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/build.zig b/build.zig index 74b769c8..4ca81bc2 100644 --- a/build.zig +++ b/build.zig @@ -13,7 +13,6 @@ pub fn build(b: *std.Build) void { .name = "nasm", .target = target, .optimize = optimize, - .linkage = if (t.os.tag == .windows) .dynamic else .static, }); exe.addIncludePath(b.path("include")); From d8fea798df035e6e48b3ee504ab2aa7dafe5e750 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Thu, 9 Jan 2025 13:10:20 +0100 Subject: [PATCH 26/32] use _fileno over fileno on Windows (fileno is deprecated) --- build.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 4ca81bc2..14a0e8cb 100644 --- a/build.zig +++ b/build.zig @@ -545,7 +545,7 @@ pub fn build(b: *std.Build) void { .HAVE_ENDIAN_H = null, .HAVE_FACCESSAT = null, .HAVE_FCNTL_H = 1, - .HAVE_FILENO = 1, + .HAVE_FILENO = 0, .HAVE_FSEEKO = null, .HAVE_FSTAT = null, .HAVE_FTRUNCATE = null, @@ -634,7 +634,7 @@ pub fn build(b: *std.Build) void { .HAVE__BYTESWAP_USHORT = null, .HAVE__CHSIZE = 1, .HAVE__CHSIZE_S = null, - .HAVE__FILENO = null, + .HAVE__FILENO = 1, .HAVE__FSEEKI64 = 1, .HAVE__FSTATI64 = 1, .HAVE__FULLPATH = 1, From 7483d3c663328d70f93d1d782568f8b28239720d Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Thu, 9 Jan 2025 14:17:29 +0100 Subject: [PATCH 27/32] update readme --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f17f214f..6c31682a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,25 @@ -This is a fork of [NASM](https://nasm.us/), packaged for Zig. Unnecessary files +# NASM + +This is NASM, packaged for [Zig](https://ziglang.org/). Unnecessary files have been deleted, and the build system has been replaced with `build.zig`. -Original README follows: +## Support + +| OS | Status | +|---------|--------| +| Linux | ✅ | +| macOS | ✅ | +| Windows | ❌ | + +| Zig version | Status | +|-------------|--------| +| zig 12.0.0 | ✅ | +| zig 12.0.1 | ✅ | +| zig 13.0.0 | ✅ | + +This is a fork of [NASM](https://nasm.us/), packaged for Zig. + +## Original README ---------------------------------------------------------------------------- From 632a8dd5a378cdbaa2af15f9ee3ef80366bc59ac Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Thu, 9 Jan 2025 14:18:11 +0100 Subject: [PATCH 28/32] readme: fix Zig versions typo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6c31682a..67656064 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ have been deleted, and the build system has been replaced with `build.zig`. | Zig version | Status | |-------------|--------| -| zig 12.0.0 | ✅ | -| zig 12.0.1 | ✅ | -| zig 13.0.0 | ✅ | +| zig 0.12.0 | ✅ | +| zig 0.12.1 | ✅ | +| zig 0.13.0 | ✅ | This is a fork of [NASM](https://nasm.us/), packaged for Zig. From f66922986aec144f2f4728b961171f2a6b1aadd3 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Mon, 7 Apr 2025 11:40:49 +0200 Subject: [PATCH 29/32] windows changes from @Banacial --- build.zig | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/build.zig b/build.zig index 14a0e8cb..0a9961a6 100644 --- a/build.zig +++ b/build.zig @@ -6,9 +6,6 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const t = target.result; - if (t.os.tag == .windows and t.abi != .msvc) - @panic("on windows only abi msvc is supported"); - const exe = b.addExecutable(.{ .name = "nasm", .target = target, @@ -474,8 +471,6 @@ pub fn build(b: *std.Build) void { .uintptr_t = null, .vsnprintf = null, })), - // these were taken from msvc.h - // NOTE: Only works for Visual Studio 2015 and upwards. .windows => exe.addConfigHeader(b.addConfigHeader(.{ .style = .{ .autoconf = b.path("config/config.h.in") }, .include_path = "config/config.h", @@ -545,7 +540,7 @@ pub fn build(b: *std.Build) void { .HAVE_ENDIAN_H = null, .HAVE_FACCESSAT = null, .HAVE_FCNTL_H = 1, - .HAVE_FILENO = 0, + .HAVE_FILENO = null, .HAVE_FSEEKO = null, .HAVE_FSTAT = null, .HAVE_FTRUNCATE = null, @@ -585,7 +580,7 @@ pub fn build(b: *std.Build) void { .HAVE_ISASCII = null, .HAVE_ISCNTRL = null, .HAVE_MACHINE_ENDIAN_H = null, - .HAVE_MEMPCPY = null, + .HAVE_MEMPCPY = 1, .HAVE_MEMPSET = null, .HAVE_MINIX_CONFIG_H = null, .HAVE_MMAP = null, @@ -596,7 +591,7 @@ pub fn build(b: *std.Build) void { .HAVE_STDARG_H = null, .HAVE_STDBOOL_H = null, .HAVE_STDC_INLINE = null, - .HAVE_STDINT_H = null, + .HAVE_STDINT_H = 1, .HAVE_STDIO_H = null, .HAVE_STDLIB_H = 1, .HAVE_STDNORETURN_H = null, @@ -708,6 +703,7 @@ pub fn build(b: *std.Build) void { "nasmlib/crc64.c", "nasmlib/file.c", "nasmlib/filename.c", + "nasmlib/ilog2.c", "nasmlib/hashtbl.c", "nasmlib/md5c.c", "nasmlib/mmap.c", @@ -796,14 +792,6 @@ pub fn build(b: *std.Build) void { .files = &files, .flags = &flags, }); - if (t.os.tag != .windows) { - // ilog2.c is not included on Windows since it causes - // duplicate symbol errors - exe.addCSourceFiles(.{ - .files = &.{"nasmlib/ilog2.c"}, - .flags = &flags, - }); - } exe.linkLibC(); From 15369d51590438c7dcd074fa6eca0085323c9e7b Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 8 Apr 2025 13:42:35 +0200 Subject: [PATCH 30/32] use default mingw libc instead of msvc target abi --- .github/workflows/ci.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 667fc9de..26ff3acb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,9 +18,6 @@ jobs: matrix: zig-version: ["0.12.0", "0.12.1", "0.13.0"] os: [ubuntu-latest, macos-latest, windows-latest] - include: - - os: windows-latest - options: "-Dtarget=native-native-msvc" runs-on: ${{ matrix.os }} steps: @@ -33,4 +30,4 @@ jobs: version: ${{ matrix.zig-version }} - name: Build - run: zig build ${{ matrix.options }} --release=fast --summary all + run: zig build --release=fast --summary all From de2d19a03e5ef15bed6324a80ef3bb624fdc8bac Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 8 Apr 2025 13:47:30 +0200 Subject: [PATCH 31/32] fix incorrect branch for MSVC int defines which should not hit for mingw --- include/nasmint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nasmint.h b/include/nasmint.h index 6be623bf..a682b982 100644 --- a/include/nasmint.h +++ b/include/nasmint.h @@ -33,7 +33,7 @@ # endif #endif -#if _I64_MAX == 9223372036854775807 +#if defined(_MSC_VER) && _I64_MAX == 9223372036854775807 /* Windows-based compiler: use __int64 */ typedef signed __int64 int64_t; From 256464749ba1d14b82122f23d5d9779fecadbf61 Mon Sep 17 00:00:00 2001 From: Gerwin van der Lugt Date: Tue, 8 Apr 2025 13:53:08 +0200 Subject: [PATCH 32/32] readme, ci: update windows support and bump to zig 0.14.0 --- .github/workflows/ci.yaml | 2 +- README.md | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26ff3acb..4e6bd6a8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - zig-version: ["0.12.0", "0.12.1", "0.13.0"] + zig-version: ["0.14.0"] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index 67656064..9a72ecd9 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,13 @@ have been deleted, and the build system has been replaced with `build.zig`. |---------|--------| | Linux | ✅ | | macOS | ✅ | -| Windows | ❌ | +| Windows | ✅ | | Zig version | Status | |-------------|--------| -| zig 0.12.0 | ✅ | -| zig 0.12.1 | ✅ | -| zig 0.13.0 | ✅ | +| zig 0.14.0 | ✅ | -This is a fork of [NASM](https://nasm.us/), packaged for Zig. +This is a fork of [NASM](https://nasm.us/), packaged for Zig. ## Original README