Skip to content

Commit c802dd5

Browse files
authored
[ci] fix freebsd ci (#265)
* Refactor WebAssembly 1.1 feature flags and improve error handling - Updated feature flag checks in various files to use `disable_*` instead of `enable_*` for better clarity and consistency in feature management. - Enhanced error handling logic to ensure proper validation of WebAssembly 1.1 features, improving robustness against unsupported operations. - Refactored related documentation to clarify the implications of enabling and disabling specific WebAssembly features, aiding user understanding. - Improved overall code maintainability by streamlining feature flag management and enhancing the clarity of error reporting mechanisms. * Enhance FreeBSD CI workflow with swapfile configuration - Added a new environment variable `freebsd_swapfile_mb` to configure the swapfile size for FreeBSD CI jobs, improving memory management during builds. - Updated the CI script to create and enable a swapfile before executing build commands, ensuring sufficient memory resources are available for the build process. - Enhanced error handling in the build script to provide better diagnostics in case of failures related to memory allocation and swap management. * Refactor fast_io_float_ext_fuzzer.cc by removing simulated __float80 implementation - Eliminated the custom __float80 struct and its associated operator overloads, streamlining the codebase. - Removed numeric_limits specialization for __float80, enhancing clarity and maintainability. - Updated the exercise_parsed_token function to ensure compatibility with existing types, improving overall robustness. - Added necessary includes for concepts to support modern C++ features. * Update FreeBSD CI workflow to optimize memory management and build process - Reduced the FreeBSD swapfile size from 4096MB to 2048MB for improved resource allocation during CI jobs. - Added cleanup commands to the CI script to optimize package management and reduce disk usage. - Enhanced build configuration commands to include additional flags for better performance and debugging information. - Implemented cleanup steps for build artifacts to ensure a more efficient CI environment.
1 parent f86181d commit c802dd5

33 files changed

Lines changed: 602 additions & 599 deletions

.github/workflows/ci.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ jobs:
386386
env:
387387
version: "14.3"
388388
freebsd_vm_memory: "8G"
389+
freebsd_swapfile_mb: "2048"
389390
strategy:
390391
matrix:
391392
compiler: ["CLANG"]
@@ -420,10 +421,11 @@ jobs:
420421
memory: ${{ env.freebsd_vm_memory }}
421422
run: |
422423
bash -c "sudo pkg install -y llvm21 gmake unzip libunwind"
424+
bash -c "sudo pkg clean -ay"
423425
bash -c "sudo ln -sf $(command -v llvm-config21) /usr/local/bin/llvm-config"
424426
bash -c "curl -fsSL https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh -o xmake-get.sh"
425427
bash -c "bash xmake-get.sh"
426-
bash -c "source ~/.xmake/profile && xmake f -y -m ${{ matrix.mode }} --policies=${{ matrix.policies }} --use-llvm-compiler=y --sdk="$(llvm-config21 --prefix)" --march=none --static=none --includedirs=/usr/local/include --linkdirs=/usr/local/lib --syslinks=unwind"
428+
bash -c "source ~/.xmake/profile && xmake f -y -m ${{ matrix.mode }} --policies=${{ matrix.policies }} --use-llvm-compiler=y --sdk="$(llvm-config21 --prefix)" --march=none --static=none --strip=symbol --cxflags=-g1 --includedirs=/usr/local/include --linkdirs=/usr/local/lib --syslinks=unwind"
427429
- name: Configure
428430
if: matrix.compiler == 'GCC'
429431
uses: cross-platform-actions/action@v0.30.0
@@ -433,16 +435,35 @@ jobs:
433435
memory: ${{ env.freebsd_vm_memory }}
434436
run: |
435437
bash -c "sudo pkg install -y gcc16-devel gmake unzip"
438+
bash -c "sudo pkg clean -ay"
436439
bash -c "curl -fsSL https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh -o xmake-get.sh"
437440
bash -c "bash xmake-get.sh"
438-
bash -c "source ~/.xmake/profile && xmake f -y -m ${{ matrix.mode }} --policies=${{ matrix.policies }} --cc=gcc16 --cxx=g++16 --ld=g++16 --march=none --static=none"
441+
bash -c "source ~/.xmake/profile && xmake f -y -m ${{ matrix.mode }} --policies=${{ matrix.policies }} --cc=gcc16 --cxx=g++16 --ld=g++16 --march=none --static=none --strip=symbol --cxflags=-g1"
439442
- name: Build and check
440443
uses: cross-platform-actions/action@v0.30.0
441444
with:
442445
operating_system: freebsd
443446
version: ${{ env.version }}
444447
memory: ${{ env.freebsd_vm_memory }}
445448
run: |
446-
bash -c "source ~/.xmake/profile && xmake b -rv -j1 || { rc=\$?; swapinfo || true; dmesg | tail -n 80 || true; exit \$rc; }"
449+
bash <<'FREEBSD_CI_SWAP'
450+
set -eux
451+
swapfile=/usr/swap0
452+
sudo dd if=/dev/zero of="${swapfile}" bs=1m count=${{ env.freebsd_swapfile_mb }}
453+
sudo chmod 0600 "${swapfile}"
454+
swapdev="$(sudo mdconfig -a -t vnode -f "${swapfile}")"
455+
case "${swapdev}" in
456+
/dev/*) ;;
457+
md*) swapdev="/dev/${swapdev}" ;;
458+
*) swapdev="/dev/md${swapdev}" ;;
459+
esac
460+
sudo swapon "${swapdev}"
461+
swapinfo
462+
df -h / /usr || true
463+
FREEBSD_CI_SWAP
464+
bash -c "source ~/.xmake/profile && xmake b -rv -j1 || { rc=\$?; swapinfo || true; df -h / /usr || true; dmesg | tail -n 80 || true; exit \$rc; }"
447465
bash -c "source ~/.xmake/profile && export UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 && xmake run uwvm --version"
466+
bash -c "source ~/.xmake/profile && xmake clean -y uwvm || true"
467+
bash -c "source ~/.xmake/profile && xmake clean -y uwvm_runtime || true"
468+
bash -c "df -h / /usr || true"
448469
bash -c "source ~/.xmake/profile && export UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 && xmake test -v -j1"

src/uwvm2/parser/wasm/standard/wasm1p1/features/data_count_section.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1p1::features
6363
::std::byte const* const sec_id_module_ptr) UWVM_THROWS
6464
{
6565
auto const& para{::uwvm2::parser::wasm::standard::wasm1p1::features::get_wasm1p1_parameter(fs_para)};
66-
if(!para.enable_bulk_memory) [[unlikely]]
66+
if(para.disable_bulk_memory) [[unlikely]]
6767
{
6868
err.err_curr = sec_id_module_ptr;
6969
err.err_selectable.wasm1p1_feature_required.value =

src/uwvm2/parser/wasm/standard/wasm1p1/features/data_section.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
417417
}
418418
case ::uwvm2::parser::wasm::standard::wasm1p1::features::wasm1p1_data_type_t::passive:
419419
{
420-
if(!para.enable_bulk_memory) [[unlikely]]
420+
if(para.disable_bulk_memory) [[unlikely]]
421421
{
422422
err.err_curr = section_curr;
423423
err.err_selectable.wasm1p1_feature_required.value = static_cast<wasm_u32>(fdt_type);
@@ -432,7 +432,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
432432
}
433433
case ::uwvm2::parser::wasm::standard::wasm1p1::features::wasm1p1_data_type_t::active_explicit:
434434
{
435-
if(!para.enable_bulk_memory) [[unlikely]]
435+
if(para.disable_bulk_memory) [[unlikely]]
436436
{
437437
err.err_curr = section_curr;
438438
err.err_selectable.wasm1p1_feature_required.value = static_cast<wasm_u32>(fdt_type);

src/uwvm2/parser/wasm/standard/wasm1p1/features/def.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,31 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1p1::features
4949
struct wasm1p1;
5050

5151
/// @brief Runtime switches for independent WebAssembly 1.1 feature groups.
52+
/// @details The disable_* fields are false by default, so WebAssembly 1.1 features are enabled unless the user explicitly disables them.
5253
/// @details The explicit_* fields record CLI ownership so the feature collection and its subfeatures can report conflicts deterministically.
5354
/// @warning Extension point: every new wasm1.1 subfeature flag needs CLI ownership, feature conflict handling, parser gating, and ECO output.
5455
struct wasm_binfmt1p1_feature_parameter
5556
{
56-
bool enable_multi_value{};
57-
bool enable_reference_types{};
58-
bool enable_bulk_memory{};
59-
bool enable_sign_extension{};
60-
bool enable_nontrapping_float_to_int{};
61-
bool enable_simd{};
62-
63-
bool explicit_feature_1p1{};
64-
bool explicit_enable_multi_value{};
65-
bool explicit_enable_reference_types{};
66-
bool explicit_enable_bulk_memory{};
67-
bool explicit_enable_sign_extension{};
68-
bool explicit_enable_nontrapping_float_to_int{};
69-
bool explicit_enable_simd{};
57+
bool disable_multi_value{};
58+
bool disable_reference_types{};
59+
bool disable_bulk_memory{};
60+
bool disable_sign_extension{};
61+
bool disable_nontrapping_float_to_int{};
62+
bool disable_simd{};
63+
64+
bool explicit_feature_mvp{};
65+
bool explicit_disable_multi_value{};
66+
bool explicit_disable_reference_types{};
67+
bool explicit_disable_bulk_memory{};
68+
bool explicit_disable_sign_extension{};
69+
bool explicit_disable_nontrapping_float_to_int{};
70+
bool explicit_disable_simd{};
7071

7172
wasm1p1_parser_limit_t parser_limit{};
7273

73-
/// @brief Preserve wasm1 validation when wasm1p1 is compiled in but the runtime flags are still disabled.
74-
bool controllable_allow_multi_result_vector{true};
75-
bool controllable_allow_multi_table{true};
74+
/// @brief Re-enable wasm1 validation when a wasm1p1 feature that relaxes MVP syntax is explicitly disabled.
75+
bool controllable_allow_multi_result_vector{};
76+
bool controllable_allow_multi_table{};
7677
};
7778

7879
/// @brief Get the const wasm1.1 feature parameter from a parser feature-parameter tuple.
@@ -105,9 +106,9 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1p1::features
105106
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::i64: [[fallthrough]];
106107
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::f32: [[fallthrough]];
107108
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::f64: return true;
108-
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::v128: return para.enable_simd;
109+
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::v128: return !para.disable_simd;
109110
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::funcref: [[fallthrough]];
110-
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::externref: return para.enable_reference_types;
111+
case ::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::externref: return !para.disable_reference_types;
111112
default: return false;
112113
}
113114
}
@@ -126,7 +127,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1p1::features
126127
// funcref remains the MVP table element type. Reference-typed locals/globals are gated by value_type_enabled instead.
127128
return true;
128129
}
129-
case ::uwvm2::parser::wasm::standard::wasm1p1::type::reference_type::externref: return para.enable_reference_types;
130+
case ::uwvm2::parser::wasm::standard::wasm1p1::type::reference_type::externref: return !para.disable_reference_types;
130131
default: return false;
131132
}
132133
}

src/uwvm2/parser/wasm/standard/wasm1p1/features/element_section.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
772772

773773
auto const require_bulk_memory = [&]() UWVM_THROWS
774774
{
775-
if(!para.enable_bulk_memory) [[unlikely]]
775+
if(para.disable_bulk_memory) [[unlikely]]
776776
{
777777
err.err_curr = section_curr;
778778
err.err_selectable.wasm1p1_feature_required.value = static_cast<wasm_u32>(fet_type);
@@ -785,7 +785,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
785785

786786
auto const require_reference_types = [&]() UWVM_THROWS
787787
{
788-
if(!para.enable_reference_types) [[unlikely]]
788+
if(para.disable_reference_types) [[unlikely]]
789789
{
790790
err.err_curr = section_curr;
791791
err.err_selectable.wasm1p1_feature_required.value = static_cast<wasm_u32>(fet_type);

src/uwvm2/parser/wasm/standard/wasm1p1/features/types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
608608
case static_cast<::uwvm2::parser::wasm::standard::wasm1::type::op_basic_type>(0xD0u):
609609
{
610610
auto const& para{::uwvm2::parser::wasm::standard::wasm1p1::features::get_wasm1p1_parameter(fs_para)};
611-
if(!para.enable_reference_types) [[unlikely]]
611+
if(para.disable_reference_types) [[unlikely]]
612612
{
613613
err.err_curr = section_curr;
614614
err.err_selectable.wasm1p1_feature_required.value = 0xD0u;
@@ -675,7 +675,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
675675
case static_cast<::uwvm2::parser::wasm::standard::wasm1::type::op_basic_type>(0xD2u):
676676
{
677677
auto const& para{::uwvm2::parser::wasm::standard::wasm1p1::features::get_wasm1p1_parameter(fs_para)};
678-
if(!para.enable_reference_types) [[unlikely]]
678+
if(para.disable_reference_types) [[unlikely]]
679679
{
680680
err.err_curr = section_curr;
681681
err.err_selectable.wasm1p1_feature_required.value = 0xD2u;
@@ -744,7 +744,7 @@ UWVM_MODULE_EXPORT namespace uwvm2::parser::wasm::standard::wasm1::features
744744
case static_cast<::uwvm2::parser::wasm::standard::wasm1::type::op_basic_type>(0xFDu):
745745
{
746746
auto const& para{::uwvm2::parser::wasm::standard::wasm1p1::features::get_wasm1p1_parameter(fs_para)};
747-
if(!para.enable_simd) [[unlikely]]
747+
if(para.disable_simd) [[unlikely]]
748748
{
749749
err.err_curr = section_curr;
750750
err.err_selectable.wasm1p1_feature_required.value = 0xFDu;

src/uwvm2/runtime/compiler/llvm_jit/compile_all_from_uwvm/translate/opcode/wasm1p1_cases.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ case static_cast<wasm1_code>(wasm1p1_code::select_t):
2121

2222
return static_cast<::uwvm2::parser::wasm::standard::wasm1p1::type::value_type>(type) ==
2323
::uwvm2::parser::wasm::standard::wasm1p1::type::value_type::v128 &&
24-
wasm1p1_para.enable_simd;
24+
!wasm1p1_para.disable_simd;
2525
}};
2626

2727
auto const validate_select_condition{[&](concrete_operand_t cond) constexpr UWVM_THROWS
@@ -142,7 +142,7 @@ case static_cast<wasm1_code>(wasm1p1_code::select_t):
142142
case static_cast<wasm1_code>(wasm1p1_code::i32_extend8_s):
143143
{
144144
auto const op_begin{code_curr};
145-
if(!wasm1p1_para.enable_sign_extension) [[unlikely]]
145+
if(wasm1p1_para.disable_sign_extension) [[unlikely]]
146146
{
147147
fail_wasm1p1_feature_required(op_begin,
148148
opcode_byte(wasm1p1_code::i32_extend8_s),
@@ -176,7 +176,7 @@ case static_cast<wasm1_code>(wasm1p1_code::i32_extend8_s):
176176
case static_cast<wasm1_code>(wasm1p1_code::i32_extend16_s):
177177
{
178178
auto const op_begin{code_curr};
179-
if(!wasm1p1_para.enable_sign_extension) [[unlikely]]
179+
if(wasm1p1_para.disable_sign_extension) [[unlikely]]
180180
{
181181
fail_wasm1p1_feature_required(op_begin,
182182
opcode_byte(wasm1p1_code::i32_extend16_s),
@@ -210,7 +210,7 @@ case static_cast<wasm1_code>(wasm1p1_code::i32_extend16_s):
210210
case static_cast<wasm1_code>(wasm1p1_code::i64_extend8_s):
211211
{
212212
auto const op_begin{code_curr};
213-
if(!wasm1p1_para.enable_sign_extension) [[unlikely]]
213+
if(wasm1p1_para.disable_sign_extension) [[unlikely]]
214214
{
215215
fail_wasm1p1_feature_required(op_begin,
216216
opcode_byte(wasm1p1_code::i64_extend8_s),
@@ -244,7 +244,7 @@ case static_cast<wasm1_code>(wasm1p1_code::i64_extend8_s):
244244
case static_cast<wasm1_code>(wasm1p1_code::i64_extend16_s):
245245
{
246246
auto const op_begin{code_curr};
247-
if(!wasm1p1_para.enable_sign_extension) [[unlikely]]
247+
if(wasm1p1_para.disable_sign_extension) [[unlikely]]
248248
{
249249
fail_wasm1p1_feature_required(op_begin,
250250
opcode_byte(wasm1p1_code::i64_extend16_s),
@@ -278,7 +278,7 @@ case static_cast<wasm1_code>(wasm1p1_code::i64_extend16_s):
278278
case static_cast<wasm1_code>(wasm1p1_code::i64_extend32_s):
279279
{
280280
auto const op_begin{code_curr};
281-
if(!wasm1p1_para.enable_sign_extension) [[unlikely]]
281+
if(wasm1p1_para.disable_sign_extension) [[unlikely]]
282282
{
283283
fail_wasm1p1_feature_required(op_begin,
284284
opcode_byte(wasm1p1_code::i64_extend32_s),
@@ -323,7 +323,7 @@ case static_cast<wasm1_code>(wasm1p1_code::numeric_prefix):
323323
curr_operand_stack_value_type operand_type,
324324
curr_operand_stack_value_type result_type) constexpr UWVM_THROWS
325325
{
326-
if(!wasm1p1_para.enable_nontrapping_float_to_int) [[unlikely]]
326+
if(wasm1p1_para.disable_nontrapping_float_to_int) [[unlikely]]
327327
{
328328
fail_wasm1p1_feature_required(op_begin,
329329
subopcode,
@@ -507,7 +507,7 @@ case static_cast<wasm1_code>(wasm1p1_code::numeric_prefix):
507507
break;
508508
case wasm1p1_numeric_code::memory_copy:
509509
{
510-
if(!wasm1p1_para.enable_bulk_memory) [[unlikely]]
510+
if(wasm1p1_para.disable_bulk_memory) [[unlikely]]
511511
{
512512
fail_wasm1p1_feature_required(op_begin,
513513
subopcode,
@@ -524,7 +524,7 @@ case static_cast<wasm1_code>(wasm1p1_code::numeric_prefix):
524524
}
525525
case wasm1p1_numeric_code::memory_fill:
526526
{
527-
if(!wasm1p1_para.enable_bulk_memory) [[unlikely]]
527+
if(wasm1p1_para.disable_bulk_memory) [[unlikely]]
528528
{
529529
fail_wasm1p1_feature_required(op_begin,
530530
subopcode,

0 commit comments

Comments
 (0)