Skip to content

Commit 5a9b560

Browse files
Fix stable runtime CI failures and separate Haxe 5 preview checks
1 parent d86b8a6 commit 5a9b560

12 files changed

Lines changed: 142 additions & 58 deletions

File tree

‎.github/workflows/fuzz.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ jobs:
5353
# run.sh links libFuzzer without its main, from compiler-rt
5454
- name: Install libFuzzer
5555
run: |
56-
dir=$(clang++ --print-runtime-dir)
57-
if ! ls "$dir"/libclang_rt.fuzzer_no_main*.a 2>/dev/null; then
56+
if ! bash test/fuzz/find-libfuzzer.sh >/dev/null 2>&1; then
5857
major=$(clang++ -dumpversion | cut -d. -f1)
5958
sudo apt-get update -qq
6059
sudo apt-get install -y -qq libclang-rt-$major-dev
61-
ls "$dir"/libclang_rt.fuzzer_no_main*.a
6260
fi
61+
bash test/fuzz/find-libfuzzer.sh
6362
6463
# The inputs that reached new code in earlier runs, so each run starts
6564
# where the last one stopped

‎.github/workflows/haxe5.yml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: haxe 5 preview
2+
on:
3+
push:
4+
branches: [main, 'release/**']
5+
paths-ignore:
6+
- '**.md'
7+
- 'docs/**'
8+
- 'LICENSE.txt'
9+
- '.github/ISSUE_TEMPLATE/**'
10+
pull_request:
11+
paths-ignore:
12+
- '**.md'
13+
- 'docs/**'
14+
- 'LICENSE.txt'
15+
- '.github/ISSUE_TEMPLATE/**'
16+
workflow_dispatch:
17+
18+
# A newer push to the same branch or pull request supersedes the run in progress,
19+
# except on main and release branches
20+
concurrency:
21+
# Each push to main or a release branch is its own group, so every commit
22+
# there gets a complete result; elsewhere the newest push wins
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || ((github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && github.sha) || github.ref }}
24+
cancel-in-progress: true
25+
26+
# Haxe 5 preview failures are reported separately from the stable runtime gate.
27+
jobs:
28+
# Haxe 5.0.0-preview.1 passes API level 500 but generates code for the level
29+
# 430 runtime, and the build tool builds it against that runtime
30+
# (BuildTool.haxeRuntimeLevels). Every suite runs with it on Linux, and the
31+
# core suites on Windows and macOS arm64.
32+
haxe5-preview-linux:
33+
name: Haxe 5.0.0-preview.1 / Linux 64
34+
uses: ./.github/workflows/test.yml
35+
with:
36+
haxe: 5.0.0-preview.1
37+
arch: 64
38+
sep: /
39+
ext: .dso
40+
os: ubuntu-latest
41+
stress: '["default generational-verify"]'
42+
bindir: Linux64
43+
44+
haxe5-preview-windows:
45+
name: Haxe 5.0.0-preview.1 / Windows 64
46+
uses: ./.github/workflows/test.yml
47+
with:
48+
haxe: 5.0.0-preview.1
49+
arch: 64
50+
sep: \
51+
ext: .dll
52+
os: windows-latest
53+
scope: smoke
54+
55+
haxe5-preview-macos:
56+
name: Haxe 5.0.0-preview.1 / macOS arm64
57+
uses: ./.github/workflows/test.yml
58+
with:
59+
haxe: 5.0.0-preview.1
60+
arch: Arm64
61+
sep: /
62+
ext: .dylib
63+
os: macos-latest
64+
scope: smoke
65+
bindir: MacArm64

‎.github/workflows/main.yml‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -131,48 +131,6 @@ jobs:
131131
- name: Build and run the regression tests on Alpine
132132
run: docker run --rm -v "$PWD:/w" -w /w alpine:edge sh -c "apk add --no-cache neko g++ linux-headers && sh test/regression/run-generated.sh"
133133

