Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max() regression on windows llvm arm64 (added to CI matrix) #25

Merged
merged 8 commits into from
Jan 21, 2025
Merged
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
40 changes: 27 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,41 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
# group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-${{ matrix.os }}-${{ matrix.type }}
# group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-${{ matrix.setup.os }}-${{ matrix.setup.build }}-${{ matrix.type }}
# cancel-in-progress: true

jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
os: [
# macos-13,
# macos-14,
macos-latest,
# ubuntu-22.04,
ubuntu-latest,
# windows-2019,
windows-latest,
]
setup:
- os: windows-latest
build: 'default'
defines: ''
test: true
- os: windows-latest
build: 'llvm-arm64'
defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake'
test: false
- os: windows-latest
build: 'msvc-arm64'
defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake'
test: true
- os: macos-latest
build: default
defines: ''
test: true
- os: ubuntu-latest
build: default
defines: ''
test: true
type: [
Release,
Debug,
]
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.setup.os }}
name: ${{ matrix.setup.os }}-${{ matrix.setup.build }}-${{ matrix.type }}
timeout-minutes: 30

steps:
Expand All @@ -44,7 +57,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.11
with:
key: ${{ matrix.os }}-${{ matrix.type }}
key: ${{ matrix.setup.os }}-${{ matrix.setup.build }}-${{ matrix.type }}

- name: Set up CMake
uses: lukka/get-cmake@latest
Expand All @@ -61,10 +74,11 @@ jobs:
- name: Configure CMake
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: cmake -B ${{github.workspace}}/build ${{ matrix.setup.defines }} -DCMAKE_BUILD_TYPE=${{ matrix.type }}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{ matrix.type }} --parallel

- name: Test
if: ${{ matrix.setup.test }}
run: ctest --test-dir build --output-on-failure --verbose -C ${{ matrix.type }}
16 changes: 16 additions & 0 deletions cmake/arm64-windows-llvm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set( CMAKE_SYSTEM_NAME Windows )
set( CMAKE_SYSTEM_PROCESSOR arm64 )

set( target arm64-pc-windows-msvc )

set( CMAKE_C_COMPILER clang )
set( CMAKE_CXX_COMPILER clang++ )

set( CMAKE_C_COMPILER_TARGET ${target} )
set( CMAKE_CXX_COMPILER_TARGET ${target} )

set( arch_c_flags "-march=armv8.7-a -fvectorize -ffp-model=fast -fno-finite-math-only" )
set( warn_c_flags "-Wno-format -Wno-unused-variable -Wno-unused-function -Wno-gnu-zero-variadic-macro-arguments" )

set( CMAKE_C_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )
set( CMAKE_CXX_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )
6 changes: 6 additions & 0 deletions cmake/arm64-windows-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set( CMAKE_SYSTEM_NAME Windows )
set( CMAKE_SYSTEM_PROCESSOR arm64 )

set( target arm64-pc-windows-msvc )
set( CMAKE_C_COMPILER_TARGET ${target} )
set( CMAKE_CXX_COMPILER_TARGET ${target} )
6 changes: 3 additions & 3 deletions include/minja/minja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ inline std::shared_ptr<Context> Context::builtins() {
}));
globals.set("namespace", Value::callable([=](const std::shared_ptr<Context> &, ArgumentsValue & args) {
auto ns = Value::object();
args.expectArgs("namespace", {0, 0}, {0, std::numeric_limits<size_t>::max()});
args.expectArgs("namespace", {0, 0}, {0, (std::numeric_limits<size_t>::max)()});
for (auto & [name, value] : args.kwargs) {
ns.set(name, value);
}
Expand Down Expand Up @@ -2632,7 +2632,7 @@ inline std::shared_ptr<Context> Context::builtins() {
};
// https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.reject
globals.set("reject", Value::callable([=](const std::shared_ptr<Context> & context, ArgumentsValue & args) {
args.expectArgs("reject", {2, std::numeric_limits<size_t>::max()}, {0, 0});
args.expectArgs("reject", {2, (std::numeric_limits<size_t>::max)()}, {0, 0});
auto & items = args.args[0];
auto filter_fn = context->get(args.args[1]);
if (filter_fn.is_null()) throw std::runtime_error("Undefined filter: " + args.args[1].dump());
Expand Down Expand Up @@ -2703,7 +2703,7 @@ inline std::shared_ptr<Context> Context::builtins() {
return out;
}));
globals.set("selectattr", Value::callable([=](const std::shared_ptr<Context> & context, ArgumentsValue & args) {
args.expectArgs("selectattr", {2, std::numeric_limits<size_t>::max()}, {0, 0});
args.expectArgs("selectattr", {2, (std::numeric_limits<size_t>::max)()}, {0, 0});
auto & items = args.args[0];
if (items.is_null())
return Value::array();
Expand Down
12 changes: 10 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

add_executable(test-syntax test-syntax.cpp)
target_compile_features(test-syntax PUBLIC cxx_std_17)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
target_compile_definitions(test-syntax PUBLIC _CRT_SECURE_NO_WARNINGS)
target_compile_options(gtest PRIVATE -Wno-language-extension-token)
endif()
target_link_libraries(test-syntax PRIVATE
nlohmann_json::nlohmann_json
gtest_main
gmock
)
gtest_discover_tests(test-syntax)
if (NOT CMAKE_CROSSCOMPILING)
gtest_discover_tests(test-syntax)
endif()

add_test(NAME test-syntax-jinja2 COMMAND test-syntax)
set_tests_properties(test-syntax-jinja2 PROPERTIES ENVIRONMENT "USE_JINJA2=1;PYTHON_EXECUTABLE=${Python_EXECUTABLE};PYTHONPATH=${CMAKE_SOURCE_DIR}")
Expand Down Expand Up @@ -119,5 +125,7 @@ if (MINJA_FUZZTEST_ENABLED)
target_include_directories(test-fuzz PRIVATE ${fuzztest_BINARY_DIR})
target_link_libraries(test-fuzz PRIVATE nlohmann_json::nlohmann_json)
link_fuzztest(test-fuzz)
gtest_discover_tests(test-fuzz)
if (NOT CMAKE_CROSSCOMPILING)
gtest_discover_tests(test-fuzz)
endif()
endif()
Loading