authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-21 23:55:56-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-22 11:22:17-04:00
logffef5d26b6bbaf52d80c74ac3879a233a7a1a513
tree76a7301501472e7689ed0adb9da985b32479ad0d
parentc5716715d5e7d7a5eae76df77ed538a48d22f0ba
signature Commit is signed but in an unrecognized format.

significantly increase test coverage

* add zig build option `-Dskip-libc` to skip tests that build libc (e.g. if you don't want to wait for musl to build) * add `-Denable-wine` option which uses wine to run cross compiled windows tests on non-windows hosts * add `-Denable-qemu` option which uses qemu to run cross compiled foreign architecture tests * add `-Denable-foreign-glibc=path` option which combined with `-Denable-qemu` enables running cross compiled tests that link against glibc. See https://github.com/ziglang/zig/wiki/Updating-libc#glibc for how to produce this directory. * the test matrix is done manually. release test builds are only enabled by default for the native target. this should save us some CI time, while still providing decent coverage of release builds. - add test coverage for `x86_64-linux-musl -lc` (building musl libc) - add test coverage for `x86_64-linux-gnu -lc` (building glibc) - add test coverage for `aarch64v8_5a-linux-none` - add test coverage for `aarch64v8_5a-linux-musl -lc` (building musl libc) - add test coverage for `aarch64v8_5a-linux-gnu -lc` (building glibc) - add test coverage for `arm-linux-none` - test coverage for `arm-linux-musleabihf -lc` (building musl libc) is disabled due to #3286 - test coverage for `arm-linux-gnueabihf -lc` (building glibc) is disabled due to #3287 - test coverage for `x86_64-windows-gnu -lc` (building mingw-w64) is disabled due to #3285 * enable qemu testing on the Linux CI job. There's not really a good reason to enable wine, since we have a Windows CI job as well. * remove the no longer needed `--build-file ../build.zig` from CI scripts * fix bug in glibc compilation where it wasn't properly reading the abi list txt files, resulting in "key not found" error. * std.build.Target gains: - isNetBSD - isLinux - osRequiresLibC - getArchPtrBitWidth - getExternalExecutor * zig build system gains support for enabling wine and enabling qemu. `artifact.enable_wine = true;`, `artifact.enable_qemu = true;`. This communicates that the system has these tools installed and the build system will use them to run tests. * zig build system gains support for overriding the dynamic linker of an executable artifact. * fix std.c.lseek prototype. makes behavior tests for arm-linux-musleabihf pass. * disable std lib tests that are failing on ARM. See #3288, #3289 * provide `std.os.off_t`. * disable some of the compiler_rt symbols for arm 32 bit. Fixes compiler_rt tests for arm 32 bit * add __stack_chk_guard when linking against glibc. Fixes std lib tests for aarch64-linux-gnu * workaround for "unable to inline function" using `@inlineCall`. Fixes compiler_rt tests for arm 32 bit.

22 files changed, 479 insertions(+), 89 deletions(-)

build.zig+8-6
...@@ -70,6 +70,7 @@ pub fn build(b: *Builder) !void {...@@ -70,6 +70,7 @@ pub fn build(b: *Builder) !void {
70 const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release;70 const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release;
71 const skip_release_safe = b.option(bool, "skip-release-safe", "Main test suite skips release-safe builds") orelse skip_release;71 const skip_release_safe = b.option(bool, "skip-release-safe", "Main test suite skips release-safe builds") orelse skip_release;
72 const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse false;72 const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse false;
73 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
73 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;74 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
74 if (!skip_self_hosted) {75 if (!skip_self_hosted) {
75 // TODO re-enable this after https://github.com/ziglang/zig/issues/237776 // TODO re-enable this after https://github.com/ziglang/zig/issues/2377
...@@ -96,6 +97,10 @@ pub fn build(b: *Builder) !void {...@@ -96,6 +97,10 @@ pub fn build(b: *Builder) !void {
9697
97 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");98 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
9899
100 const is_wine_enabled = b.option(bool, "enable-wine", "Use Wine to run cross compiled Windows tests") orelse false;
101 const is_qemu_enabled = b.option(bool, "enable-qemu", "Use QEMU to run cross compiled foreign architecture tests") orelse false;
102 const glibc_multi_dir = b.option([]const u8, "enable-foreign-glibc", "Provide directory with glibc installations to run cross compiled tests that link glibc");
103
99 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");104 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");
100 test_stage2_step.dependOn(&test_stage2.step);105 test_stage2_step.dependOn(&test_stage2.step);
101106
...@@ -122,19 +127,16 @@ pub fn build(b: *Builder) !void {...@@ -122,19 +127,16 @@ pub fn build(b: *Builder) !void {
122 }127 }
123 const modes = chosen_modes[0..chosen_mode_index];128 const modes = chosen_modes[0..chosen_mode_index];
124129
125 const multi_and_single = [_]bool{ false, true };
126 const just_multi = [_]bool{false};
127
128 // run stage1 `zig fmt` on this build.zig file just to make sure it works130 // run stage1 `zig fmt` on this build.zig file just to make sure it works
129 test_step.dependOn(&fmt_build_zig.step);131 test_step.dependOn(&fmt_build_zig.step);
130 const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");132 const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
131 fmt_step.dependOn(&fmt_build_zig.step);133 fmt_step.dependOn(&fmt_build_zig.step);
132134
133 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes, multi_and_single, skip_non_native));135 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, glibc_multi_dir));
134136
135 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/std.zig", "std", "Run the standard library tests", modes, multi_and_single, skip_non_native));137 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/std.zig", "std", "Run the standard library tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, glibc_multi_dir));
136138
137 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt.zig", "compiler-rt", "Run the compiler_rt tests", modes, just_multi, skip_non_native));139 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt.zig", "compiler-rt", "Run the compiler_rt tests", modes, true, skip_non_native, true, is_wine_enabled, is_qemu_enabled, glibc_multi_dir));
138140
139 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));141 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
140 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));142 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));
ci/azure/linux_script+2-2
...@@ -12,7 +12,7 @@ sudo apt-get update -q...@@ -12,7 +12,7 @@ sudo apt-get update -q
1212
13sudo apt-get remove -y llvm-*13sudo apt-get remove -y llvm-*
14sudo rm -rf /usr/local/*14sudo rm -rf /usr/local/*
15sudo apt-get install -y libxml2-dev libclang-9-dev llvm-9 llvm-9-dev cmake s3cmd gcc-7 g++-715sudo apt-get install -y libxml2-dev libclang-9-dev llvm-9 llvm-9-dev cmake s3cmd gcc-7 g++-7 qemu
1616
17export CC=gcc-717export CC=gcc-7
18export CXX=g++-718export CXX=g++-7
...@@ -20,7 +20,7 @@ mkdir build...@@ -20,7 +20,7 @@ mkdir build
20cd build20cd build
21cmake .. -DCMAKE_BUILD_TYPE=Release21cmake .. -DCMAKE_BUILD_TYPE=Release
22make -j2 install22make -j2 install
23./zig build --build-file ../build.zig test23./zig build test -Denable-qemu
2424
25if [ "${BUILD_REASON}" != "PullRequest" ]; then25if [ "${BUILD_REASON}" != "PullRequest" ]; then
26 ARTIFACTSDIR="$BUILDDIR/artifacts"26 ARTIFACTSDIR="$BUILDDIR/artifacts"
ci/azure/macos_script+1-1
...@@ -70,7 +70,7 @@ mkdir build...@@ -70,7 +70,7 @@ mkdir build
70cd build70cd build
71cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$(pwd)/release -DZIG_STATIC=ON71cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$(pwd)/release -DZIG_STATIC=ON
72make $JOBS install72make $JOBS install
73release/bin/zig build --build-file ../build.zig test73release/bin/zig build test
7474
75if [ "${BUILD_REASON}" != "PullRequest" ]; then75if [ "${BUILD_REASON}" != "PullRequest" ]; then
76 mv ../LICENSE release/76 mv ../LICENSE release/
ci/azure/windows_script.bat+1-1
...@@ -20,7 +20,7 @@ cd %ZIGBUILDDIR%...@@ -20,7 +20,7 @@ cd %ZIGBUILDDIR%
20cmake.exe .. -Thost=x64 -G"Visual Studio 15 2017 Win64" "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release || exit /b20cmake.exe .. -Thost=x64 -G"Visual Studio 15 2017 Win64" "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release || exit /b
21msbuild /p:Configuration=Release INSTALL.vcxproj || exit /b21msbuild /p:Configuration=Release INSTALL.vcxproj || exit /b
2222
23"%ZIGINSTALLDIR%\bin\zig.exe" build --build-file ..\build.zig test || exit /b23"%ZIGINSTALLDIR%\bin\zig.exe" build test || exit /b
2424
25set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"25set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
26SET "MSYSTEM=MINGW64"26SET "MSYSTEM=MINGW64"
src/glibc.cpp+1-1
...@@ -99,9 +99,9 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo...@@ -99,9 +99,9 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
99 if (!opt_line.is_some) break;99 if (!opt_line.is_some) break;
100100
101 ver_list_base = allocate<ZigGLibCVerList>(glibc_abi->all_functions.length);101 ver_list_base = allocate<ZigGLibCVerList>(glibc_abi->all_functions.length);
102 ZigTarget *target = allocate<ZigTarget>(1);
103 SplitIterator line_it = memSplit(opt_line.value, str(" "));102 SplitIterator line_it = memSplit(opt_line.value, str(" "));
104 for (;;) {103 for (;;) {
104 ZigTarget *target = allocate<ZigTarget>(1);
105 Optional<Slice<uint8_t>> opt_target = SplitIterator_next(&line_it);105 Optional<Slice<uint8_t>> opt_target = SplitIterator_next(&line_it);
106 if (!opt_target.is_some) break;106 if (!opt_target.is_some) break;
107107
std/build.zig+174-1
...@@ -1175,6 +1175,13 @@ pub const Target = union(enum) {...@@ -1175,6 +1175,13 @@ pub const Target = union(enum) {
1175 };1175 };
1176 }1176 }
11771177
1178 pub fn isLinux(self: Target) bool {
1179 return switch (self.getOs()) {
1180 .linux => true,
1181 else => false,
1182 };
1183 }
1184
1178 pub fn isUefi(self: Target) bool {1185 pub fn isUefi(self: Target) bool {
1179 return switch (self.getOs()) {1186 return switch (self.getOs()) {
1180 .uefi => true,1187 .uefi => true,
...@@ -1196,9 +1203,125 @@ pub const Target = union(enum) {...@@ -1196,9 +1203,125 @@ pub const Target = union(enum) {
1196 };1203 };
1197 }1204 }
11981205
1206 pub fn isNetBSD(self: Target) bool {
1207 return switch (self.getOs()) {
1208 .netbsd => true,
1209 else => false,
1210 };
1211 }
1212
1199 pub fn wantSharedLibSymLinks(self: Target) bool {1213 pub fn wantSharedLibSymLinks(self: Target) bool {
1200 return !self.isWindows();1214 return !self.isWindows();
1201 }1215 }
1216
1217 pub fn osRequiresLibC(self: Target) bool {
1218 return self.isDarwin() or self.isFreeBSD() or self.isNetBSD();
1219 }
1220
1221 pub fn getArchPtrBitWidth(self: Target) u32 {
1222 switch (self.getArch()) {
1223 .avr,
1224 .msp430,
1225 => return 16,
1226
1227 .arc,
1228 .arm,
1229 .armeb,
1230 .hexagon,
1231 .le32,
1232 .mips,
1233 .mipsel,
1234 .powerpc,
1235 .r600,
1236 .riscv32,
1237 .sparc,
1238 .sparcel,
1239 .tce,
1240 .tcele,
1241 .thumb,
1242 .thumbeb,
1243 .i386,
1244 .xcore,
1245 .nvptx,
1246 .amdil,
1247 .hsail,
1248 .spir,
1249 .kalimba,
1250 .shave,
1251 .lanai,
1252 .wasm32,
1253 .renderscript32,
1254 .aarch64_32,
1255 => return 32,
1256
1257 .aarch64,
1258 .aarch64_be,
1259 .mips64,
1260 .mips64el,
1261 .powerpc64,
1262 .powerpc64le,
1263 .riscv64,
1264 .x86_64,
1265 .nvptx64,
1266 .le64,
1267 .amdil64,
1268 .hsail64,
1269 .spir64,
1270 .wasm64,
1271 .renderscript64,
1272 .amdgcn,
1273 .bpfel,
1274 .bpfeb,
1275 .sparcv9,
1276 .s390x,
1277 => return 64,
1278 }
1279 }
1280
1281 pub const Executor = union(enum) {
1282 native,
1283 qemu: []const u8,
1284 wine: []const u8,
1285 unavailable,
1286 };
1287
1288 pub fn getExternalExecutor(self: Target) Executor {
1289 if (@TagType(Target)(self) == .Native) return .native;
1290
1291 // If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture.
1292 if (self.getOs() == builtin.os) {
1293 return switch (self.getArch()) {
1294 .aarch64 => Executor{ .qemu = "qemu-aarch64" },
1295 .aarch64_be => Executor{ .qemu = "qemu-aarch64_be" },
1296 .arm => Executor{ .qemu = "qemu-arm" },
1297 .armeb => Executor{ .qemu = "qemu-armeb" },
1298 .i386 => Executor{ .qemu = "qemu-i386" },
1299 .mips => Executor{ .qemu = "qemu-mips" },
1300 .mipsel => Executor{ .qemu = "qemu-mipsel" },
1301 .mips64 => Executor{ .qemu = "qemu-mips64" },
1302 .mips64el => Executor{ .qemu = "qemu-mips64el" },
1303 .powerpc => Executor{ .qemu = "qemu-ppc" },
1304 .powerpc64 => Executor{ .qemu = "qemu-ppc64" },
1305 .powerpc64le => Executor{ .qemu = "qemu-ppc64le" },
1306 .riscv32 => Executor{ .qemu = "qemu-riscv32" },
1307 .riscv64 => Executor{ .qemu = "qemu-riscv64" },
1308 .s390x => Executor{ .qemu = "qemu-s390x" },
1309 .sparc => Executor{ .qemu = "qemu-sparc" },
1310 .x86_64 => Executor{ .qemu = "qemu-x86_64" },
1311 else => return .unavailable,
1312 };
1313 }
1314
1315 if (self.isWindows()) {
1316 switch (self.getArchPtrBitWidth()) {
1317 32 => return Executor{ .wine = "wine" },
1318 64 => return Executor{ .wine = "wine64" },
1319 else => return .unavailable,
1320 }
1321 }
1322
1323 return .unavailable;
1324 }
1202};1325};
12031326
1204const Pkg = struct {1327const Pkg = struct {
...@@ -1266,6 +1389,7 @@ pub const LibExeObjStep = struct {...@@ -1266,6 +1389,7 @@ pub const LibExeObjStep = struct {
1266 include_dirs: ArrayList(IncludeDir),1389 include_dirs: ArrayList(IncludeDir),
1267 output_dir: ?[]const u8,1390 output_dir: ?[]const u8,
1268 need_system_paths: bool,1391 need_system_paths: bool,
1392 is_linking_libc: bool = false,
12691393
1270 installed_path: ?[]const u8,1394 installed_path: ?[]const u8,
1271 install_step: ?*InstallArtifactStep,1395 install_step: ?*InstallArtifactStep,
...@@ -1275,6 +1399,20 @@ pub const LibExeObjStep = struct {...@@ -1275,6 +1399,20 @@ pub const LibExeObjStep = struct {
12751399
1276 valgrind_support: ?bool = null,1400 valgrind_support: ?bool = null,
12771401
1402 /// Uses system Wine installation to run cross compiled Windows build artifacts.
1403 enable_wine: bool = false,
1404
1405 /// Uses system QEMU installation to run cross compiled foreign architecture build artifacts.
1406 enable_qemu: bool = false,
1407
1408 /// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
1409 /// this will be the directory $glibc-build-dir/install/glibcs
1410 /// Given the example of the aarch64 target, this is the directory
1411 /// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
1412 glibc_multi_install_dir: ?[]const u8 = null,
1413
1414 dynamic_linker: ?[]const u8 = null,
1415
1278 const LinkObject = union(enum) {1416 const LinkObject = union(enum) {
1279 StaticPath: []const u8,1417 StaticPath: []const u8,
1280 OtherStep: *LibExeObjStep,1418 OtherStep: *LibExeObjStep,
...@@ -1504,7 +1642,9 @@ pub const LibExeObjStep = struct {...@@ -1504,7 +1642,9 @@ pub const LibExeObjStep = struct {
15041642
1505 pub fn linkSystemLibrary(self: *LibExeObjStep, name: []const u8) void {1643 pub fn linkSystemLibrary(self: *LibExeObjStep, name: []const u8) void {
1506 self.link_objects.append(LinkObject{ .SystemLib = self.builder.dupe(name) }) catch unreachable;1644 self.link_objects.append(LinkObject{ .SystemLib = self.builder.dupe(name) }) catch unreachable;
1507 if (!isLibCLibrary(name)) {1645 if (isLibCLibrary(name)) {
1646 self.is_linking_libc = true;
1647 } else {
1508 self.need_system_paths = true;1648 self.need_system_paths = true;
1509 }1649 }
1510 }1650 }
...@@ -1840,6 +1980,11 @@ pub const LibExeObjStep = struct {...@@ -1840,6 +1980,11 @@ pub const LibExeObjStep = struct {
1840 zig_args.append(builder.pathFromRoot(linker_script)) catch unreachable;1980 zig_args.append(builder.pathFromRoot(linker_script)) catch unreachable;
1841 }1981 }
18421982
1983 if (self.dynamic_linker) |dynamic_linker| {
1984 try zig_args.append("--dynamic-linker");
1985 try zig_args.append(dynamic_linker);
1986 }
1987
1843 if (self.version_script) |version_script| {1988 if (self.version_script) |version_script| {
1844 try zig_args.append("--version-script");1989 try zig_args.append("--version-script");
1845 try zig_args.append(builder.pathFromRoot(version_script));1990 try zig_args.append(builder.pathFromRoot(version_script));
...@@ -1854,6 +1999,34 @@ pub const LibExeObjStep = struct {...@@ -1854,6 +1999,34 @@ pub const LibExeObjStep = struct {
1854 try zig_args.append("--test-cmd-bin");1999 try zig_args.append("--test-cmd-bin");
1855 }2000 }
1856 }2001 }
2002 } else switch (self.target.getExternalExecutor()) {
2003 .native, .unavailable => {},
2004 .qemu => |bin_name| if (self.enable_qemu) qemu: {
2005 const need_cross_glibc = self.target.isGnu() and self.target.isLinux() and self.is_linking_libc;
2006 const glibc_dir_arg = if (need_cross_glibc)
2007 self.glibc_multi_install_dir orelse break :qemu
2008 else
2009 null;
2010 try zig_args.append("--test-cmd");
2011 try zig_args.append(bin_name);
2012 if (glibc_dir_arg) |dir| {
2013 const full_dir = try fs.path.join(builder.allocator, [_][]const u8{
2014 dir,
2015 try self.target.linuxTriple(builder.allocator),
2016 });
2017
2018 try zig_args.append("--test-cmd");
2019 try zig_args.append("-L");
2020 try zig_args.append("--test-cmd");
2021 try zig_args.append(full_dir);
2022 }
2023 try zig_args.append("--test-cmd-bin");
2024 },
2025 .wine => |bin_name| if (self.enable_wine) {
2026 try zig_args.append("--test-cmd");
2027 try zig_args.append(bin_name);
2028 try zig_args.append("--test-cmd-bin");
2029 },
1857 }2030 }
1858 for (self.packages.toSliceConst()) |pkg| {2031 for (self.packages.toSliceConst()) |pkg| {
1859 zig_args.append("--pkg-begin") catch unreachable;2032 zig_args.append("--pkg-begin") catch unreachable;
std/c.zig+1-1
...@@ -63,7 +63,7 @@ pub extern "c" fn close(fd: fd_t) c_int;...@@ -63,7 +63,7 @@ pub extern "c" fn close(fd: fd_t) c_int;
63pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;63pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
64pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;64pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
65pub extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;65pub extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
66pub extern "c" fn lseek(fd: fd_t, offset: isize, whence: c_int) isize;66pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;
67pub extern "c" fn open(path: [*]const u8, oflag: c_uint, ...) c_int;67pub extern "c" fn open(path: [*]const u8, oflag: c_uint, ...) c_int;
68pub extern "c" fn openat(fd: c_int, path: [*]const u8, oflag: c_uint, ...) c_int;68pub extern "c" fn openat(fd: c_int, path: [*]const u8, oflag: c_uint, ...) c_int;
69pub extern "c" fn raise(sig: c_int) c_int;69pub extern "c" fn raise(sig: c_int) c_int;
std/fmt/parse_float.zig+4
...@@ -382,6 +382,10 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {...@@ -382,6 +382,10 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {
382}382}
383383
384test "fmt.parseFloat" {384test "fmt.parseFloat" {
385 if (@import("builtin").arch == .arm) {
386 // TODO https://github.com/ziglang/zig/issues/3289
387 return error.SkipZigTest;
388 }
385 const testing = std.testing;389 const testing = std.testing;
386 const expect = testing.expect;390 const expect = testing.expect;
387 const expectEqual = testing.expectEqual;391 const expectEqual = testing.expectEqual;
std/fs/path.zig+8
...@@ -646,6 +646,10 @@ test "resolve" {...@@ -646,6 +646,10 @@ test "resolve" {
646}646}
647647
648test "resolveWindows" {648test "resolveWindows" {
649 if (@import("builtin").arch == .aarch64) {
650 // TODO https://github.com/ziglang/zig/issues/3288
651 return error.SkipZigTest;
652 }
649 if (windows.is_the_target) {653 if (windows.is_the_target) {
650 const cwd = try process.getCwdAlloc(debug.global_allocator);654 const cwd = try process.getCwdAlloc(debug.global_allocator);
651 const parsed_cwd = windowsParsePath(cwd);655 const parsed_cwd = windowsParsePath(cwd);
...@@ -1086,6 +1090,10 @@ pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![...@@ -1086,6 +1090,10 @@ pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![
1086}1090}
10871091
1088test "relative" {1092test "relative" {
1093 if (@import("builtin").arch == .aarch64) {
1094 // TODO https://github.com/ziglang/zig/issues/3288
1095 return error.SkipZigTest;
1096 }
1089 testRelativeWindows("c:/blah\\blah", "d:/games", "D:\\games");1097 testRelativeWindows("c:/blah\\blah", "d:/games", "D:\\games");
1090 testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa", "..");1098 testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa", "..");
1091 testRelativeWindows("c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc");1099 testRelativeWindows("c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc");
std/io/test.zig+4
...@@ -11,6 +11,10 @@ const fs = std.fs;...@@ -11,6 +11,10 @@ const fs = std.fs;
11const File = std.fs.File;11const File = std.fs.File;
1212
13test "write a file, read it, then delete it" {13test "write a file, read it, then delete it" {
14 if (builtin.arch == .aarch64 and builtin.glibc_version != null) {
15 // TODO https://github.com/ziglang/zig/issues/3288
16 return error.SkipZigTest;
17 }
14 var raw_bytes: [200 * 1024]u8 = undefined;18 var raw_bytes: [200 * 1024]u8 = undefined;
15 var allocator = &std.heap.FixedBufferAllocator.init(raw_bytes[0..]).allocator;19 var allocator = &std.heap.FixedBufferAllocator.init(raw_bytes[0..]).allocator;
1620
std/os/bits/darwin.zig+3-1
...@@ -43,6 +43,8 @@ pub const mach_timebase_info_data = extern struct {...@@ -43,6 +43,8 @@ pub const mach_timebase_info_data = extern struct {
43 denom: u32,43 denom: u32,
44};44};
4545
46pub const off_t = i64;
47
46/// Renamed to Stat to not conflict with the stat function.48/// Renamed to Stat to not conflict with the stat function.
47/// atime, mtime, and ctime have functions to return `timespec`,49/// atime, mtime, and ctime have functions to return `timespec`,
48/// because although this is a POSIX API, the layout and names of50/// because although this is a POSIX API, the layout and names of
...@@ -65,7 +67,7 @@ pub const Stat = extern struct {...@@ -65,7 +67,7 @@ pub const Stat = extern struct {
65 ctimensec: isize,67 ctimensec: isize,
66 birthtimesec: isize,68 birthtimesec: isize,
67 birthtimensec: isize,69 birthtimensec: isize,
68 size: i64,70 size: off_t,
69 blocks: i64,71 blocks: i64,
70 blksize: i32,72 blksize: i32,
71 flags: u32,73 flags: u32,
std/os/bits/freebsd.zig+3-1
...@@ -73,6 +73,8 @@ pub const msghdr_const = extern struct {...@@ -73,6 +73,8 @@ pub const msghdr_const = extern struct {
73 msg_flags: i32,73 msg_flags: i32,
74};74};
7575
76pub const off_t = i64;
77
76/// Renamed to Stat to not conflict with the stat function.78/// Renamed to Stat to not conflict with the stat function.
77/// atime, mtime, and ctime have functions to return `timespec`,79/// atime, mtime, and ctime have functions to return `timespec`,
78/// because although this is a POSIX API, the layout and names of80/// because although this is a POSIX API, the layout and names of
...@@ -96,7 +98,7 @@ pub const Stat = extern struct {...@@ -96,7 +98,7 @@ pub const Stat = extern struct {
96 ctim: timespec,98 ctim: timespec,
97 birthtim: timespec,99 birthtim: timespec,
98100
99 size: i64,101 size: off_t,
100 blocks: i64,102 blocks: i64,
101 blksize: isize,103 blksize: isize,
102 flags: u32,104 flags: u32,
std/os/bits/linux/arm-eabi.zig+3-1
...@@ -511,6 +511,8 @@ pub const msghdr_const = extern struct {...@@ -511,6 +511,8 @@ pub const msghdr_const = extern struct {
511 msg_flags: i32,511 msg_flags: i32,
512};512};
513513
514pub const off_t = i64;
515
514/// Renamed to Stat to not conflict with the stat function.516/// Renamed to Stat to not conflict with the stat function.
515/// atime, mtime, and ctime have functions to return `timespec`,517/// atime, mtime, and ctime have functions to return `timespec`,
516/// because although this is a POSIX API, the layout and names of518/// because although this is a POSIX API, the layout and names of
...@@ -527,7 +529,7 @@ pub const Stat = extern struct {...@@ -527,7 +529,7 @@ pub const Stat = extern struct {
527 gid: u32,529 gid: u32,
528 rdev: u64,530 rdev: u64,
529 __rdev_padding: u32,531 __rdev_padding: u32,
530 size: i64,532 size: off_t,
531 blksize: i32,533 blksize: i32,
532 blocks: u64,534 blocks: u64,
533 atim: timespec,535 atim: timespec,
std/os/bits/linux/arm64.zig+3-1
...@@ -382,6 +382,8 @@ pub const msghdr_const = extern struct {...@@ -382,6 +382,8 @@ pub const msghdr_const = extern struct {
382 msg_flags: i32,382 msg_flags: i32,
383};383};
384384
385pub const off_t = i64;
386
385/// Renamed to Stat to not conflict with the stat function.387/// Renamed to Stat to not conflict with the stat function.
386/// atime, mtime, and ctime have functions to return `timespec`,388/// atime, mtime, and ctime have functions to return `timespec`,
387/// because although this is a POSIX API, the layout and names of389/// because although this is a POSIX API, the layout and names of
...@@ -398,7 +400,7 @@ pub const Stat = extern struct {...@@ -398,7 +400,7 @@ pub const Stat = extern struct {
398 gid: u32,400 gid: u32,
399 __pad0: u32,401 __pad0: u32,
400 rdev: u64,402 rdev: u64,
401 size: i64,403 size: off_t,
402 blksize: isize,404 blksize: isize,
403 blocks: i64,405 blocks: i64,
404406
std/os/bits/linux/x86_64.zig+3-1
...@@ -479,6 +479,8 @@ pub const msghdr_const = extern struct {...@@ -479,6 +479,8 @@ pub const msghdr_const = extern struct {
479 msg_flags: i32,479 msg_flags: i32,
480};480};
481481
482pub const off_t = i64;
483
482/// Renamed to Stat to not conflict with the stat function.484/// Renamed to Stat to not conflict with the stat function.
483/// atime, mtime, and ctime have functions to return `timespec`,485/// atime, mtime, and ctime have functions to return `timespec`,
484/// because although this is a POSIX API, the layout and names of486/// because although this is a POSIX API, the layout and names of
...@@ -495,7 +497,7 @@ pub const Stat = extern struct {...@@ -495,7 +497,7 @@ pub const Stat = extern struct {
495 gid: u32,497 gid: u32,
496 __pad0: u32,498 __pad0: u32,
497 rdev: u64,499 rdev: u64,
498 size: i64,500 size: off_t,
499 blksize: isize,501 blksize: isize,
500 blocks: i64,502 blocks: i64,
501503
std/os/bits/netbsd.zig+3-1
...@@ -73,6 +73,8 @@ pub const msghdr_const = extern struct {...@@ -73,6 +73,8 @@ pub const msghdr_const = extern struct {
73 msg_flags: i32,73 msg_flags: i32,
74};74};
7575
76pub const off_t = i64;
77
76/// Renamed to Stat to not conflict with the stat function.78/// Renamed to Stat to not conflict with the stat function.
77/// atime, mtime, and ctime have functions to return `timespec`,79/// atime, mtime, and ctime have functions to return `timespec`,
78/// because although this is a POSIX API, the layout and names of80/// because although this is a POSIX API, the layout and names of
...@@ -94,7 +96,7 @@ pub const Stat = extern struct {...@@ -94,7 +96,7 @@ pub const Stat = extern struct {
94 ctim: timespec,96 ctim: timespec,
95 birthtim: timespec,97 birthtim: timespec,
9698
97 size: i64,99 size: off_t,
98 blocks: i64,100 blocks: i64,
99 blksize: isize,101 blksize: isize,
100 flags: u32,102 flags: u32,
std/os/test.zig+4
...@@ -95,6 +95,10 @@ test "cpu count" {...@@ -95,6 +95,10 @@ test "cpu count" {
95}95}
9696
97test "AtomicFile" {97test "AtomicFile" {
98 if (builtin.arch == .aarch64 and builtin.glibc_version != null) {
99 // TODO https://github.com/ziglang/zig/issues/3288
100 return error.SkipZigTest;
101 }
98 var buffer: [1024]u8 = undefined;102 var buffer: [1024]u8 = undefined;
99 const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator;103 const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator;
100 const test_out_file = "tmp_atomic_file_test_dest.txt";104 const test_out_file = "tmp_atomic_file_test_dest.txt";
std/rb.zig+9
...@@ -511,6 +511,11 @@ fn testCompare(l: *Node, r: *Node) mem.Compare {...@@ -511,6 +511,11 @@ fn testCompare(l: *Node, r: *Node) mem.Compare {
511}511}
512512
513test "rb" {513test "rb" {
514 if (@import("builtin").arch == .aarch64) {
515 // TODO https://github.com/ziglang/zig/issues/3288
516 return error.SkipZigTest;
517 }
518
514 var tree: Tree = undefined;519 var tree: Tree = undefined;
515 var ns: [10]testNumber = undefined;520 var ns: [10]testNumber = undefined;
516 ns[0].value = 42;521 ns[0].value = 42;
...@@ -571,6 +576,10 @@ test "inserting and looking up" {...@@ -571,6 +576,10 @@ test "inserting and looking up" {
571}576}
572577
573test "multiple inserts, followed by calling first and last" {578test "multiple inserts, followed by calling first and last" {
579 if (@import("builtin").arch == .aarch64) {
580 // TODO https://github.com/ziglang/zig/issues/3288
581 return error.SkipZigTest;
582 }
574 var tree: Tree = undefined;583 var tree: Tree = undefined;
575 tree.init(testCompare);584 tree.init(testCompare);
576 var zeroth: testNumber = undefined;585 var zeroth: testNumber = undefined;
std/special/compiler_rt.zig+4-1
...@@ -143,7 +143,7 @@ comptime {...@@ -143,7 +143,7 @@ comptime {
143 @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage);143 @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage);
144 @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage);144 @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage);
145145
146 if (is_arm_arch and !is_arm_64) {146 if (is_arm_arch and !is_arm_64 and !is_test) {
147 @export("__aeabi_unwind_cpp_pr0", __aeabi_unwind_cpp_pr0, strong_linkage);147 @export("__aeabi_unwind_cpp_pr0", __aeabi_unwind_cpp_pr0, strong_linkage);
148 @export("__aeabi_unwind_cpp_pr1", __aeabi_unwind_cpp_pr1, linkage);148 @export("__aeabi_unwind_cpp_pr1", __aeabi_unwind_cpp_pr1, linkage);
149 @export("__aeabi_unwind_cpp_pr2", __aeabi_unwind_cpp_pr2, linkage);149 @export("__aeabi_unwind_cpp_pr2", __aeabi_unwind_cpp_pr2, linkage);
...@@ -264,6 +264,9 @@ comptime {...@@ -264,6 +264,9 @@ comptime {
264 else => {},264 else => {},
265 }265 }
266 } else {266 } else {
267 if (builtin.glibc_version != null) {
268 @export("__stack_chk_guard", __stack_chk_guard, linkage);
269 }
267 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);270 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);
268 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);271 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);
269 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);272 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);
std/special/compiler_rt/arm/aeabi_dcmp.zig+6-6
...@@ -14,31 +14,31 @@ const ConditionalOperator = enum {...@@ -14,31 +14,31 @@ const ConditionalOperator = enum {
1414
15pub nakedcc fn __aeabi_dcmpeq() noreturn {15pub nakedcc fn __aeabi_dcmpeq() noreturn {
16 @setRuntimeSafety(false);16 @setRuntimeSafety(false);
17 aeabi_dcmp(.Eq);17 @inlineCall(aeabi_dcmp, .Eq);
18 unreachable;18 unreachable;
19}19}
2020
21pub nakedcc fn __aeabi_dcmplt() noreturn {21pub nakedcc fn __aeabi_dcmplt() noreturn {
22 @setRuntimeSafety(false);22 @setRuntimeSafety(false);
23 aeabi_dcmp(.Lt);23 @inlineCall(aeabi_dcmp, .Lt);
24 unreachable;24 unreachable;
25}25}
2626
27pub nakedcc fn __aeabi_dcmple() noreturn {27pub nakedcc fn __aeabi_dcmple() noreturn {
28 @setRuntimeSafety(false);28 @setRuntimeSafety(false);
29 aeabi_dcmp(.Le);29 @inlineCall(aeabi_dcmp, .Le);
30 unreachable;30 unreachable;
31}31}
3232
33pub nakedcc fn __aeabi_dcmpge() noreturn {33pub nakedcc fn __aeabi_dcmpge() noreturn {
34 @setRuntimeSafety(false);34 @setRuntimeSafety(false);
35 aeabi_dcmp(.Ge);35 @inlineCall(aeabi_dcmp, .Ge);
36 unreachable;36 unreachable;
37}37}
3838
39pub nakedcc fn __aeabi_dcmpgt() noreturn {39pub nakedcc fn __aeabi_dcmpgt() noreturn {
40 @setRuntimeSafety(false);40 @setRuntimeSafety(false);
41 aeabi_dcmp(.Gt);41 @inlineCall(aeabi_dcmp, .Gt);
42 unreachable;42 unreachable;
43}43}
4444
...@@ -49,7 +49,7 @@ inline fn convert_dcmp_args_to_df2_args() void {...@@ -49,7 +49,7 @@ inline fn convert_dcmp_args_to_df2_args() void {
49 );49 );
50}50}
5151
52inline fn aeabi_dcmp(comptime cond: ConditionalOperator) void {52fn aeabi_dcmp(comptime cond: ConditionalOperator) void {
53 @setRuntimeSafety(false);53 @setRuntimeSafety(false);
54 asm volatile (54 asm volatile (
55 \\ push { r4, lr }55 \\ push { r4, lr }
std/special/compiler_rt/arm/aeabi_fcmp.zig+6-6
...@@ -14,31 +14,31 @@ const ConditionalOperator = enum {...@@ -14,31 +14,31 @@ const ConditionalOperator = enum {
1414
15pub nakedcc fn __aeabi_fcmpeq() noreturn {15pub nakedcc fn __aeabi_fcmpeq() noreturn {
16 @setRuntimeSafety(false);16 @setRuntimeSafety(false);
17 aeabi_fcmp(.Eq);17 @inlineCall(aeabi_fcmp, .Eq);
18 unreachable;18 unreachable;
19}19}
2020
21pub nakedcc fn __aeabi_fcmplt() noreturn {21pub nakedcc fn __aeabi_fcmplt() noreturn {
22 @setRuntimeSafety(false);22 @setRuntimeSafety(false);
23 aeabi_fcmp(.Lt);23 @inlineCall(aeabi_fcmp, .Lt);
24 unreachable;24 unreachable;
25}25}
2626
27pub nakedcc fn __aeabi_fcmple() noreturn {27pub nakedcc fn __aeabi_fcmple() noreturn {
28 @setRuntimeSafety(false);28 @setRuntimeSafety(false);
29 aeabi_fcmp(.Le);29 @inlineCall(aeabi_fcmp, .Le);
30 unreachable;30 unreachable;
31}31}
3232
33pub nakedcc fn __aeabi_fcmpge() noreturn {33pub nakedcc fn __aeabi_fcmpge() noreturn {
34 @setRuntimeSafety(false);34 @setRuntimeSafety(false);
35 aeabi_fcmp(.Ge);35 @inlineCall(aeabi_fcmp, .Ge);
36 unreachable;36 unreachable;
37}37}
3838
39pub nakedcc fn __aeabi_fcmpgt() noreturn {39pub nakedcc fn __aeabi_fcmpgt() noreturn {
40 @setRuntimeSafety(false);40 @setRuntimeSafety(false);
41 aeabi_fcmp(.Gt);41 @inlineCall(aeabi_fcmp, .Gt);
42 unreachable;42 unreachable;
43}43}
4444
...@@ -49,7 +49,7 @@ inline fn convert_fcmp_args_to_sf2_args() void {...@@ -49,7 +49,7 @@ inline fn convert_fcmp_args_to_sf2_args() void {
49 );49 );
50}50}
5151
52inline fn aeabi_fcmp(comptime cond: ConditionalOperator) void {52fn aeabi_fcmp(comptime cond: ConditionalOperator) void {
53 @setRuntimeSafety(false);53 @setRuntimeSafety(false);
54 asm volatile (54 asm volatile (
55 \\ push { r4, lr }55 \\ push { r4, lr }
test/tests.zig+228-57
...@@ -23,22 +23,181 @@ const runtime_safety = @import("runtime_safety.zig");...@@ -23,22 +23,181 @@ const runtime_safety = @import("runtime_safety.zig");
23const translate_c = @import("translate_c.zig");23const translate_c = @import("translate_c.zig");
24const gen_h = @import("gen_h.zig");24const gen_h = @import("gen_h.zig");
2525
26const cross_targets = [_]CrossTarget{26const TestTarget = struct {
27 CrossTarget{27 target: Target = .Native,
28 .os = .linux,28 mode: builtin.Mode = .Debug,
29 .arch = .x86_64,29 link_libc: bool = false,
30 .abi = .gnu,30 single_threaded: bool = false,
31};
32
33const test_targets = [_]TestTarget{
34 TestTarget{},
35 TestTarget{
36 .link_libc = true,
37 },
38 TestTarget{
39 .single_threaded = true,
40 },
41
42 TestTarget{
43 .mode = .ReleaseFast,
44 },
45 TestTarget{
46 .link_libc = true,
47 .mode = .ReleaseFast,
48 },
49 TestTarget{
50 .mode = .ReleaseFast,
51 .single_threaded = true,
52 },
53
54 TestTarget{
55 .mode = .ReleaseSafe,
56 },
57 TestTarget{
58 .link_libc = true,
59 .mode = .ReleaseSafe,
60 },
61 TestTarget{
62 .mode = .ReleaseSafe,
63 .single_threaded = true,
64 },
65
66 TestTarget{
67 .mode = .ReleaseSmall,
31 },68 },
32 CrossTarget{69 TestTarget{
33 .os = .macosx,70 .link_libc = true,
34 .arch = .x86_64,71 .mode = .ReleaseSmall,
35 .abi = .gnu,
36 },72 },
37 CrossTarget{73 TestTarget{
38 .os = .windows,74 .mode = .ReleaseSmall,
39 .arch = .x86_64,75 .single_threaded = true,
40 .abi = .msvc,
41 },76 },
77
78 TestTarget{
79 .target = Target{
80 .Cross = CrossTarget{
81 .os = .linux,
82 .arch = .x86_64,
83 .abi = .none,
84 },
85 },
86 },
87 TestTarget{
88 .target = Target{
89 .Cross = CrossTarget{
90 .os = .linux,
91 .arch = .x86_64,
92 .abi = .gnu,
93 },
94 },
95 .link_libc = true,
96 },
97 TestTarget{
98 .target = Target{
99 .Cross = CrossTarget{
100 .os = .linux,
101 .arch = .x86_64,
102 .abi = .musl,
103 },
104 },
105 .link_libc = true,
106 },
107
108 TestTarget{
109 .target = Target{
110 .Cross = CrossTarget{
111 .os = .linux,
112 .arch = builtin.Arch{ .aarch64 = builtin.Arch.Arm64.v8_5a },
113 .abi = .none,
114 },
115 },
116 },
117 TestTarget{
118 .target = Target{
119 .Cross = CrossTarget{
120 .os = .linux,
121 .arch = builtin.Arch{ .aarch64 = builtin.Arch.Arm64.v8_5a },
122 .abi = .musl,
123 },
124 },
125 .link_libc = true,
126 },
127 TestTarget{
128 .target = Target{
129 .Cross = CrossTarget{
130 .os = .linux,
131 .arch = builtin.Arch{ .aarch64 = builtin.Arch.Arm64.v8_5a },
132 .abi = .gnu,
133 },
134 },
135 .link_libc = true,
136 },
137
138 TestTarget{
139 .target = Target{
140 .Cross = CrossTarget{
141 .os = .linux,
142 .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
143 .abi = .none,
144 },
145 },
146 },
147 // TODO https://github.com/ziglang/zig/issues/3286
148 //TestTarget{
149 // .target = Target{
150 // .Cross = CrossTarget{
151 // .os = .linux,
152 // .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
153 // .abi = .musleabihf,
154 // },
155 // },
156 // .link_libc = true,
157 //},
158 // TODO https://github.com/ziglang/zig/issues/3287
159 //TestTarget{
160 // .target = Target{
161 // .Cross = CrossTarget{
162 // .os = .linux,
163 // .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
164 // .abi = .gnueabihf,
165 // },
166 // },
167 // .link_libc = true,
168 //},
169
170 TestTarget{
171 .target = Target{
172 .Cross = CrossTarget{
173 .os = .macosx,
174 .arch = .x86_64,
175 .abi = .gnu,
176 },
177 },
178 },
179
180 TestTarget{
181 .target = Target{
182 .Cross = CrossTarget{
183 .os = .windows,
184 .arch = .x86_64,
185 .abi = .msvc,
186 },
187 },
188 },
189
190 // TODO https://github.com/ziglang/zig/issues/3285
191 //TestTarget{
192 // .target = Target{
193 // .Cross = CrossTarget{
194 // .os = .windows,
195 // .arch = .x86_64,
196 // .abi = .gnu,
197 // },
198 // },
199 // .link_libc = true,
200 //},
42};201};
43202
44const max_stdout_size = 1 * 1024 * 1024; // 1 MB203const max_stdout_size = 1 * 1024 * 1024; // 1 MB
...@@ -182,57 +341,69 @@ pub fn addPkgTests(...@@ -182,57 +341,69 @@ pub fn addPkgTests(
182 name: []const u8,341 name: []const u8,
183 desc: []const u8,342 desc: []const u8,
184 modes: []const Mode,343 modes: []const Mode,
185 single_threaded_list: []const bool,344 skip_single_threaded: bool,
186 skip_non_native: bool,345 skip_non_native: bool,
346 skip_libc: bool,
347 is_wine_enabled: bool,
348 is_qemu_enabled: bool,
349 glibc_dir: ?[]const u8,
187) *build.Step {350) *build.Step {
188 const step = b.step(b.fmt("test-{}", name), desc);351 const step = b.step(b.fmt("test-{}", name), desc);
189352
190 var targets = std.ArrayList(*const CrossTarget).init(b.allocator);353 for (test_targets) |test_target| {
191 defer targets.deinit();354 if (skip_non_native and test_target.target != .Native)
192 const host = CrossTarget{ .os = builtin.os, .arch = builtin.arch, .abi = builtin.abi };355 continue;
193 targets.append(&host) catch unreachable;
194 for (cross_targets) |*t| {
195 if (t.os == builtin.os and t.arch == builtin.arch and t.abi == builtin.abi) continue;
196 targets.append(t) catch unreachable;
197 }
198356
199 for (targets.toSliceConst()) |test_target| {357 if (skip_libc and test_target.link_libc)
200 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);
201 if (skip_non_native and !is_native)
202 continue;358 continue;
203 for (modes) |mode| {359
204 for ([_]bool{ false, true }) |link_libc| {360 if (test_target.link_libc and test_target.target.osRequiresLibC()) {
205 for (single_threaded_list) |single_threaded| {361 // This would be a redundant test.
206 if (link_libc and !is_native) {362 continue;
207 // don't assume we have a cross-compiling libc set up363 }
208 continue;364
209 }365 if (skip_single_threaded and test_target.single_threaded)
210 const these_tests = b.addTest(root_src);366 continue;
211 these_tests.setNamePrefix(b.fmt(367
212 "{}-{}-{}-{}-{}-{} ",368 const want_this_mode = for (modes) |m| {
213 name,369 if (m == test_target.mode) break true;
214 @tagName(test_target.os),370 } else false;
215 @tagName(test_target.arch),371 if (!want_this_mode) continue;
216 @tagName(mode),372
217 if (link_libc) "c" else "bare",373 const libc_prefix = if (test_target.target.osRequiresLibC())
218 if (single_threaded) "single" else "multi",374 ""
219 ));375 else if (test_target.link_libc)
220 these_tests.single_threaded = single_threaded;376 "c"
221 these_tests.setFilter(test_filter);377 else
222 these_tests.setBuildMode(mode);378 "bare";
223 if (!is_native) {379
224 these_tests.setTarget(test_target.arch, test_target.os, test_target.abi);380 const triple_prefix = if (test_target.target == .Native)
225 }381 ([]const u8)("native")
226 if (link_libc) {382 else
227 these_tests.linkSystemLibrary("c");383 test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable;
228 }384
229 if (mem.eql(u8, name, "std")) {385 const these_tests = b.addTest(root_src);
230 these_tests.overrideStdDir("std");386 these_tests.setNamePrefix(b.fmt(
231 }387 "{}-{}-{}-{}-{} ",
232 step.dependOn(&these_tests.step);388 name,
233 }389 triple_prefix,
234 }390 @tagName(test_target.mode),
391 libc_prefix,
392 if (test_target.single_threaded) "single" else "multi",
393 ));
394 these_tests.single_threaded = test_target.single_threaded;
395 these_tests.setFilter(test_filter);
396 these_tests.setBuildMode(test_target.mode);
397 these_tests.setTheTarget(test_target.target);
398 if (test_target.link_libc) {
399 these_tests.linkSystemLibrary("c");
235 }400 }
401 these_tests.overrideStdDir("std");
402 these_tests.enable_wine = is_wine_enabled;
403 these_tests.enable_qemu = is_qemu_enabled;
404 these_tests.glibc_multi_install_dir = glibc_dir;
405
406 step.dependOn(&these_tests.step);
236 }407 }
237 return step;408 return step;
238}409}