134-
# Haxe 5.0.0-preview.1 passes API level 500 but generates code for the level
135-
# 430 runtime, and the build tool builds it against that runtime
136-
# (BuildTool.haxeRuntimeLevels). Every suite runs with it on Linux, and the
137-
# core suites on Windows and macOS arm64.
138-
haxe5-preview-linux:
139-
name: Haxe 5.0.0-preview.1 / Linux 64
140-
needs: [check-headers, check-gc-defines]
141-
uses: ./.github/workflows/test.yml
142-
with:
143-
haxe: 5.0.0-preview.1
144-
arch: 64
145-
sep: /
146-
ext: .dso
147-
os: ubuntu-latest
148-
stress: '["default generational-verify"]'
149-
bindir: Linux64
150-
151-
haxe5-preview-windows:
152-
name: Haxe 5.0.0-preview.1 / Windows 64
153-
needs: [check-headers, check-gc-defines]
154-
uses: ./.github/workflows/test.yml
155-
with:
156-
haxe: 5.0.0-preview.1
157-
arch: 64
158-
sep: \
159-
ext: .dll
160-
os: windows-latest
161-
scope: smoke
162-
163-
haxe5-preview-macos:
164-
name: Haxe 5.0.0-preview.1 / macOS arm64
165-
needs: [check-headers, check-gc-defines]
166-
uses: ./.github/workflows/test.yml
167-
with:
168-
haxe: 5.0.0-preview.1
169-
arch: Arm64
170-
sep: /
171-
ext: .dylib
172-
os: macos-latest
173-
scope: smoke
174-
bindir: MacArm64
175-
176134
# The regression, std and GC stress suites under UBSan, ASan and TSan. A
177135
# sanitizer report fails its suite; the reports go to files because the
178136
# runner only shows stdout. Each suite runs even when one before it failed.

‎Changes.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
libhxcpp 6.0.0 (unreleased)
33
------------------------------------------------------------
44

5+
* Fixed the 32-bit x86 collector missing live objects held only in EBP when frame pointers are omitted. It now captures EBP with the other callee-saved registers; the lost strings in the Linux 32 CFFI tests were one consequence (libhxcpp #430)
6+
* Fixed GCC TSan builds reporting allocator races because a Clang sanitizer annotation also disabled instrumentation of the block-claim atomics on newer GCC. GCC keeps those atomics instrumented, without adding suppressions, and the Linux 32 and TSan jobs run on ubuntu-latest again (libhxcpp #430)
7+
* Fixed the fuzz job failing to find libFuzzer on Ubuntu 26.04 with Clang 21, whose reported runtime directory differs from the compiler-rt package's lib/linux directory. Setup and the fuzz build now check both locations for the native archive
8+
* Haxe 5 preview tests run in their own workflow, so their failures remain visible separately from the stable Haxe 4 runtime checks
59
* Added HXCPP_PGO, profile-guided optimisation with MSVC, GCC and Clang: -D HXCPP_PGO=generate builds a program that counts what it runs, and -D HXCPP_PGO=use builds it again from what a run counted, with link-time optimisation. On a replication benchmark it took a further 4 to 29% off with MSVC, 19 to 43% with GCC and 12 to 46% with Clang. See docs/ProfileGuidedOptimisation.md
610
* Fixed HXCPP_OPTIMIZE_LINK builds with Clang on Linux failing to link ("file format not recognized"): objects were compiled with -flto and linked without it, which GCC's linker plugin covered for, on one thread, and Clang's bitcode objects did not. Programs and shared libraries now link with -flto
711
* Fixed an MSVC build with HXCPP_OPTIMIZE_LINK failing after any change (C1382, then LNK1257) until its objects were deleted: a group's PCH is rebuilt whenever one of its files compiles, and the link checks each object against the PCH it was compiled with. When the PCH is rebuilt under link-time code generation, the rest of the group is compiled against it too

‎src/hx/gc/GcRegCapture.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,17 @@ void CaptureX86(RegisterCaptureBuffer &outBuffer)
6161
void *regEsi;
6262
void *regEdi;
6363
void *regEbx;
64+
// EBP is another callee-saved general register when frame pointers are
65+
// omitted. A live object may be held only there across a collection.
66+
void *regEbp;
6467
asm ("mov %%esi, %0\n\t" : "=r" (regEsi) );
6568
asm ("mov %%edi, %0\n\t" : "=r" (regEdi) );
6669
asm ("mov %%ebx, %0\n\t" : "=r" (regEbx) );
70+
asm ("mov %%ebp, %0\n\t" : "=r" (regEbp) );
6771
outBuffer.esi = regEsi;
6872
outBuffer.edi = regEdi;
6973
outBuffer.ebx = regEbx;
74+
outBuffer.ebp = regEbp;
7075
}
7176

7277
} // end namespace hx

‎src/hx/gc/GcRegCapture.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct RegisterCaptureBuffer
127127
void *ebx;
128128
void *edi;
129129
void *esi;
130+
void *ebp;
130131

131132
void *frame[CAPTURE_FRAME_WORDS];
132133
size_t frameWords = 0;

