Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ jobs:
working-directory: test/haxe
run: bin\TestMain

# clang-cl's /Yu reads a clang precompiled header, which keeps each
# header's date, so the compile cache must make it again when one changes
- name: Build with the cached precompiled header after a header's date changes
shell: bash
run: bash test/compile_cache/pch_dates.sh -D HXCPP_MSVC_LLVM -D HXCPP_M64

check-android:
name: Build for Android (${{ matrix.abi }})
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -283,6 +289,22 @@ jobs:
working-directory: test/regression
run: haxe --run Run -D emscripten

# Each file must compile with the standard its group, its own
# cxx_standard or HXCPP_CPP17 asks for: the toolchain once pinned C++11
# after the build tool's -std, so all three built as C++11
- name: Build with each file's C++ standard
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
working-directory: test/cxx_standard
run: |
for xml in *.xml; do
haxelib run hxcpp $xml -Demscripten
haxelib run hxcpp $xml clean -Demscripten
done

- name: Build with the cached precompiled header after a header's date changes
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
run: bash test/compile_cache/pch_dates.sh -D emscripten

- name: Run the memory and stack test
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
run: timeout 600 sh test/emscripten/run.sh
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ jobs:
scope: ${{ inputs.pr && 'smoke' || 'full' }}
stress: '["default generational verify", "generational-verify moving big-blocks", "always-move check-pointer", "big-generational big-verify nursery dynamic-size debug-level"]'

# Haxe has no Windows arm64 build, so the x64 Haxe and Neko run emulated,
# and the C++ compiles with the ARM64-hosted compiler
WindowsArm64:
if: ${{ !inputs.pr }}
uses: ./.github/workflows/test.yml
name: Windows arm64
with:
haxe: ${{ inputs.haxe }}
arch: Arm64
sep: \
ext: .dll
os: windows-11-arm
scope: smoke

MacOS64:
if: ${{ !inputs.pr }}
uses: ./.github/workflows/test.yml
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ runs:
using: composite
steps:
- name: install haxe
if: runner.os != 'Windows' || runner.arch != 'ARM64'
uses: krdlab/setup-haxe@v2
with:
haxe-version: ${{ inputs.haxe }}

# setup-haxe's releases, v2.1.1 the latest, have no Windows arm64 support.
# The commit that added it, merged on 2026-10-18, installs the x64 Haxe
# and Neko there, which Windows runs emulated; use a release once one has it
- name: install haxe (Windows arm64)
if: runner.os == 'Windows' && runner.arch == 'ARM64'
uses: krdlab/setup-haxe@2158bbdec718708920c54ab91fb19d8ddfa28f32
with:
haxe-version: ${{ inputs.haxe }}

- name: install haxe libraries
shell: pwsh
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ jobs:
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
shell: bash
run: bash test/compile_errors/check.sh
# Clang refused a cached precompiled header once a header's date changed
- name: build tool cached precompiled header after a header's date changes
continue-on-error: ${{ inputs.warn_only }}
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
shell: bash
run: bash test/compile_cache/pch_dates.sh -D $HXCPP_ARCH_FLAG
- name: build tool compile cache trimming keeps what builds use
continue-on-error: ${{ inputs.warn_only }}
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
shell: bash
run: bash test/compile_cache/trim.sh -D$HXCPP_ARCH_FLAG
- name: build tool MSVC setup scripts with ! in the Visual Studio path
continue-on-error: ${{ inputs.warn_only }}
if: ${{ !cancelled() && steps.setup.outcome == 'success' && runner.os == 'Windows' }}
Expand Down
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
libhxcpp 6.1.0 (unreleased)
------------------------------------------------------------

