Skip to content

Commit 7c4f115

Browse files
committed
build
1 parent e42376a commit 7c4f115

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

.lldbinit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
command script import tools/lldb_pretty_printers.py
2+
type category enable zig.stage2 zig.std zig.lang
3+
type summary add --category zig.stage2 --inline-children arch.x86_64.CodeGen.FrameAddr
4+
type summary add --category zig.stage2 --inline-children arch.x86_64.CodeGen.RegisterOffset
5+
type summary add --category zig.stage2 --inline-children arch.x86_64.CodeGen.InstTracking

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -e
3+
build=build
4+
if [ "x$1" != x--debug ]; then
5+
cmake -GNinja -S. -B$build -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=clang -DCMAKE_CXX_COMPILER:FILEPATH=clang++ -DZIG_NO_LIB:BOOL=ON
6+
cmake --build $build
7+
cmake --install $build
8+
else
9+
shift
10+
fi
11+
$build/stage3/bin/zig build -p debug -Dno-lib -Denable-llvm "$@"

lib/std/Build/Step/Run.zig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,35 @@ fn runCommand(
976976
else => false,
977977
};
978978

979+
if (b.enable_qemu) runtime_dir: {
980+
const exe = switch (run.argv.items[0]) {
981+
.artifact => |exe| exe.artifact,
982+
else => break :runtime_dir,
983+
};
984+
switch (exe.kind) {
985+
.exe, .@"test" => {},
986+
else => break :runtime_dir,
987+
}
988+
989+
const root_target = exe.rootModuleTarget();
990+
const need_cross_glibc = root_target.isGnuLibC() and
991+
exe.is_linking_libc;
992+
993+
const glibc_dir_arg = if (need_cross_glibc)
994+
b.glibc_runtimes_dir
995+
else
996+
null;
997+
if (glibc_dir_arg) |dir| run.setEnvironmentVariable("QEMU_LD_PREFIX", b.pathJoin(&.{
998+
dir,
999+
try std.zig.target.glibcRuntimeTriple(
1000+
b.allocator,
1001+
root_target.cpu.arch,
1002+
root_target.os.tag,
1003+
root_target.abi,
1004+
),
1005+
}));
1006+
}
1007+
9791008
var interp_argv = std.ArrayList([]const u8).init(b.allocator);
9801009
defer interp_argv.deinit();
9811010

lldb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../llvm/lldb/Debug/bin/lldb

test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
if [[ $1 == --behavior-c ]]; then
3+
shift
4+
./build.sh --debug && debug/bin/zig test -Itest test/behavior.zig -ofmt=c "$@"
5+
elif [[ $1 == --enable-fixed-behavior ]]; then
6+
backend=$2
7+
shift 2
8+
declare -A offsets
9+
git grep --no-index --line-number stage2_$backend test/behavior | while read -r match; do
10+
printf '\e[36mTrying to enable... %s\e[m\n' "$match"
11+
file=`cut -d: -f1 <<<"$match"`
12+
offset=${offsets[$file]:=0}
13+
echo "match = \"$match\""
14+
let line=`cut -d: -f2 <<<"$match"`-$offset
15+
contents=`cut -d: -f3- <<<"$match"`
16+
sed --in-place "${line}d" "$file"
17+
if timeout 15s debug/bin/zig test test/behavior.zig "$@"; then
18+
printf '\e[32mTest was enabled! :)\e[m\n'
19+
let offsets[$file]+=1
20+
else
21+
printf '\e[31mTest kept disabled. :(\e[m\n'
22+
sed --in-place "${line}i\\
23+
$contents" "$file"
24+
fi
25+
done
26+
fi

0 commit comments

Comments
 (0)