authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-15 11:19:47+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-15 11:19:47+02:00
log3016f875c31bc421b1276584adfff25fe3c0d207
treec235a4202b082847fe2f81c47f74a92d0c0567b2
parent291addadf8d058de3af2d83285d94fea51053447
parent18964c086589a1aa3dfbd7ae8ace294bb1379c73

Merge pull request 'compiler: disable warnings in all vendored code' (#31868) from alexrp/zig:disable-vendor-warnings into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31868

4 files changed, 17 insertions(+), 22 deletions(-)

src/libs/glibc.zig+13-7
...@@ -189,11 +189,11 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -189,11 +189,11 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
189 var args = std.array_list.Managed([]const u8).init(arena);189 var args = std.array_list.Managed([]const u8).init(arena);
190 try add_include_dirs(comp, arena, &args);190 try add_include_dirs(comp, arena, &args);
191 try args.appendSlice(&[_][]const u8{191 try args.appendSlice(&[_][]const u8{
192 "-w", // Disable all warnings.
192 "-D_LIBC_REENTRANT",193 "-D_LIBC_REENTRANT",
193 "-include",194 "-include",
194 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),195 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
195 "-DMODULE_NAME=libc",196 "-DMODULE_NAME=libc",
196 "-Wno-nonportable-include-path",
197 "-include",197 "-include",
198 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),198 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
199 "-DPIC",199 "-DPIC",
...@@ -217,6 +217,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -217,6 +217,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
217 });217 });
218 try add_include_dirs(comp, arena, &args);218 try add_include_dirs(comp, arena, &args);
219 try args.appendSlice(&[_][]const u8{219 try args.appendSlice(&[_][]const u8{
220 "-w", // Disable all warnings.
220 "-D_LIBC_REENTRANT",221 "-D_LIBC_REENTRANT",
221 "-DMODULE_NAME=libc",222 "-DMODULE_NAME=libc",
222 "-DTOP_NAMESPACE=glibc",223 "-DTOP_NAMESPACE=glibc",
...@@ -229,9 +230,16 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -229,9 +230,16 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
229 .owner = undefined,230 .owner = undefined,
230 };231 };
231 };232 };
232 const init_o: Compilation.CSourceFile = .{233 const init_o: Compilation.CSourceFile = blk: {
233 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),234 var args = std.array_list.Managed([]const u8).init(arena);
234 .owner = undefined,235 try args.appendSlice(&[_][]const u8{
236 "-w", // Disable all warnings.
237 });
238 break :blk .{
239 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),
240 .cache_exempt_flags = args.items,
241 .owner = undefined,
242 };
235 };243 };
236 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };244 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
237 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";245 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";
...@@ -308,15 +316,14 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -308,15 +316,14 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
308316
309 var args = std.array_list.Managed([]const u8).init(arena);317 var args = std.array_list.Managed([]const u8).init(arena);
310 try args.appendSlice(&[_][]const u8{318 try args.appendSlice(&[_][]const u8{
319 "-w", // Disable all warnings.
311 "-std=gnu11",320 "-std=gnu11",
312 "-fgnu89-inline",321 "-fgnu89-inline",
313 "-fmerge-all-constants",322 "-fmerge-all-constants",
314 "-frounding-math",323 "-frounding-math",
315 "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math.
316 "-fno-common",324 "-fno-common",
317 "-fmath-errno",325 "-fmath-errno",
318 "-ftls-model=initial-exec",326 "-ftls-model=initial-exec",
319 "-Wno-ignored-attributes",
320 "-Qunused-arguments",327 "-Qunused-arguments",
321 });328 });
322 try add_include_dirs(comp, arena, &args);329 try add_include_dirs(comp, arena, &args);
...@@ -335,7 +342,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -335,7 +342,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
335 "-include",342 "-include",
336 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),343 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
337 "-DMODULE_NAME=libc",344 "-DMODULE_NAME=libc",
338 "-Wno-nonportable-include-path",
339 "-include",345 "-include",
340 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),346 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
341 "-DPIC",347 "-DPIC",
src/libs/libcxx.zig+2-6
...@@ -206,6 +206,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -206,6 +206,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
206206
207 try addCxxArgs(comp, arena, &cflags);207 try addCxxArgs(comp, arena, &cflags);
208208
209 try cflags.append("-w"); // Disable all warnings.
209 try cflags.append("-DNDEBUG");210 try cflags.append("-DNDEBUG");
210 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");211 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
211 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");212 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
...@@ -223,9 +224,6 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -223,9 +224,6 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
223224
224 try cflags.append("-nostdinc++");225 try cflags.append("-nostdinc++");
225 try cflags.append("-std=c++23");226 try cflags.append("-std=c++23");
226 try cflags.append("-Wno-user-defined-literals");
227 try cflags.append("-Wno-covered-switch-default");
228 try cflags.append("-Wno-suggest-override");
229227
230 // These depend on only the zig lib directory file path, which is228 // These depend on only the zig lib directory file path, which is
231 // purposefully either in the cache or not in the cache. The decision229 // purposefully either in the cache or not in the cache. The decision
...@@ -401,6 +399,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -401,6 +399,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
401399
402 try addCxxArgs(comp, arena, &cflags);400 try addCxxArgs(comp, arena, &cflags);
403401
402 try cflags.append("-w"); // Disable all warnings.
404 try cflags.append("-DNDEBUG");403 try cflags.append("-DNDEBUG");
405 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");404 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
406 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");405 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
...@@ -422,9 +421,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -422,9 +421,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
422 try cflags.append("-nostdinc++");421 try cflags.append("-nostdinc++");
423 try cflags.append("-fstrict-aliasing");422 try cflags.append("-fstrict-aliasing");
424 try cflags.append("-std=c++23");423 try cflags.append("-std=c++23");
425 try cflags.append("-Wno-user-defined-literals");
426 try cflags.append("-Wno-covered-switch-default");
427 try cflags.append("-Wno-suggest-override");
428424
429 // These depend on only the zig lib directory file path, which is425 // These depend on only the zig lib directory file path, which is
430 // purposefully either in the cache or not in the cache. The decision426 // purposefully either in the cache or not in the cache. The decision
src/libs/libunwind.zig+1-7
...@@ -104,6 +104,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -104,6 +104,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
104 .assembly_with_cpp => {},104 .assembly_with_cpp => {},
105 else => unreachable, // See `unwind_src_list`.105 else => unreachable, // See `unwind_src_list`.
106 }106 }
107 try cflags.append("-w"); // Disable all warnings.
107 try cflags.append("-I");108 try cflags.append("-I");
108 try cflags.append(try comp.dirs.zig_lib.join(arena, &.{ "libunwind", "include" }));109 try cflags.append(try comp.dirs.zig_lib.join(arena, &.{ "libunwind", "include" }));
109 try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");110 try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");
...@@ -126,13 +127,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -126,13 +127,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
126 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {127 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
127 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");128 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
128 }129 }
129 try cflags.append("-Wno-bitwise-conditional-parentheses");
130 try cflags.append("-Wno-visibility");
131 try cflags.append("-Wno-incompatible-pointer-types");
132
133 if (target.os.tag == .windows) {
134 try cflags.append("-Wno-dll-attribute-on-redeclaration");
135 }
136130
137 c_source_files[i] = .{131 c_source_files[i] = .{
138 .src_path = try comp.dirs.zig_lib.join(arena, &.{unwind_src}),132 .src_path = try comp.dirs.zig_lib.join(arena, &.{unwind_src}),
src/libs/mingw.zig+1-2
...@@ -135,8 +135,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -135,8 +135,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
135 try addCcArgs(comp, arena, &winpthreads_args);135 try addCcArgs(comp, arena, &winpthreads_args);
136 try winpthreads_args.appendSlice(&[_][]const u8{136 try winpthreads_args.appendSlice(&[_][]const u8{
137 "-DIN_WINPTHREAD",137 "-DIN_WINPTHREAD",
138 // winpthreads incorrectly assumes that Clang has `-Wprio-ctor-dtor`.
139 "-Wno-unknown-warning-option",
140 });138 });
141139
142 switch (comp.compilerRtOptMode()) {140 switch (comp.compilerRtOptMode()) {
...@@ -170,6 +168,7 @@ fn addCcArgs(...@@ -170,6 +168,7 @@ fn addCcArgs(
170 args: *std.array_list.Managed([]const u8),168 args: *std.array_list.Managed([]const u8),
171) error{OutOfMemory}!void {169) error{OutOfMemory}!void {
172 try args.appendSlice(&[_][]const u8{170 try args.appendSlice(&[_][]const u8{
171 "-w", // Disable all warnings.
173 "-std=gnu11",172 "-std=gnu11",
174 "-D__USE_MINGW_ANSI_STDIO=0",173 "-D__USE_MINGW_ANSI_STDIO=0",
175174