| ... | @@ -2811,45 +2811,66 @@ fn addOneModuleTest( | ... | @@ -2811,45 +2811,66 @@ fn addOneModuleTest( |
| 2811 | | 2811 | |
| 2812 | compile_c.addCSourceFile(.{ | 2812 | compile_c.addCSourceFile(.{ |
| 2813 | .file = these_tests.getEmittedBin(), | 2813 | .file = these_tests.getEmittedBin(), |
| 2814 | .flags = &.{ | 2814 | .flags = blk: { |
| 2815 | // Tracking issue for making the C backend generate C89 compatible code: | 2815 | const invariant_cflags: []const []const u8 = &.{ |
| 2816 | // https://github.com/ziglang/zig/issues/19468 | 2816 | // Tracking issue for making the C backend generate C89 compatible code: |
| 2817 | "-std=c99", | 2817 | // https://github.com/ziglang/zig/issues/19468 |
| 2818 | "-Werror", | 2818 | "-std=c99", |
| 2819 | | 2819 | "-Werror", |
| 2820 | "-Wall", | 2820 | |
| 2821 | "-Wembedded-directive", | 2821 | "-Wall", |
| 2822 | "-Wempty-translation-unit", | 2822 | "-Wembedded-directive", |
| 2823 | "-Wextra", | 2823 | "-Wempty-translation-unit", |
| 2824 | "-Wgnu", | 2824 | "-Wextra", |
| 2825 | "-Winvalid-utf8", | 2825 | "-Wgnu", |
| 2826 | "-Wkeyword-macro", | 2826 | "-Winvalid-utf8", |
| 2827 | "-Woverlength-strings", | 2827 | "-Wkeyword-macro", |
| 2828 | | 2828 | "-Woverlength-strings", |
| 2829 | // Tracking issue for making the C backend generate code | 2829 | |
| 2830 | // that does not trigger warnings: | 2830 | // Tracking issue for making the C backend generate code |
| 2831 | // https://github.com/ziglang/zig/issues/19467 | 2831 | // that does not trigger warnings: |
| 2832 | | 2832 | // https://github.com/ziglang/zig/issues/19467 |
| 2833 | // spotted everywhere | 2833 | |
| 2834 | "-Wno-builtin-requires-header", | 2834 | // spotted everywhere |
| 2835 | | 2835 | "-Wno-builtin-requires-header", |
| 2836 | // spotted on linux | 2836 | |
| 2837 | "-Wno-braced-scalar-init", | 2837 | // spotted on linux |
| 2838 | "-Wno-excess-initializers", | 2838 | "-Wno-braced-scalar-init", |
| 2839 | "-Wno-incompatible-pointer-types-discards-qualifiers", | 2839 | "-Wno-excess-initializers", |
| 2840 | "-Wno-unused", | 2840 | "-Wno-incompatible-pointer-types-discards-qualifiers", |
| 2841 | "-Wno-unused-parameter", | 2841 | "-Wno-unused", |
| 2842 | | 2842 | "-Wno-unused-parameter", |
| 2843 | // spotted on darwin | 2843 | |
| 2844 | "-Wno-incompatible-pointer-types", | 2844 | // spotted on darwin |
| 2845 | | 2845 | "-Wno-incompatible-pointer-types", |
| 2846 | // https://github.com/llvm/llvm-project/issues/153314 | 2846 | |
| 2847 | "-Wno-unterminated-string-initialization", | 2847 | // https://github.com/llvm/llvm-project/issues/153314 |
| 2848 | | 2848 | "-Wno-unterminated-string-initialization", |
| 2849 | // In both Zig and C it is legal to return a pointer to a | 2849 | |
| 2850 | // local. The C backend lowers such thing directly, so the | 2850 | // In both Zig and C it is legal to return a pointer to a |
| 2851 | // corresponding warning in C must be disabled. | 2851 | // local. The C backend lowers such thing directly, so the |
| 2852 | "-Wno-return-stack-address", | 2852 | // corresponding warning in C must be disabled. |
| | 2853 | "-Wno-return-stack-address", |
| | 2854 | }; |
| | 2855 | |
| | 2856 | const function_data_sections = switch (target.cpu.arch) { |
| | 2857 | .arm, |
| | 2858 | .armeb, |
| | 2859 | .thumb, |
| | 2860 | .thumbeb, |
| | 2861 | .hexagon, |
| | 2862 | .powerpc, |
| | 2863 | .powerpcle, |
| | 2864 | .powerpc64, |
| | 2865 | .powerpc64le, |
| | 2866 | => true, |
| | 2867 | else => false, |
| | 2868 | }; |
| | 2869 | |
| | 2870 | break :blk if (function_data_sections) invariant_cflags ++ &[_][]const u8{ |
| | 2871 | "-ffunction-sections", |
| | 2872 | "-fdata-sections", |
| | 2873 | } else invariant_cflags; |
| 2853 | }, | 2874 | }, |
| 2854 | }); | 2875 | }); |
| 2855 | compile_c.addIncludePath(b.path("lib")); // for zig.h | 2876 | compile_c.addIncludePath(b.path("lib")); // for zig.h |