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
189189 var args = std.array_list.Managed([]const u8).init(arena);
190190 try add_include_dirs(comp, arena, &args);
191191 try args.appendSlice(&[_][]const u8{
192 "-w", // Disable all warnings.
192193 "-D_LIBC_REENTRANT",
193194 "-include",
194195 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
195196 "-DMODULE_NAME=libc",
196 "-Wno-nonportable-include-path",
197197 "-include",
198198 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
199199 "-DPIC",
......@@ -217,6 +217,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
217217 });
218218 try add_include_dirs(comp, arena, &args);
219219 try args.appendSlice(&[_][]const u8{
220 "-w", // Disable all warnings.
220221 "-D_LIBC_REENTRANT",
221222 "-DMODULE_NAME=libc",
222223 "-DTOP_NAMESPACE=glibc",
......@@ -229,9 +230,16 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
229230 .owner = undefined,
230231 };
231232 };
232 const init_o: Compilation.CSourceFile = .{
233 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),
234 .owner = undefined,
233 const init_o: Compilation.CSourceFile = blk: {
234 var args = std.array_list.Managed([]const u8).init(arena);
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 };
235243 };
236244 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
237245 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
308316
309317 var args = std.array_list.Managed([]const u8).init(arena);
310318 try args.appendSlice(&[_][]const u8{
319 "-w", // Disable all warnings.
311320 "-std=gnu11",
312321 "-fgnu89-inline",
313322 "-fmerge-all-constants",
314323 "-frounding-math",
315 "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math.
316324 "-fno-common",
317325 "-fmath-errno",
318326 "-ftls-model=initial-exec",
319 "-Wno-ignored-attributes",
320327 "-Qunused-arguments",
321328 });
322329 try add_include_dirs(comp, arena, &args);
......@@ -335,7 +342,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
335342 "-include",
336343 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
337344 "-DMODULE_NAME=libc",
338 "-Wno-nonportable-include-path",
339345 "-include",
340346 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
341347 "-DPIC",
src/libs/libcxx.zig+2-6
......@@ -206,6 +206,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
206206
207207 try addCxxArgs(comp, arena, &cflags);
208208
209 try cflags.append("-w"); // Disable all warnings.
209210 try cflags.append("-DNDEBUG");
210211 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
211212 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
......@@ -223,9 +224,6 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
223224
224225 try cflags.append("-nostdinc++");
225226 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
230228 // These depend on only the zig lib directory file path, which is
231229 // 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
401399
402400 try addCxxArgs(comp, arena, &cflags);
403401
402 try cflags.append("-w"); // Disable all warnings.
404403 try cflags.append("-DNDEBUG");
405404 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
406405 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
......@@ -422,9 +421,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
422421 try cflags.append("-nostdinc++");
423422 try cflags.append("-fstrict-aliasing");
424423 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
429425 // These depend on only the zig lib directory file path, which is
430426 // 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
104104 .assembly_with_cpp => {},
105105 else => unreachable, // See `unwind_src_list`.
106106 }
107 try cflags.append("-w"); // Disable all warnings.
107108 try cflags.append("-I");
108109 try cflags.append(try comp.dirs.zig_lib.join(arena, &.{ "libunwind", "include" }));
109110 try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");
......@@ -126,13 +127,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
126127 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
127128 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
128129 }
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
137131 c_source_files[i] = .{
138132 .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
135135 try addCcArgs(comp, arena, &winpthreads_args);
136136 try winpthreads_args.appendSlice(&[_][]const u8{
137137 "-DIN_WINPTHREAD",
138 // winpthreads incorrectly assumes that Clang has `-Wprio-ctor-dtor`.
139 "-Wno-unknown-warning-option",
140138 });
141139
142140 switch (comp.compilerRtOptMode()) {
......@@ -170,6 +168,7 @@ fn addCcArgs(
170168 args: *std.array_list.Managed([]const u8),
171169) error{OutOfMemory}!void {
172170 try args.appendSlice(&[_][]const u8{
171 "-w", // Disable all warnings.
173172 "-std=gnu11",
174173 "-D__USE_MINGW_ANSI_STDIO=0",
175174