* Fixed Emscripten builds ignoring the C++ standard: the toolchain added --std=c++11 after the build tool's own -std, so HXCPP_CXX_STANDARD, HXCPP_CPP14, HXCPP_CPP17 and cxx_standard did nothing there and every file, the precompiled header included, compiled as C++11. Each file gets the standard it asks for now, C++11 by default as before, so an Emscripten build compiles everything once more after updating. The GCW Zero toolchain had the same flag (HaxeFoundation/hxcpp#1232)
* Fixed Objective-C++ ignoring the C++ standard: it compiled as C++11 whatever HXCPP_CXX_STANDARD, HXCPP_CPP14, HXCPP_CPP17 or cxx_standard asked for, and with -D objc, which makes every generated file .mm, so did all of a program's Haxe code while the runtime followed the setting. Objective-C++ follows the C++ standard now, and Objective-C the C one, a file's own cxx_standard or c_standard included; objcxx_standard, objc_standard, HXCPP_OBJCXX_STANDARD and HXCPP_OBJC_STANDARD still set them apart (HaxeFoundation/hxcpp#1250)
* Fixed builds with the compile cache failing on clang once a header's date changed but not its content, as after a fresh clone, a branch switched and back or a restored CI cache: the cached precompiled header is found by content, and clang refused it with "has been modified since the precompiled header was built" at the first file that had to compile, on macOS, iOS, Android, Emscripten and Linux with clang. A cached precompiled header keeps the dates of the headers it was made from now, and is made again when one differs, later or earlier (HaxeFoundation/hxcpp#1466)
* Fixed the compile cache removing what builds still use when it trims to HXCPP_CACHE_MB, or with "cache days": it took an entry's last use from its access and change times, which reusing it changes neither, as an object up to date in the cache is linked from there and Windows does not update access times. So objects every build reused looked as old as when they were compiled, went first, and were compiled again. Each target now lists in the cache's .used folder what its last build took from the cache, reused or not, and trimming takes that list's date as their last use; no object's date changes, so a build with nothing to do still links nothing. "cache details" shows that date (HaxeFoundation/hxcpp#1469)
* Fixed builds on a Windows ARM64 machine using the x86-hosted MSVC, which Windows runs emulated in 32 bits and which can run out of memory on a precompiled header: setup asked for it for ARM64 desktop and WinRT builds, through Visual Studio's VsDevCmd and through HXCPP_MSVC_VER's vcvars scripts alike. The ARM64-hosted compiler is used now when it is installed, else the x64-hosted one, which runs emulated with a 64-bit address space, and the x86-hosted one only when neither is. CI runs the core suites on Windows ARM64 (HaxeFoundation/hxcpp#1400)

libhxcpp 6.0.3
------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/build_xml/Defines.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Defines affecting how the code is compiled. These can be on the command line wh
| *HXCPP_C_STANDARD* | Set default C standard |
| *HXCPP_CXX_STANDARD* | Set default C++ standard |
| *HXCPP_CPP17* | Use C++17, as HXCPP_CXX_STANDARD=17 does |
| *HXCPP_OBJC_STANDARD* | Set default Objective-C standard |
| *HXCPP_OBJCXX_STANDARD* | Set default Objective-C++ standard |
| *HXCPP_OBJC_STANDARD* | Set default Objective-C standard. Without it, Objective-C follows the C standard |
| *HXCPP_OBJCXX_STANDARD* | Set default Objective-C++ standard. Without it, Objective-C++ follows the C++ standard |
| *exe_link* | Generate executable file (rather than dynamic library on android) |
| *static_link* | Generate static library |
| *dll_link* | Generate dynamic library |
Expand Down
8 changes: 4 additions & 4 deletions docs/build_xml/Files.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The files node defines a group of files that all share the same attributes, incl

+ `c_standard` = Default C standard for the file group
+ `cxx_standard` = Default C++ standard for the file group
+ `objc_standard` = Default Objective-C standard for the file group
+ `objcxx_standard` = Default Objective-C++ standard for the file group
+ `objc_standard` = Default Objective-C standard for the file group. Without one, Objective-C follows the C standard
+ `objcxx_standard` = Default Objective-C++ standard for the file group. Without one, Objective-C++ follows the C++ standard
#### Nodes
- *depend* - Declare that all files in the group depend on another file or another file group.
```xml
Expand Down Expand Up @@ -103,8 +103,8 @@ The files node defines a group of files that all share the same attributes, incl
+ tags = optional override of group tags. See [Tags.md](Tags.md).
+ `c_standard` = C standard for the file
+ `cxx_standard` = C++ standard for the file
+ `objc_standard` = Objective-C standard for the file
+ `objcxx_standard` = Objective-C++ standard for the file
+ `objc_standard` = Objective-C standard for the file. Without one, the file follows its own `c_standard` if it has one, else its group
+ `objcxx_standard` = Objective-C++ standard for the file. Without one, the file follows its own `cxx_standard` if it has one, else its group
+ filterout = allows files to be skipped at compile-time if the named define exists.
This is useful when the define is set sometime after the file list is parsed.
+ depend name = filename of additional dependency
Expand Down
56 changes: 56 additions & 0 deletions test/compile_cache/pch_dates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# HaxeFoundation/hxcpp#1466: clang keeps each header's date in a precompiled
# header and refuses it once a date differs, though the content is the same.
# The compile cache finds a precompiled header by content, so a fresh clone, a
# branch switched and back or a restored CI cache stopped the next compile with
# "has been modified since the precompiled header was built".
# This builds a program with the compile cache, then edits it and builds it
# again with hxcpp.h dated later, and then earlier, than the cached precompiled
# header. Each build must succeed and print what it was edited to. Only clang
# and clang-cl check the dates, but every compiler must pass.
# Uses HXCPP_COMPILE_CACHE, or a cache of its own when that is not set.
# Usage: test/compile_cache/pch_dates.sh [extra haxe args, eg -D HXCPP_M64 or -D emscripten]
cd "$(dirname "$0")"
extra=("$@")
hxcpp=$(haxelib libpath hxcpp | tr -d '\r')
header="${hxcpp//\\//}/include/hxcpp.h"
[ -f "$header" ] || { echo "::error::no hxcpp.h at $header"; exit 1; }
rm -rf bin
mkdir -p bin/src
[ -n "$HXCPP_COMPILE_CACHE" ] || export HXCPP_COMPILE_CACHE="$PWD/bin/cache"

# Later builds in the same checkout see the header's date as it was
touch -r "$header" bin/header-date
trap 'touch -r bin/header-date "$header"' EXIT

run() {
if [ -f bin/cpp/Main.js ]; then node bin/cpp/Main.js
elif [ -f bin/cpp/Main.exe ]; then bin/cpp/Main.exe
else bin/cpp/Main
fi
}

# build <name>: builds and runs a Main that prints its name
build() {
printf 'class Main {\n\tstatic function main() {\n\t\tSys.println("%s");\n\t}\n}\n' "$1" > bin/src/Main.hx
if ! haxe -cp bin/src -m Main --cpp bin/cpp "${extra[@]}" > bin/build.log 2>&1; then
echo "::error::the build $1 failed"
tail -20 bin/build.log
return 1
fi
local out
out=$(run | tr -d '\r')
if [ "$out" != "$1" ]; then
echo "::error::the build $1 printed \"$out\""
return 1
fi
echo "$1: built and printed its name"
}

failed=0
build first || failed=1
touch "$header"
build later || failed=1
touch -t 200001010000 "$header"
build earlier || failed=1
exit $failed
54 changes: 54 additions & 0 deletions test/compile_cache/trim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# HaxeFoundation/hxcpp#1469: trimming the compile cache, to HXCPP_CACHE_MB or
# by age, took an entry's use from its access and change times. Reusing an
# entry changes neither: an object up to date in the cache is linked from
# there, and Windows does not update access times. So entries every build
# reused looked as old as when they were compiled, and went first.
# This builds trim/Build.xml with a cache of its own, edits main.cpp and builds
# again, which reuses the rest in place, then dates every entry back to 2000,
# as if compiled long ago and never read since. Trimming to one day must keep
# all the last build used, so that build does nothing again, and remove the
# first main.cpp's object, which nothing has used since.
# Usage: test/compile_cache/trim.sh [extra build tool args, eg -DHXCPP_M64]
cd "$(dirname "$0")"
extra=("$@")
rm -rf bin/trim
mkdir -p bin/trim
cp trim/* bin/trim/
cd bin/trim
export HXCPP_COMPILE_CACHE="$PWD/cache"

# build <name> <value>: builds with a main.cpp of its own
build() {
printf '#include <pre.h>\n\nint main() { return other() + libValue() - %s; }\n' "$2" > main.cpp
if ! haxelib run hxcpp Build.xml "${extra[@]}" > "$1.log" 2>&1; then
echo "::error::the build $1 failed"
tail -20 "$1.log"
exit 1
fi
}

build first 1
build second 2
# The records of what each build used keep their dates
find cache -path cache/.used -prune -o -type f -exec touch -t 200001010000 {} +
haxelib run hxcpp cache days 1 "${extra[@]}" > trim.log 2>&1 || { echo "::error::trimming failed"; cat trim.log; exit 1; }
grep "Cache:" trim.log

failed=0
build again 2
if grep -q "Compiling group\|Creating\|Link:" again.log; then
echo "::error::trimming removed what the last build used, so building it again did this:"
grep "Compiling group\|Creating\|Link:" again.log
failed=1
else
echo "trimming kept what the last build used"
fi
build old 1
if grep -q "Compiling group" old.log; then
echo "trimming removed the first main.cpp's object"
else
echo "::error::trimming kept the first main.cpp's object, which nothing has used since"
failed=1
fi
exit $failed
20 changes: 20 additions & 0 deletions test/compile_cache/trim/Build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<xml>
<!-- A cached group linked as a library, and a cached group with a precompiled header -->
<files id="lib">
<cache value="1" project="trim_test" asLibrary="true" />
<file name="lib.cpp" />
</files>

<files id="main">
<compilerflag value="-I." />
<precompiledheader name="pre" dir="." />
<cache value="1" project="trim_test" />
<file name="main.cpp" />
<file name="other.cpp" />
</files>

<target id="default" tool="linker" toolid="exe" output="prog">
<files id="lib" />
<files id="main" />
</target>
</xml>
1 change: 1 addition & 0 deletions test/compile_cache/trim/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libValue() { return 2; }
3 changes: 3 additions & 0 deletions test/compile_cache/trim/other.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <pre.h>

int other() { return 1; }
7 changes: 7 additions & 0 deletions test/compile_cache/trim/pre.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef TRIM_TEST_PRE_H
#define TRIM_TEST_PRE_H

int other();
int libValue();

#endif
6 changes: 6 additions & 0 deletions test/cxx_standard/Build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<file name="cxx14.cpp" cxx_standard="14" />
<file name="c11.c" c_standard="11" />
<file name="c17.c" c_standard="17" />
<!-- Objective-C and Objective-C++ follow the C and C++ standards, the group's or the file's own -->
<section if="macos||emscripten">
<file name="objcxx17.mm" />
<file name="objcxx14.mm" cxx_standard="14" />
<file name="objc17.m" c_standard="17" />
</section>
</files>

<set name="EXESUFFIX" value=".exe" if="windows" />
Expand Down
1 change: 1 addition & 0 deletions test/cxx_standard/Build_legacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<files id="test">
<compilerflag value="/Zc:__cplusplus" if="isMsvc" />
<file name="main.cpp" />
<file name="objcxx17.mm" if="macos||emscripten" />
</files>

<target id="default" tool="linker" toolid="exe" output="main">
Expand Down
2 changes: 2 additions & 0 deletions test/cxx_standard/Build_section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<compilerflag value="/Zc:__cplusplus" if="isMsvc" />
<section>
<file name="main.cpp" />
<!-- An Objective-C++ standard of its own wins over the C++ one -->
<file name="objcxx14.mm" objcxx_standard="14" if="macos||emscripten" />
</section>
</files>

Expand Down
6 changes: 6 additions & 0 deletions test/cxx_standard/objc17.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __OBJC__
#error "Not Objective-C"
#endif
#if __STDC_VERSION__ < 201710L
#error "Not C17"
#endif
6 changes: 6 additions & 0 deletions test/cxx_standard/objcxx14.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __OBJC__
#error "Not Objective-C++"
#endif
#if __cplusplus != 201402L
#error "Not C++14"
#endif
6 changes: 6 additions & 0 deletions test/cxx_standard/objcxx17.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __OBJC__
#error "Not Objective-C++"
#endif
#if __cplusplus < 201703L
#error "Not C++17"
#endif
Loading
Loading