‎src/hx/gc/Immix.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4531,7 +4531,11 @@ class GlobalAllocator
45314531
// size seen early may not be written yet on a weakly ordered CPU
45324532
// * it is not critical whether the mNextFreeBlockOfSize is increased since
45334533
// skipping only leads to a bit of extra searching for the next allocation
4534-
#if defined(__has_feature)
4534+
// GCC's no_sanitize also hides the atomic claim of mZeroLock. Newer GCC
4535+
// defines __has_feature, so applying the Clang annotation there loses the
4536+
// ordering from the zeroing thread and block publication in TSan. GCC uses
4537+
// the race_top suppressions for the hint reads and keeps the atomics seen.
4538+
#if defined(__clang__) && defined(__has_feature)
45354539
#if __has_feature(thread_sanitizer)
45364540
__attribute__((no_sanitize("thread")))
45374541
#endif

‎test/fuzz/find-libfuzzer.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# compiler-rt packages can use the older lib/linux directory even when the
3+
# compiler reports a target-triple runtime directory (Ubuntu 26.04, Clang 21).
4+
set -eu
5+
cxx=${CXX:-clang++}
6+
runtime=$("$cxx" --print-runtime-dir)
7+
resource=$("$cxx" -print-resource-dir)
8+
arch=$(uname -m)
9+
for dir in "$runtime" "$resource/lib/linux"; do
10+
for name in libclang_rt.fuzzer_no_main.a "libclang_rt.fuzzer_no_main-$arch.a"; do
11+
if [ -f "$dir/$name" ]; then
12+
printf '%s\n' "$dir/$name"
13+
exit 0
14+
fi
15+
done
16+
done
17+
echo "No native libclang_rt.fuzzer_no_main in $runtime or $resource/lib/linux; install compiler-rt for $cxx" >&2
18+
exit 1

‎test/fuzz/run.sh‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,7 @@ else
6666
# libFuzzer without its main, which Fuzz.main replaces. The runtime
6767
# directory can hold one archive per architecture, named for it, and
6868
# the i386 one sorts first, so take the one for this machine
69-
rt=$($CXX --print-runtime-dir)
70-
lib=
71-
for candidate in "$rt/libclang_rt.fuzzer_no_main.a" "$rt/libclang_rt.fuzzer_no_main-$(uname -m).a"; do
72-
if [ -f "$candidate" ]; then
73-
lib=$candidate
74-
break
75-
fi
76-
done
77-
if [ -z "$lib" ]; then
78-
echo "No libclang_rt.fuzzer_no_main in $($CXX --print-runtime-dir); install compiler-rt for $CXX" >&2
79-
exit 1
80-
fi
69+
lib=$(bash ./find-libfuzzer.sh) || exit 1
8170
haxe libfuzzer.hxml -D HXCPP_SANITIZE=fuzzer-no-link,address,undefined -D "FUZZER_NO_MAIN=$lib" || exit 1
8271
fi
8372
fuzz=$(exe out)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// With frame pointers omitted, a 32-bit compiler can keep the only reference
2+
// to values in EBP across a collection. CaptureX86 must save EBP with the other
3+
// callee-saved registers. The warm-up affects allocation and register layout.
4+
@:cppFileCode('
5+
extern "C" void *hx_cffi(const char *);
6+
static ::String viewText(Dynamic value) {
7+
typedef const char *(*View)(hx::Object *);
8+
static View view = (View)hx_cffi("val_string");
9+
return ::String::create(view(value.mPtr));
10+
}
11+
')
12+
class Main {
13+
static function text(n:Int):String {
14+
var b = new StringBuf();
15+
for (i in 0...n) b.addChar(0x3bb);
16+
b.add("end");
17+
return b.toString();
18+
}
19+
static function view(v:Dynamic):String return untyped __cpp__('viewText({0})', v);
20+
static function main() {
21+
view(text(4096));
22+
for (round in 0...20) {
23+
var values:Array<Dynamic> = [];
24+
for (i in 0...64) {
25+
var boxed:Dynamic = text(i + 1);
26+
view(boxed);
27+
values.push(boxed);
28+
}
29+
for (i in 0...3) cpp.vm.Gc.run(true);
30+
cpp.vm.Gc.compact();
31+
for (i in 0...64) {
32+
var actual = view(values[i]);
33+
if (actual != text(i + 1)) throw 'round $round view $i got "$actual"';
34+
}
35+
}
36+
Sys.println("views survived");
37+
}
38+
}

0 commit comments

Comments
 (0)